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.

Examples<br />

Parameters<br />

n : integer<br />

dtype : :<br />

Shape of the identity matrix.<br />

Data type of the matrix<br />

format : string<br />

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

>>> identity(3).todense()<br />

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

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

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

>>> identity(3, dtype=’int8’, format=’dia’)<br />

<br />

kron(A, B, format=None)<br />

kronecker product of sparse matrices A and B<br />

Examples<br />

Parameters<br />

A : sparse or dense matrix<br />

first matrix of the product<br />

B : sparse or dense matrix<br />

second matrix of the product<br />

format : string<br />

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

Returns<br />

kronecker product in a sparse matrix format :<br />

>>> A = csr_matrix(array([[0,2],[5,0]]))<br />

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

>>> kron(A,B).todense()<br />

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

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

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

[15, 20, 0, 0]])<br />

>>> kron(A,[[1,2],[3,4]]).todense()<br />

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

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

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

[15, 20, 0, 0]])<br />

kronsum(A, B, format=None)<br />

kronecker sum of sparse matrices A and B<br />

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

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

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

Saved successfully!

Ooh no, something went wrong!