Warning
This documentation is work-in-progress and unorganized.
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
matvec : callable f(v)
|
---|
See also
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 )
>>> A
<2x2 LinearOperator with unspecified dtype>
>>> A.matvec( ones(2) )
array([ 2., 3.])
>>> A * ones(2)
array([ 2., 3.])
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}
|
---|---|
Returns: | Y : {matrix, ndarray}
|
Notes
This matmat wraps any user-specified matmat routine to ensure that y has the correct type.
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}
|
---|---|
Returns: | y : {matrix, ndarray}
|
Notes
This matvec wraps the user-specified matvec routine to ensure that y has the correct shape and type.
Nose test runner.
Usage: NoseTester(<package>).test()
<package> is package path or module Default for package is None. A value of None finds the calling module path.
This class is made available as numpy.testing.Tester, and a test function is typically added to a package’s __init__.py like so:
>>> from numpy.testing import Tester
>>> test = Tester().test
Calling this test function finds and runs all tests associated with the package and all its subpackages.
Run benchmarks for module using nose
Parameters: | label : {‘fast’, ‘full’, ‘’, attribute identifer}
verbose : integer
extra_argv : list
|
---|
Run tests for module using nose
%(test_header)s doctests : boolean
If True, run doctests in module, default False
If True, report coverage of NumPy code, default False (Requires the coverage module:
http://nedbatchelder.com/code/modules/coverage.html)
Run tests for module using nose
Parameters: | label : {‘fast’, ‘full’, ‘’, attribute identifer}
verbose : integer
extra_argv : list
doctests : boolean
coverage : boolean
|
---|
Return A as a LinearOperator.
See the LinearOperator documentation for additonal information.
Examples
>>> from scipy import matrix
>>> M = matrix( [[1,2,3],[4,5,6]], dtype='int32' )
>>> aslinearoperator( M )
<2x3 LinearOperator with dtype=int32>
Use BIConjugate Gradient iteration to solve A x = b
Parameters: | A : {sparse matrix, dense matrix, LinearOperator}
b : {array, matrix}
|
---|
Use BIConjugate Gradient STABilized iteration to solve A x = b
Parameters: | A : {sparse matrix, dense matrix, LinearOperator}
b : {array, matrix}
|
---|
Use Conjugate Gradient iteration to solve A x = b
Parameters: | A : {sparse matrix, dense matrix, LinearOperator}
b : {array, matrix}
|
---|
Use Conjugate Gradient Squared iteration to solve A x = b
Parameters: | A : {sparse matrix, dense matrix, LinearOperator}
b : {array, matrix}
|
---|
Return a fuction for solving a sparse linear system, with A pre-factorized.
Use Generalized Minimal RESidual iteration to solve A x = b
Parameters: | A : {sparse matrix, dense matrix, LinearOperator}
b : {array, matrix}
|
---|
See also
Solve symmetric partial eigenproblems with optional preconditioning
This function implements the Locally Optimal Block Preconditioned Conjugate Gradient Method (LOBPCG).
Parameters: | A : {sparse matrix, dense matrix, LinearOperator}
X : array_like
|
---|---|
Returns: | w : array
v : array
|
Notes
If both retLambdaHistory and retResidualNormsHistory are True, the return tuple has the following format (lambda, V, lambda history, residual norms history)
Use MINimum RESidual iteration to solve Ax=b
MINRES minimizes norm(A*x - b) for the symmetric matrix A. Unlike the Conjugate Gradient method, A can be indefinite or singular.
If shift != 0 then the method solves (A - shift*I)x = b
Parameters: | A : {sparse matrix, dense matrix, LinearOperator}
b : {array, matrix}
|
---|
Notes
THIS FUNCTION IS EXPERIMENTAL AND SUBJECT TO CHANGE!
References
Use Quasi-Minimal Residual iteration to solve A x = b
Parameters: | A : {sparse matrix, dense matrix, LinearOperator}
b : {array, matrix}
|
---|
See also
A linear solver, for a sparse, square matrix A, using LU decomposition where L is a lower triangular matrix and U is an upper triagular matrix.
Returns a factored_lu object. (scipy.sparse.linalg.dsolve._superlu.SciPyLUType)
See scipy.sparse.linalg.dsolve._superlu.dgstrf for more info.
The default sparse solver is umfpack when available. This can be changed by passing useUmfpack = False, which then causes the always present SuperLU based solver to be used.
Umfpack requires a CSR/CSC matrix to have sorted column/row indices. If sure that the matrix fulfills this, pass assumeSortedIndices=True to gain some speed.