11.07.2015 Views

Introduction to Sparse Matrices In Scilab - Projects

Introduction to Sparse Matrices In Scilab - Projects

Introduction to Sparse Matrices In Scilab - Projects

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

sp2adjspeyesponessprandspzerosfullsparsemtlb sparsennzspcompackspgetconverts sparse matrix in<strong>to</strong> adjacency formsparse identity matrixsparse matrixsparse random matrixsparse zero matrixsparse <strong>to</strong> full matrix conversionsparse matrix definitionconvert sparse matrixnumber of non zero entries in a matrixconverts a compressed adjacency representationretrieves entries of sparse matrixFigure 1 – Basic features for sparse matrices.matrix is s<strong>to</strong>red internally.2.1 Creating sparse matricesThe figure 1 present several functions <strong>to</strong> create sparse matrices.<strong>In</strong> the following session, we use the sprand function <strong>to</strong> create a 100×1000sparse matrix with density 0.001. The density parameter makes so that thenumber of non-zero entries in the sparse matrix is approximately equal <strong>to</strong>100 · 1000 · 0.001 = 100. Then we use the size function <strong>to</strong> compute the sizeof the matrix. Finally, we compute the number of non-zero entries with thennz function.-->A= sprand (100 ,1000 ,0.001);--> size (A)ans =100. 1000.-->nnz (A)ans =100.The sparse and full functions works as complementary functions. <strong>In</strong>deed,the sparse function converts a full matrix in<strong>to</strong> a sparse one, while thefull function converts a sparse matrix in<strong>to</strong> a full one.<strong>In</strong> the following session, we create a 3 × 5 dense matrix. Then we use thesparse function <strong>to</strong> convert it in<strong>to</strong> a sparse matrix. <strong>Scilab</strong> then displays all6

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!