compute compressed sparse row and column forms
sparse Matrix with hardware data type
optional equations controlling the details of the computation
form = row or form = column
This option determines whether the compressed sparse column form or the compressed sparse row form is returned. The default is compressed sparse column form.
output = CB or R or X or a list of these values
If output is set to CB, then only CB is returned. Similarly for R and X. If a list of these values is selected, then Maple returns the corresponding values in that order, as an expression sequence. The default value is [CB, R, X]: return the sequence of all three Vectors.
cbbase = posint
rbase = posint
These options determines at what number Maple starts numbering the rows and columns. The default is 1, corresponding to the standard Maple convention. Other values, in particular 0, are mainly useful if the result is passed to external code.
The setting of cbbase changes the values in CB: it changes the start of indexing into R and X. The setting of rbase changes the values in R: it changes the start of indexing into A.
The CompressedSparseForm function computes either the compressed sparse row form or the compressed sparse column form of the input Matrix A, which needs to have one of the hardware data types. It thus performs the opposite function to FromCompressedSparseForm.
The compressed sparse column form of an n by m Matrix A with k nonzero entries consists of three Vectors, CB, R, and X. These are obtained by sorting the k nonzero entries of A first by column, and then within each column sorting the entries by row. Now X is the k-element Vector of these nonzero values in A in this order, and R is the k-element Vector of row indices at which these values occur. CB is an n+1-element Vector; CBi is the index in both X and R where the ith column starts. We always have CB1=1 and CBn+1=k+1, so that the entries in column i have indices CBi up to, but not including, CBi+1. (If the cbbase option below is used, then CB1=cbbase and CBn+1=k+cbbase and a similar statement holds.)
The compressed sparse row form is very similar, but with the roles of rows and columns interchanged. Specifically, we first sort A by row and then within each row by column; X is still the nonzero values occurring in A. However, R is the k-element Vector of column indices. Similarly, CBi is the index in X and R where the ith row starts.
The compressed sparse forms are most useful for sparse Matrices. If A does not have sparse storage (as determined by rtable_option⁡X,storage being either sparse or sparseupper or sparselower), then a sparse storage copy is made before determining the compressed sparse form.
If A has any indexing functions (as determined by rtable_indfns⁡A), then these are bypassed when determining the compressed sparse row or column form: since CompressedSparseForm is a low level command, Maple returns the compressed sparse form of the stored entries only. For example, if a Matrix is defined with option shape=symmetric and storage=sparseupper, then only one of each pair of off-diagonal entries will be represented in the compressed sparse form. However, if A has indexing functions but no sparse storage, then the copy made to give it sparse storage, as explained above, typically gets rid of the indexing function and stores all nonzero entries.
The code for CompressedSparseForm relies on A being a NAG-sparse Matrix (potentially after copying it to give it sparse storage); that is, its datatype as returned by rtable_options needs to be one of these values:
Let us examine the compressed sparse row and column form of an arbitrary matrix.
We can obtain the entries of r corresponding to the second column as follows.
Similarly for the entries of x.
CompressedSparseForm does not work with Matrices that are not of a hardware data type.
Error, (in LinearAlgebra:-CompressedSparseForm) cannot compute compressed sparse form of a Matrix with non-hardware datatype anything
To make this work, we need to recreate m3 with, for example, option datatype=integer4.
Here is an example of the antisymmetric indexing function being ignored.
The LinearAlgebra[CompressedSparseForm] command was introduced in Maple 17.
For more information on Maple 17 changes, see Updates in Maple 17.
Download Help Document
What kind of issue would you like to report? (Optional)