{ } Raw JSON

bundles / scipy 1.18.0 / scipy / sparse / linalg / _interface / aslinearoperator

function

scipy.sparse.linalg._interface:aslinearoperator

source: /scipy/sparse/linalg/_interface.py:1165

Signature

def aslinearoperator(A)

Summary

Return A as a LinearOperator.

Extended Summary

See the LinearOperator documentation for additional information.

Parameters

A : object

Object to convert to a LinearOperator. May be any one of the following types:

Returns

B : LinearOperator

A LinearOperator corresponding with A

Notes

If A has no .dtype attribute, the data type is determined by calling LinearOperator.matvec() - set the .dtype attribute to prevent this call upon the linear operator creation.

Array API Standard Support

aslinearoperator has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

====================  ====================  ====================
Library               CPU                   GPU
====================  ====================  ====================
NumPy                 ✅                     n/a                 
CuPy                  n/a                   ✅                   
PyTorch               ✅                     ✅                   
JAX                   ✅                     ✅                   
Dask                  ✅                     n/a                 
====================  ====================  ====================

See dev-arrayapi for more information.

Examples

import numpy as np
from scipy.sparse.linalg import aslinearoperator
M = np.array([[1,2,3],[4,5,6]], dtype=np.int32)
aslinearoperator(M)
✓
<2x3 MatrixLinearOperator with dtype=int32>

Aliases

  • scipy.sparse.linalg.aslinearoperator

Referenced by