15.12.2012 Views

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

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.

matrix([[0, 0, 0, 0],<br />

[0, 0, 0, 0],<br />

[0, 0, 0, 0]], dtype=int8)<br />

>>> row = array([0,3,1,0])<br />

>>> col = array([0,3,1,2])<br />

>>> data = array([4,5,7,9])<br />

>>> coo_matrix( (data,(row,col)), shape=(4,4) ).todense()<br />

matrix([[4, 0, 9, 0],<br />

[0, 7, 0, 0],<br />

[0, 0, 0, 0],<br />

[0, 0, 0, 5]])<br />

>>> # example with duplicates<br />

>>> row = array([0,0,1,3,1,0,0])<br />

>>> col = array([0,2,1,3,1,0,0])<br />

>>> data = array([1,1,1,1,1,1,1])<br />

>>> coo_matrix( (data,(row,col)), shape=(4,4)).todense()<br />

matrix([[3, 0, 1, 0],<br />

[0, 2, 0, 0],<br />

[0, 0, 0, 0],<br />

[0, 0, 0, 1]])<br />

Methods<br />

SciPy Reference Guide, Release 0.8.dev<br />

asformat(format) Return this matrix in a given sparse format<br />

asfptype() Upcast matrix to a floating point format (if necessary)<br />

astype(t)<br />

conj()<br />

conjugate()<br />

copy()<br />

diagonal() Returns the main diagonal of the matrix<br />

dot(*args, **kwds) dot is deprecated!<br />

getH()<br />

get_shape()<br />

getcol(j) Returns a copy of column j of the matrix, as an (m x 1) sparse<br />

getdata(*args, **kwds) getdata is deprecated!<br />

getformat()<br />

getmaxprint()<br />

getnnz()<br />

getrow(i) Returns a copy of row i of the matrix, as a (1 x n) sparse<br />

listprint(*args, **kwds) listprint is deprecated!<br />

matmat(*args, **kwds) matmat is deprecated!<br />

matvec(*args, **kwds) matvec is deprecated!<br />

mean([axis]) Average the matrix over the given axis.<br />

multiply(other) Point-wise multiplication by another matrix<br />

nonzero() nonzero indices<br />

reshape(shape)<br />

rmatvec(*args, **kwds) rmatvec is deprecated!<br />

rowcol(*args, **kwds) rowcol is deprecated!<br />

save(file_name[, format])<br />

set_shape(shape)<br />

setdiag(values[, k]) Fills the diagonal elements {a_ii} with the values from the given sequence.<br />

Continued on next page<br />

3.14. Sparse matrices (<strong>scipy</strong>.sparse) 377

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

Saved successfully!

Ooh no, something went wrong!