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
2 answers

Set the elements that are less than zero in columns 1 and 3 to zero in R

I have 4 by 5 random matrix. How can I set the elements that are less than zero in columns 1 and 3 to zero in R? I tried to use replace() function. r <- rnorm(20, mean=2, sd=2) r1 <- matrix(r, ncol=5, nrow=4, byrow=T) replace(r1, r1[,c(1,3)] < 0,…
Pol
  • 117
  • 3
0
votes
3 answers

How can I extract the sign values from a matrix into a new matrix

I have a matrix: > A[-1 0 1 0.5] > [-0.2 0.8 1 -1] > [0.4 0.8 1 -0.1] > [-0.6 0.4 -1 1] I want to extract a sub matrix from this.. so what I want the program to do is to make a matrix to preserve the signs... like so: B[-1 +1 +1…
hsayya
  • 131
  • 1
  • 10
0
votes
1 answer

spsolve overloading and rowvec type conversion consistency

With the following declarations: uvec basis; rowvec c; sp_mat B; The expression c(basis) seems to return an arma::subview_elem1 > and the following call appears to work: vec pi_B = spsolve(trans(B), c(basis),…
Dr. E.C.
  • 11
  • 1
0
votes
1 answer

submatrix view rowvec(vector_of_indices)

As an armadillo new-be, it seems like return types are hard to find in the documentation. Specifically, whether a rowvec(vector_of_indices) operation return another rowvec, or a (col)vec?? uvec indx; rowvec c; What class is c(indx) ?
Dr. E.C.
  • 11
  • 1
0
votes
1 answer

How to create all the possible Sub-Matrices from a large Matrix by shifting exactly one row and one column

I am working on a matrix problem where I have an m*n matrix and I want to extract all 5*5 matrices from it by shifting one row and column but I am not able to extract all the 5*5 matrices but only once. Can you help me extract all the matrices? I am…
0
votes
2 answers

how to make a sum of submatrices

i need to make for every sub-matrix the sum of the values. for example if i have [[1,1,2],[2,3,4]] the resulting matrix will be: M[0][0] = 1 M[0][1] = 1+1 = 2 M[0][2] = 1+1+2 = 4 M[1][0] = 1+2 = 3 M[1][1] = 1+1+2+3 = 7 M[1][2] = 1+1+2+2+3+4 =…
0
votes
1 answer

Maximum sized square sub-matrix

I have a matrix of size N*M filled with 0's and 1's. For each query K, I have to answer the maximum sized square sub-matrix in which minimum(number of 1's, number of 0's)=k where 1<=K<=10^9. For example consider the matrix of size…
Klasen
  • 159
  • 1
  • 7
0
votes
1 answer

Applying a "keep top N values" mask to image, in blocks

I have troubles understanding how to apply a function on a block of data / submatrix of a matrix. My task is to take an image, divide it into 8x8 blocks, and from each block pick 8 biggest values and set the rest to zero. I know the way could be…
ubuntuxs
  • 3
  • 1
0
votes
3 answers

c# Creating Matrix from sub matrixes

Hello high Skilled Programmers I have a test image 1600x1600. I imported this to a matrix as grayscale int values. Then i created 4x4 sub matrixes from that matrix.I made some math operations in these blocks and created new blocks. Now i need to…
0
votes
3 answers

Create a submatrix using random columns and loop

I have a 102-by-102 matrix. I want to select square sub-matrices of orders from 2 up to 8 using random column numbers. Here is what I have done so far. matt is the the original matrix of size 102-by-102. ittr = 30 cols = 3; for i = 1:ittr rr =…
MathNovice
  • 35
  • 6
0
votes
1 answer

Indexing a submatrix in R

Currently in class, I am learning about matrices. There is a particular problem I just can't crack. The problem had me create a matrix such as this: m=matrix(seq(2,48,2),nrow=6,ncol=4) Which returns this: [,1] [,2] [,3] [,4] [1,] 2 14 …
0
votes
1 answer

plotting a submatrix (ROI) in MATLAB

I am trying to select a particular region using MATLAB. Before extracting the sub matrix I am defining the region using plot command. figure,imshow(imgc,[0,3000]); hold on; plot([x1,x2],[y1,y1],'Color','r','LineWidth',0.5) hold…
amrita
  • 5
  • 4
0
votes
1 answer

Extracting part of a matrix

I have a matrix say (+) order, I want to extract first order matrix, like say , I want to extract first
Marso
  • 131
  • 4
0
votes
1 answer

Normalize between-blocks by the maxima of the block corresponding to the columns

This question is a follow-up on my previous question Instead of normalizing blocks by the local maxima, I would like to normalize between-blocks by the maxima of the block corresponding to the columns. #dummy data mat <- matrix(round(runif(90, 0,…
jO.
  • 3,384
  • 7
  • 28
  • 38
0
votes
1 answer

Normalize blocks/sub-matrices within a matrix

I want to normalize (i.e., 0-1) blocks/sub-matrices within a square matrix based on row/col names. It is important that the normalized matrix correspond to the original matrix. The below code extracts the blocks, e.g. all col/row names == "A" and…
jO.
  • 3,384
  • 7
  • 28
  • 38