translate compressed sparse row and column forms to native Maple form - Maple 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

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

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,integer1,integer2,integer4,integer8,float4,float8,complex8

Examples

withLinearAlgebra:

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

m:=Matrix5,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=integer4

m:=0810000005515004601799610018007800000022

(1)

cb,r,x:=CompressedSparseFormm

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

(2)

FromCompressedSparseFormcb,r,x

0810000005515004601799610018007800000022

(3)

cb,r,x:=CompressedSparseFormm,'form=row'

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

(4)

FromCompressedSparseFormcb,r,x,'form=row'

0810000005515004601799610018007800000022

(5)

FromCompressedSparseFormcb,r,x

0046008100180055170001599000061780000022

(6)

cb,r,x:=CompressedSparseFormm,'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.)

m1:=Matrix0,1,0,2,0,0,3,0,4,'datatype=float'

m1:=0.1.0.2.0.0.3.0.4.

(9)

m2:=Matrix0,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,x1:=CompressedSparseFormm1

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

(11)

cb2,r2,x2:=CompressedSparseFormm2

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)

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