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.

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

3.15.1 Sparse Linear Algebra<br />

The submodules of sparse.linalg:<br />

1. eigen: sparse eigenvalue problem solvers<br />

2. isolve: iterative methods for solving linear systems<br />

3. dsolve: direct factorization methods for solving linear systems<br />

3.15.2 Examples<br />

class LinearOperator(shape, matvec, rmatvec=None, matmat=None, dtype=None)<br />

Common interface for performing matrix vector products<br />

Many iterative methods (e.g. cg, gmres) do not need to know the individual entries of a matrix to solve a linear<br />

system A*x=b. Such solvers only require the computation of matrix vector products, A*v where v is a dense<br />

vector. This class serves as an abstract interface between iterative solvers and matrix-like objects.<br />

See Also:<br />

Parameters<br />

shape : tuple<br />

Matrix dimensions (M,N)<br />

matvec : callable f(v)<br />

Returns returns A * v.<br />

aslinearoperator<br />

Construct LinearOperators<br />

Notes<br />

The user-defined matvec() function must properly handle the case where v has shape (N,) as well as the (N,1)<br />

case. The shape of the return type is handled internally by LinearOperator.<br />

Examples<br />

>>> from <strong>scipy</strong>.sparse.linalg import LinearOperator<br />

>>> from <strong>scipy</strong> import *<br />

>>> def mv(v):<br />

... return array([ 2*v[0], 3*v[1]])<br />

...<br />

>>> A = LinearOperator( (2,2), matvec=mv )<br />

>>> A<br />

<br />

>>> A.matvec( ones(2) )<br />

array([ 2., 3.])<br />

>>> A * ones(2)<br />

array([ 2., 3.])<br />

Methods<br />

matmat(X) Matrix-matrix multiplication<br />

matvec(x) Matrix-vector multiplication<br />

392 Chapter 3. Reference

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

Saved successfully!

Ooh no, something went wrong!