Questions tagged [submatrix]

A submatrix is a matrix formed by selecting a subset of the rows and columns of one larger matrix. Questions tagged [submatrix] deal with implementation issues regading accessing the relevant rows/columns of the larger matrix, relevant memory issues, etc.

A submatrix is a matrix formed by selecting a subset of the rows and columns of one larger matrix.

For example, let A be a matrix of size n-by-m

A = [ a00 a01 ...
      a10 a11 ...
      .       .
      .        .
      .         .
      an1 an2 ... anm ]

Then one can form a 2-by-3 sub-matrix by selecting rows 2 and 5, and columns 1,4 and 6.
The resulting sub-matrix is then

S = [ a21 a24 a26
      a51 a54 a56 ]

Questions tagged [submatrix] deal with implementation issues regading accessing the relevant rows/columns of the larger matrix, relevant memory issues, etc.

183 questions
0
votes
1 answer

how to find all submatrices values are greater than threshold in a given matrix (without using numpy and Scipy)

I'm working on microcontrollers, where it doesn't supports numpy or scipy. I want to extract all submatrices greater than given threshold value in matrix. myMtarix = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 204, 0,…
0
votes
1 answer

Adding a submatrix at a certain location rounds down all entries in the submatrix (python)

I wanted to add a submatrix at a certain location and found the following article, which solved that problem: Add submatrices at certain locations My problem now is, that when ever I do this, the submatrix which originally consisted of floating…
niklasaa
  • 81
  • 5
0
votes
1 answer

Non-contiguous subsetting of matrix with RcppArmadillo

Hello and sorry for the probably stupid question. I studied a bit of C++ in my past but in the last years I've only used R. I need to transform some R code for a package I wrote using Rcpp and in particular, I'm using RcppArmadillo. Now I checked…
Andrew
  • 11
0
votes
1 answer

Python - How to make a matrix using sub-matrix?

Imagine we have an array with 100 elements. we want to turn it into a 2x2 matrix which every sub-matrix is a 5x5 matrix itself. I've write it to this level: import numpy as np M = np.linspace(1,100,100) MUL = M[0:25].reshape([5,5]) MUR =…
Moty.R
  • 47
  • 1
  • 9
0
votes
0 answers

How can I scan for the max value in a sub-matrix[dim][dim], given an int matrix[n][m]? C

I've read an (int) matrix[N][M] from a .txt file which turned out to be square. I am given a certain dimension "d" which will be the dimension of the sub-matrix[dim][dim] I'll have to use. I have to scan the original matrix and seek those numbers…
user13769879
0
votes
1 answer

Sub Matrices right diagonal - Python

The program must accept an integer matrix of size RxC and an integer K as the input.The program must print all the integers in the bottom left to top right diagonal in each KxK sub matrix without any overlapping of the given matrix NOTE: The values…
user13719023
0
votes
1 answer

Finding Non-Overlapping Sub Matrices in Python

Non-Overlapping Sub Matrices I'm stuck at finding a way to get only the non-overlapping sub matrices. My code below finds all the sub matrices. Code: n = 4 matrix = [[1,2,3,4], [5,6,7,8], [9,10,11,12], [13,14,15,16]] k…
Arsive
  • 33
  • 1
  • 7
0
votes
2 answers

Find if a small matrix exists in a big matrix in O(n)

I was asked a question in the interview: Given matrix A and matrix B, I have to write a program to find out whether matrix B exist in matrix A. The problem is I have to do it in O(n) time. This the only approach I have come up: public class Matrix…
0
votes
1 answer

R - extract submatrix based on column names and row names

I have a matrix, R of the following form. 0 0.44 0.77 0.88 0.99 0 1.00 0.75 0.50 0.25 0 0.5 0.75 0.75 0.50 0.25 0 0.6 0.50 0.50 0.25 0.25 0 0.8 0.00 0.00 0.00 0.00 0 here, colnames(R) [1] "0" "0.44" "0.77" "0.88"…
vip123
  • 1
  • 1
0
votes
1 answer

Finding maximal submatrix of all 1's - missing argument error

Program that finds the maximal rectangle containing only 1's of a binary matrix with the maximal histogram problem. I am trying to do some tests on a code def maximalRectangle(self, matrix): if not matrix or not matrix[0]: return 0 n…
Yira
  • 23
  • 4
0
votes
0 answers

Extract submatrix of unknown size from bigger matrix while values are equal to specified value

So let's say we have this matrix: 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 0 And we need those outputs: Submatrix 1: 1 1 1 1 1 1 1 1 1 Submatrix 2: 1 1 1 1 1 1 The matrix…
0
votes
0 answers

How to find duplicates in a submatrices of 2d matrix and compare them

I have a question. Can anyone help me with finding duplicates in submatrices? I have a code which finds submatrices in 2d matrix, but I can't find duplicates. I thought to push the values onto the Stack (because in assignment I should use Stack),…
0
votes
1 answer

How to pass submatrix to another function as a pointer

Consider I have a matrix A n*n elements defined as pointer of pointer **A. I want to pass a submatrix (B nb*nb) of A to another function as a pointer, perform some mathematical operation on the submatrix and return it back to the original function.…
mehdi_bm
  • 381
  • 1
  • 3
  • 16
0
votes
1 answer

Submatrix incorrectly defined in Scilab

I am given a morse potential to solve and to find its energy eigen values and vector by scilab. But i am having an issue as scilab is saying submatrix defined incorrectly. I am trying to see why my matrix is unable to be correct. I am new to this…
Anshul Sharma
  • 37
  • 1
  • 1
  • 9
0
votes
1 answer

How to obtain an entry of a square matrix inside a non square matrix

I am trying to print the last element of the largest square sub-matrix of some arbitrary-shaped rectangular matrix. I have several hints for this task: Set the variable y to be the last diagonal entry of A. Since A may not be square, you will need…
i9-9980XE
  • 11
  • 5