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.

mminfommreadmmwriteExtracts size and s<strong>to</strong>rage informationReads a Matrix Market fileWrites a sparse or dense matrixFigure 11 – Functions from the Matrix Market module.elements.<strong>In</strong> the specification, two matrix formats are defined.– Coordinate Format. A file format suitable for representing general sparsematrices. Only nonzero entries are provided, and the coordinates ofeach nonzero entry is given explicitly. This is illustrated in the examplebelow.– Array Format. A file format suitable for representing general densematrices. All entries are provided in a pre-defined (column-oriented)order.The Matrix Market file format can be used <strong>to</strong> manage dense or sparsematrices. MM coordinate format is suitable for representing sparse matrices.Only nonzero entries need be encoded, and the coordinates of each are givenexplicitly.http://a<strong>to</strong>ms.scilab.org/<strong>to</strong>olboxes/MatrixMarket<strong>In</strong> order <strong>to</strong> install the Matrix Market module, we use the a<strong>to</strong>ms system,as in the following script.a<strong>to</strong>ms<strong>In</strong>stall (" MatrixMarket ")The table 11 presents the functions provided by the Matrix Market module.<strong>In</strong> the following script, we create a sparse matrix with the sparse functionand save it in<strong>to</strong> a file with the mmwrite function.A= sparse ([1 ,1;1 ,3;2 ,2;3 ,1;3 ,3;3 ,4;4 ,3;4 ,4] ,..[9;27+ %i ;16;27 - %i ;145;88;88;121] ,[4 ,4]) ;filename = TMPDIR +"/A. mtx ";mmwrite ( filename ,A);<strong>In</strong> the following session, we use the mminfo function <strong>to</strong> extract informationsfrom this file.--> mminfo ( filename );=====================================25

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

Saved successfully!

Ooh no, something went wrong!