CompressedSparseForm - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


LinearAlgebra

  

CompressedSparseForm

  

compute compressed sparse row and column forms

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

CompressedSparseForm(A, opts)

Parameters

A

-

sparse Matrix with hardware data type

opts

-

optional equations controlling the details of the computation

Options

• 

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 : it changes the start of indexing into  and . The setting of rbase changes the values in : it changes the start of indexing into .

• 

length0 = true or length0 = false

  

Maple has no problems working with Vectors of length 0, but some external tools do. If length0 is set to false, and A has no nonzero entries, then Maple returns values pretending that the [1, 1] entry is stored and has value 0. This and the includediagonal and structuralsymmetry options below are the only cases in which X contains a zero value.

• 

includediagonal = true or includediagonal = false

  

If the includediagonal option is set to true, then Maple includes all diagonal entries in the result, even if their value is zero. If it is set to false (the default), then Maple omits all zero entries, including if they occur on the diagonal. The former is useful when preparing input for some external tools.

• 

structuralsymmetry = true or structuralsymmetry = false

  

If the structuralsymmetry option is set to true, then Maple ensures that, whenever a value  is included in the result, then  is also included, even if it is zero. If it is set to false (the default), then Maple does not do this. The former is useful when preparing input for some external tools.

  

The structuralsymmetry option can only be used if A is a square Matrix.

Description

• 

The CompressedSparseForm function computes either the compressed sparse row form or the compressed sparse column form of the input Matrix , 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  by  Matrix  with  nonzero entries consists of three Vectors, , , and . These are obtained by sorting the  nonzero entries of  first by column, and then within each column sorting the entries by row. Now  is the -element Vector of these nonzero values in  in this order, and  is the -element Vector of row indices at which these values occur.  is an -element Vector;  is the index in both  and  where the th column starts. We always have  and , so that the entries in column  have indices  up to, but not including, . (If the  option below is used, then  and  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  by row and then within each row by column;  is still the nonzero values occurring in . However,  is the -element Vector of column indices. Similarly,  is the index in  and  where the th row starts.

• 

The compressed sparse forms are most useful for sparse Matrices. If  does not have sparse storage (as determined by  being either  or  or ), then a sparse storage copy is made before determining the compressed sparse form.

• 

If  has any indexing functions (as determined by ), 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  and , then only one of each pair of off-diagonal entries will be represented in the compressed sparse form. However, if  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  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:

  

Examples

Let us examine the compressed sparse row and column form of an arbitrary matrix.

(1)

(2)

(3)

Setting  causes the entries of  to be reduced by 1.

(4)

Setting  causes the entries of  to be reduced by 1.

(5)

Using the  option ensures that all 6 diagonal entries are included, even though most of them are 0.

(6)

(7)

We can obtain the entries of  corresponding to the second column as follows.

(8)

(9)

Similarly for the entries of .

(10)

We will omit the last row of  and illustrate the includediagonal and structuralsymmetry options. First, this is what the result looks like without these options.

(11)

(12)

Adding the structuralsymmetry option makes Maple include the entry for , even though it is 0, because  is nonzero.

(13)

Adding the includediagonal option makes Maple include the entries for  and , even though they are 0.

(14)

Adding both of these options makes Maple include the entries for , , and .

(15)

CompressedSparseForm does not work with Matrices that are not of a hardware data type.

(16)

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  with, for example, option .

(17)

(18)

Here is an example of the antisymmetric indexing function being ignored.

(19)

(20)

Compatibility

• 

The LinearAlgebra[CompressedSparseForm] command was introduced in Maple 17.

• 

For more information on Maple 17 changes, see Updates in Maple 17.

• 

The LinearAlgebra[CompressedSparseForm] command was updated in Maple 2022.

• 

The length0, includediagonal and structuralsymmetry options were introduced in Maple 2022.

• 

For more information on Maple 2022 changes, see Updates in Maple 2022.

See Also

LinearAlgebra[FromCompressedSparseForm]

LinearAlgebra[FromSplitForm]

LinearAlgebra[SplitForm]

rtable_indfns

rtable_options

 


Download Help Document