scipy 1.8.0 Pypi GitHub Homepage
Other Docs
AttributesNotesParametersBackRef

Attributes

args : tuple

For linear operators describing products etc. of other linear operators, the operands of the binary operation.

ndim : int

Number of dimensions (this is always 2)

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.

To construct a concrete LinearOperator, either pass appropriate callables to the constructor of this class, or subclass it.

A subclass must implement either one of the methods _matvec and _matmat , and the attributes/properties shape (pair of integers) and dtype (may be None). It may call the __init__ on this class to have these attributes validated. Implementing _matvec automatically implements _matmat (using a naive algorithm) and vice-versa.

Optionally, a subclass may implement _rmatvec or _adjoint to implement the Hermitian adjoint (conjugate transpose). As with _matvec and _matmat , implementing either _rmatvec or _adjoint implements the other automatically. Implementing _adjoint is preferable; _rmatvec is mostly there for backwards compatibility.

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.

LinearOperator instances can also be multiplied, added with each other and exponentiated, all lazily: the result of these operations is always a new, composite LinearOperator, that defers linear operations to the original operators and combines the results.

More details regarding how to subclass a LinearOperator and several examples of concrete LinearOperator instances can be found in the external project PyLops.

Parameters

shape : tuple

Matrix dimensions (M, N).

matvec : callable f(v)

Returns returns A * v.

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).

dtype : dtype

Data type of the matrix.

rmatmat : callable f(V)

Returns A^H * V, where V is a dense matrix with dimensions (M, K).

Common interface for performing matrix vector products

See Also

aslinearoperator

Construct LinearOperators

Examples

>>> import numpy as np
... from scipy.sparse.linalg import LinearOperator
... def mv(v):
...  return np.array([2*v[0], 3*v[1]]) ...
>>> A = LinearOperator((2,2), matvec=mv)
... A <2x2 _CustomLinearOperator with dtype=float64>
>>> A.matvec(np.ones(2))
array([ 2.,  3.])
>>> A * np.ones(2)
array([ 2.,  3.])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.sparse.linalg._eigen.lobpcg.lobpcg.lobpcg scipy.sparse.linalg._isolve.iterative.gmres scipy.sparse.linalg._isolve.tfqmr.tfqmr scipy.optimize._numdiff.approx_derivative scipy.sparse.linalg._isolve.iterative.qmr scipy.optimize._lbfgsb_py.LbfgsInvHessProduct.todense scipy.sparse.linalg._interface.LinearOperator

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/sparse/linalg/_interface.py#53
type: <class 'type'>
Commit: