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.

spdiags(data, diags, m, n, format=None)<br />

Return a sparse matrix from diagonals.<br />

See Also:<br />

Parameters<br />

data : array_like<br />

matrix diagonals stored row-wise<br />

diags : diagonals to set<br />

• k = 0 the main diagonal<br />

• k > 0 the k-th upper diagonal<br />

• k < 0 the k-th lower diagonal<br />

m, n : int<br />

shape of the result<br />

format : format of the result (e.g. “csr”)<br />

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

By default (format=None) an appropriate sparse matrix format is returned. This<br />

choice is subject to change.<br />

dia_matrix<br />

the sparse DIAgonal format.<br />

Examples<br />

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

>>> diags = array([0,-1,2])<br />

>>> spdiags(data, diags, 4, 4).todense()<br />

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

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

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

[0, 0, 3, 4]])<br />

tril(A, k=0, format=None)<br />

Return the lower triangular portion of a matrix in sparse format<br />

Returns the elements on or below the k-th diagonal of the matrix A.<br />

• k = 0 corresponds to the main diagonal<br />

• k > 0 is above the main diagonal<br />

• k < 0 is below the main diagonal<br />

Parameters<br />

A : dense or sparse matrix<br />

Matrix whose lower trianglar portion is desired.<br />

k : integer<br />

The top-most diagonal of the lower triangle.<br />

format : string<br />

Sparse format of the result, e.g. format=”csr”, etc.<br />

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

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

Saved successfully!

Ooh no, something went wrong!