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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

-->A = [-->1 2 0-->3 4 5-->0 6 7-->];-->B = sparse (A);<strong>In</strong> this case, the fields are the following.B.m: 3B.n: 3B.it: 0B. nel : 7B. mnel : [2 , 3, 2]B. icol : [1 , 2, 1, 2, 3, 2, 3]B.R: [1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0]B.I: [ undefined ]This current s<strong>to</strong>rage is different from the CSR format, in the sense thatthere is no array containing the row indices corresponding <strong>to</strong> the values andno array containing the cumulated indexes where each column starts.2.3 <strong>Sparse</strong> arithmetic<strong>Scilab</strong> provides arithmetic opera<strong>to</strong>rs for sparse matrices.<strong>In</strong>deed, most opera<strong>to</strong>rs are defined for sparse matrices. For example, theopera<strong>to</strong>rs +, - and * can be used for sparse matrices, as shown in the followingexample.Afull = [2 3 0 0 0;3 0 4 0 6;0 -1 -3 2 0;0 0 1 0 0;0 4 2 0 1];A = sparse ( Afull );B = 2*AC = A+Bx = [1;2;3;4;5]b = A * xAnother opera<strong>to</strong>r is the backslash opera<strong>to</strong>r \, which is presented in thenext section.9

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

Saved successfully!

Ooh no, something went wrong!