spDenseSubmat#

Purpose#

Returns a dense submatrix of a sparse matrix.

Format#

y = spDenseSubmat(x, rinds, cinds)#
Parameters:
  • x (MxN sparse matrix) – data

  • rinds (Kx1 vector) – row indices.

  • cinds (Lx1 vector) – column indices.

Returns:

y (KxL dense matrix) – the intersection of rinds and cinds.

Examples#

sparse matrix y;
x = { 0  0  0 10,
      0  2  0  0,
      0  0  0  0,
      5  0  0  0,
      0  0  0  3 };

// Set 'y' to be a sparse matrix with the same values as 'x'
y = denseToSp(x, 0);

// Extract a submatrix from 'y' with all rows of 'y' and
// columns 1, 3 and 4
d = spDenseSubmat(y, 0, 1|3|4);

Now d is equal to:

0  0 10
0  0  0
0  0  0
5  0  0
0  0  3

Remarks#

If rinds or cinds are scalar zeros, all rows or columns will be returned.

See also

Functions spSubmat()