as_scipy_operator
- odl.as_scipy_operator(op)
Wrap
opas ascipy.sparse.linalg.LinearOperator.This is intended to be used with the scipy sparse linear solvers.
Parameters
- op
Operator A linear operator that should be wrapped
Returns
scipy.sparse.linalg.LinearOperatorlinear_opThe wrapped operator, has attributes
matvecwhich callsop, andrmatvecwhich callsop.adjoint.
Examples
Wrap operator and solve simple problem (here toy problem
Ix = b)>>> op = odl.IdentityOperator(odl.rn(3)) >>> scipy_op = as_scipy_operator(op) >>> import scipy.sparse.linalg as scipy_solvers >>> result, status = scipy_solvers.cg(scipy_op, [0, 1, 0]) >>> result array([ 0., 1., 0.])
Notes
If the data representation of
op’s domain and range is of typeNumpyTensorSpacethis incurs no significant overhead. If the space type isCudaFnor some other nonlocal type, the overhead is significant.- op