crs2mat {kexpmv} | R Documentation |
The EXPOKIT
's DMEPXV and DGEXPV functions both deal with sparse matrices.
These matrices have a lot of zeros, and can therefore be stored more efficiently by converting the
matrix into CRS (Compressed Row Storage) format.
crs2mat(mat, n)
mat |
a 3 column list including the vectors; ia, ja and a. |
n |
the dimension of the square (nxn) matrix. |
In EXPOKIT
and its wrapper functions, a CRS-formatted matrix is input as
3 vectors:
ia = row pointer. This vector stores the location in the ‘a’ vector that is the first non-zero element
in a row.
ja = column indices for non-zero elements.
a = non-zero elements of the matrix.
This function takes a 3-column list CRS matrix and converts it back to standard square format.
Meabh G. McCurdy mmccurdy01@qub.ac.uk
# Create a CRS format matrix ia = c(1, 2, 4, 6) ja = c(1, 1, 2, 1, 2) a = c(-0.071207, 0.065573, -0.041206, 0.005634, 0.041206) crsmat=list(ia, ja, a) # Convert CRS format matrix to square format n = 3 mat = crs2mat(crsmat, n) print(mat)