LinearAlgebra - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Linear Algebra : LinearAlgebra Package : Solvers : LinearAlgebra/FromCompressedSparseForm

LinearAlgebra

  

FromCompressedSparseForm

  

translate compressed sparse row and column forms to native Maple form

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

FromCompressedSparseForm(CB, R, X, opts)

Parameters

CB

-

integer vector of column bounds

R

-

integer vector of row coordinates

X

-

hardware datatype vector with values

opts

-

optional equations controlling the details of the computation

Options

• 

form = row or form = column

  

This option determines whether CB, R, and X are interpreted as the compressed sparse column form of A or as its compressed sparse row form. The default is compressed sparse column form.

• 

otherdimension = n

  

This option determines the number of columns of A in the case of compressed sparse column form, and the number of rows of A in the case of compressed sparse row form. If the option is not specified, Maple uses the maximal entry in R.

• 

scan = true or scan = false

  

This option determines whether or not X is scanned for zeroes. If scan = true, the default, then X is scanned to test if it contains any entries that are equal to 0. If this is the case, the operation is aborted with an error message: such entries are not allowed. If you are certain that there are no entries equal to 0, you can save a little bit of processing time by disabling this scan by passing scan = false to the procedure. Use this option with extreme caution.

• 

rbase = posint

  

This option determines at what number Maple starts numbering the rows, for compressed sparse column form, or the columns, for compressed sparse row form. The default is 1, corresponding to the standard Maple convention. Other values, in particular 0, are mainly useful if the data come from external code.

  

The inverse command, CompressedSparseForm, also has a cbbase option. This corresponds to the first entry of CB and cannot be set manually for FromCompressedSparseForm.

Description

• 

The FromCompressedSparseForm function constructs a sparse Matrix A from either its compressed sparse row form or its compressed sparse column form, performing the opposite function to CompressedSparseForm.

• 

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 CBn+1=CB1+k, so that the entries in column i have indices CBi up to, but not including, CBi+1.

• 

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 code for FromCompressedSparseForm relies on being able to construct A as a NAG-sparse Matrix; that is, the datatype of X as returned by rtable_options needs to be one of these values:

  

sfloat,complexsfloat,integer[1],integer[2],integer[4],integer[8],float[4],float[8],complex[8]

Examples

withLinearAlgebra:

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

mMatrix5,6,1,2=81,2,3=55,2,4=15,3,1=46,3,3=17,3,4=99,3,5=61,4,2=18,4,5=78,5,6=22,datatype=integer[4]

m:=0810000005515004601799610018007800000022

(1)

cb,r,xCompressedSparseFormm

cb,r,x:=124681011,3142323345,46811855171599617822

(2)

FromCompressedSparseFormcb,r,x

0810000005515004601799610018007800000022

(3)

cb,r,xCompressedSparseFormm,'form=row'

cb,r,x:=12481011,2341345256,81551546179961187822

(4)

FromCompressedSparseFormcb,r,x,'form=row'

0810000005515004601799610018007800000022

(5)

FromCompressedSparseFormcb,r,x

0046008100180055170001599000061780000022

(6)

cb,r,xCompressedSparseFormm,'cbbase'=3,'rbase'=2

cb,r,x:=3468101213,0211010012,46811855171599617822

(7)

FromCompressedSparseFormcb,r,x,'rbase'=2

0810000005515004601799610018007800000022

(8)

If the matrix has zero rows at the bottom, these are not reflected in the compressed sparse column form. (Similarly, zero columns at the right are not reflected in the compressed sparse row form.)

m1Matrix0,1,0,2,0,0,3,0,4,'datatype=float'

m1:=0.1.0.2.0.0.3.0.4.

(9)

m2Matrix0,1,0,2,0,0,3,0,4,0,0,0,'datatype=float'

m2:=0.1.0.2.0.0.3.0.4.0.0.0.

(10)

cb1,r1,x1CompressedSparseFormm1

cb1,r1,x1:=1345,2313,2.3.1.4.

(11)

cb2,r2,x2CompressedSparseFormm2

cb2,r2,x2:=1345,2313,2.3.1.4.

(12)

Therefore, to recover the original Matrix, you may need to use the otherdimension option.

FromCompressedSparseFormcb2,r2,x2

0.1.0.2.0.0.3.0.4.

(13)

FromCompressedSparseFormcb2,r2,x2,'otherdimension'=4

0.1.0.2.0.0.3.0.4.0.0.0.

(14)

Compatibility

• 

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

• 

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

See Also

LinearAlgebra[CompressedSparseForm]

LinearAlgebra[FromSplitForm]

LinearAlgebra[SplitForm]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam