Home | Trees | Indices | Help |
---|
|
object --+ | LinearOperator
Common interface for performing matrix vector products Many iterative methods (e.g. cg, gmres) do not need to know the individual entries of a matrix to solve a linear system A*x=b. Such solvers only require the computation of matrix vector products, A*v where v is a dense vector. This class serves as an abstract interface between iterative solvers and matrix-like objects. Parameters ---------- shape : tuple Matrix dimensions (M,N) matvec : callable f(v) Returns returns A * v. Optional Parameters ------------------- rmatvec : callable f(v) Returns A^H * v, where A^H is the conjugate transpose of A. matmat : callable f(V) Returns A * V, where V is a dense matrix with dimensions (N,K). rmatmat : callable f(V) Returns A^H * V, where V is a dense matrix with dimensions (N,K). dtype : dtype Data type of the matrix. See Also -------- aslinearoperator : Construct LinearOperators Notes ----- The user-defined matvec() function must properly handle the case where v has shape (N,) as well as the (N,1) case. The shape of the return type is handled internally by LinearOperator. Examples -------- >>> from scipy.sparse.linalg import LinearOperator >>> from scipy import * >>> def mv(v): ... return array([ 2*v[0], 3*v[1]]) ... >>> A = LinearOperator( (2,2), matvec=mv, rmatvec=mv) >>> A <2x2 LinearOperator with unspecified dtype> >>> A.matvec( ones(2) ) array([ 2., 3.]) >>> A * ones(2) array([ 2., 3.]) >>> A.dense() array([[ 2., 0.], [ 0., 3.]]) >>> (2 * A.T * A + 1) * ones(2) array([ 9., 19.])
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
|
|||
T | |||
Inherited from |
|
x.__init__(...) initializes x; see help(type(x)) for signature
|
Default matrix-matrix multiplication handler. Falls back on the user-defined matvec() routine, which is always provided. |
Matrix-vector multiplication Performs the operation y=A*x where A is an MxN linear operator and x is a column vector or rank-1 array. Parameters ---------- x : {matrix, ndarray} An array with shape (N,) or (N,1). Returns ------- y : {matrix, ndarray} A matrix or ndarray with shape (M,) or (M,1) depending on the type and shape of the x argument. Notes ----- This matvec wraps the user-specified matvec routine to ensure that y has the correct shape and type. |
Matrix-matrix multiplication Performs the operation y=A*X where A is an MxN linear operator and X dense N*K matrix or ndarray. Parameters ---------- X : {matrix, ndarray} An array with shape (N,K). Returns ------- Y : {matrix, ndarray} A matrix or ndarray with shape (M,K) depending on the type of the X argument. Notes ----- This matmat wraps any user-specified matmat routine to ensure that y has the correct type. |
repr(x)
|
|
T
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Jun 2 17:46:15 2011 | http://epydoc.sourceforge.net |