getSM {lazy.mat}R Documentation

Extract a submatrix from a supermatrix

Description

Extract a submatrix from a supermatrix

Usage

getSM(M, i, j, index = 0, SMdim = NULL)

Arguments

M

Input supermatrix with or without SMdim attribute

i

The row number

j

The column number

index

= 1 to retrun the row and column index list.

SMdim

list of the form (nrows=, ncols=) where
nrows is a vector of rows of each submatrix,
ncols is a vector of columns of each submatrix.
This must be given when attributes(M)$SMdim=NULL.

Details

When M is a horizontally stacked supermatrix, use getSM[M,1,j]
When M is a vertically stacked supermatrix, use getSM[M,i,1]

About SMdim attribute:
SMdim attribute of a supermatrix is a list of the form (nrows=, ncols=) where
nrows is a vector of rows of each submatrix,
ncols is a vector of columns of each submatrix.

Value

a SMdim$nrows[i] x SMdim$ncols[j] matrix
Or when index=1, the index of the form list(rows=, cols=) where the i,j submatrix of S is S[rows,cols].

Examples

SM <- demomat(4,3,2, supermat=2)
getSM(SM,2,1)
SM <- demomat(c(3,2),c(3,2))
getSM(SM,2,2)
SM[ getSM(SM,2,2,1)[[1]], getSM(SM,2,2,1)[[2]] ]


[Package lazy.mat version 0.1.3 Index]