+
    nDj                        R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIH	t
 ^ RIHtHtHtHtHtHtHtHtHtHt ^ RIHt ^ RIHtHtHtHt RR.t]! 4        ! R	 R4      4       t ! R
 R]4      t ! R R]4      t  ! R R]4      t!R R lt" ! R R]4      t# ! R R]4      t$ ! R R]4      t% ! R R]4      t& ! R R]4      t' ! R R]'4      t( ! R R]4      t)]! 4       R 4       t*R# )!aU  Abstract linear algebra library.

This module defines a class hierarchy that implements a kind of "lazy"
matrix representation, called the ``LinearOperator``. It can be used to do
linear algebra with extremely large sparse or structured matrices, without
representing those explicitly in memory. Such matrices can be added,
multiplied, transposed, etc.

As a motivating example, suppose you want have a matrix where almost all of
the elements have the value one. The standard sparse matrix representation
skips the storage of zeros, but not ones. By contrast, a LinearOperator is
able to represent such matrices efficiently. First, we need a compact way to
represent an all-ones matrix::

    >>> import numpy as np
    >>> from scipy.sparse.linalg._interface import LinearOperator
    >>> class Ones(LinearOperator):
    ...     def __init__(self, shape):
    ...         super().__init__(dtype=None, shape=shape)
    ...     def _matvec(self, x):
    ...         return np.repeat(x.sum(), self.shape[0])

Instances of this class emulate ``np.ones(shape)``, but using a constant
amount of storage, independent of ``shape``. The ``_matvec`` method specifies
how this linear operator multiplies with (operates on) a vector. We can now
add this operator to a sparse matrix that stores only offsets from one::

    >>> from scipy.sparse.linalg._interface import aslinearoperator
    >>> from scipy.sparse import csr_array
    >>> offsets = csr_array([[1, 0, 2], [0, -1, 0], [0, 0, 3]])
    >>> A = aslinearoperator(offsets) + Ones(offsets.shape)
    >>> A.dot([1, 2, 3])
    array([13,  4, 15])

The result is the same as that given by its dense, explicitly-stored
counterpart::

    >>> (np.ones(A.shape, A.dtype) + offsets.toarray()).dot([1, 2, 3])
    array([13,  4, 15])

Several algorithms in the ``scipy.sparse`` library are able to operate on
``LinearOperator`` instances.
N)sparse)array_api_extra)
SCIPY_ARRAY_API_asarrayarray_namespaceis_array_api_objis_pydata_sparse_array	np_compatxp_capabilitiesxp_copyxp_isscalarxp_result_type)issparse)asmatrixis_pydata_spmatrix	isintlikeisshapeLinearOperatoraslinearoperatorc                   n  a a ] tR t^Gt oRtRt]! ]P                  4      t	V 3R lt
R*R ltR tR tR tR tR	 tR+V3R
 lR lltR tR tR tR+V3R lR lltR tR tR tR tR tR tR tR tR tR tR t R t!R t"R t#R t$R  t%R! t&R" t'](R# 4       t)R$ t*](R% 4       t+R& t,R' t-V3R( lt.R)t/Vt0V ;t1# ),r   a  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.

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, optionally with additional batch dimensions at the front)
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.

The defined operator may have additional "batch" dimensions
prepended to the core shape, to represent a batch of 2-D operators;
see :ref:`linalg_batch` for details.

Parameters
----------
shape : tuple
    Matrix dimensions ``(..., M, N)``,
    where ``...`` represents any additional batch dimensions.
matvec : callable f(v)
    Applies ``A`` to ``v``, where ``v`` is a dense vector
    with shape ``(..., N)``.
rmatvec : callable f(v)
    Applies ``A^H`` to ``v``, where ``A^H`` is the conjugate transpose of ``A``,
    and ``v`` is a dense vector of shape ``(..., M)``.
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 ``A^H`` is the conjugate transpose of ``A``,
    and where ``V`` is a dense matrix with dimensions ``(..., M, K)``.
dtype : dtype
    Data type of the matrix or matrices.
xp : array_namespace, optional
    A namespace compatible with the array API standard for use in array operations.
    Default: ``numpy``.

Attributes
----------
args : tuple
    For linear operators describing products etc. of other linear
    operators, the operands of the binary operation.
ndim : int
    Number of dimensions (greater than 2 in the case of batch dimensions).
T : LinearOperator
    Transpose.
H : LinearOperator
    Hermitian adjoint.

Methods
-------
matvec
matmat
adjoint
transpose
rmatvec
rmatmat
dot
rdot
__mul__
__matmul__
__call__
__add__
__truediv__
__rmul__
__rmatmul__

See Also
--------
aslinearoperator : Construct a `LinearOperator`.

Notes
-----
The user-defined `matvec` function must properly handle the case
where ``v`` has shape ``(..., N)``.

It is highly recommended to explicitly specify the `dtype`, otherwise
it is determined automatically at the cost of a single matvec application
on ``int8`` zero vector using the promoted `dtype` of the output.
It is assumed that `matmat`, `rmatvec`, and `rmatmat` would result in
the same dtype of the output given an ``int8`` input as `matvec`.

`LinearOperator` instances can also be multiplied, added with each
other, and raised to integral powers, 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 <https://pylops.readthedocs.io>`_.

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=int8>
>>> A.matvec(np.ones(2))
array([ 2.,  3.])
>>> A @ np.ones(2)
array([ 2.,  3.])

Nc                :  < V \         J d   \        SV `	  \        4      # \        SV `	  V 4      p\	        V4      P
                  \         P
                  8X  dF   \	        V4      P                  \         P                  8X  d   \        P                  ! R \        ^R7       V# )zMLinearOperator subclass should implement at least one of _matvec and _matmat.)category
stacklevel)
r   super__new___CustomLinearOperatortype_matvec_matmatwarningswarnRuntimeWarning)clsargskwargsobj	__class__s   &*, X/data/cameron/venvs/s3viz/lib/python3.14/site-packages/scipy/sparse/linalg/_interface.pyr   LinearOperator.__new__   sy    . 7?#899'/#&C S	!!^%;%;;I%%)?)??<+ 	 J    c                >   Vf   \         MTpVe   VP                  ^ VR7      P                  p\        V4      p\	        V4      ^8  d   \        RV: R24      h\        VRR7      '       g   \        RV: 24      hWn        W n        \	        V4      V n        W0n	        R# )zInitialize this LinearOperator.

To be called by subclasses. ``dtype`` may be None; ``shape`` should
be convertible to a length >=2 tuple.
Ndtypezinvalid shape z (must be at least 2-d)F)check_nd)
r	   emptyr,   tuplelen
ValueErrorr   shapendim_xp)selfr,   r2   xps   &&&&r'   __init__LinearOperator.__init__   s     *Y"HHQeH,22Eeu:>~eY6MNOOuu--~eY788

J	r)   c                p    V P                   P                  4       pVR ,          P                  ^ 4      VR &   V# )r4   )__dict__copyr.   r5   states   & r'   __getstate__LinearOperator.__getstate__   s1    ""$U|))!,er)   c                z    \        VP                  R 4      4      V n        V P                  P	                  V4       R# )r4   N)r   popr4   r:   updater<   s   &&r'   __setstate__LinearOperator.__setstate__   s)    "599U#34U#r)   c                r   V P                   fo   V P                  pVP                  V P                  R,          VP                  R7      p VP                  V P                  V4      4      pVP                   V n         R# R#   \        \        \        3 d"    \        P                  ! TRR7      T n          R# i ; i)a  Determine the dtype by executing `matvec` on an `int8` test vector.

In `np.promote_types` hierarchy, the type `int8` is the smallest,
so we call `matvec` on `int8` and use the promoted dtype of the output
to set the default `dtype` of the `LinearOperator`.
We assume that `matmat`, `rmatvec`, and `rmatmat` would result in
the same dtype of the output given an `int8` input as `matvec`.

Called from subclasses at the end of the __init__ routine.
Nr+   integral)r6   kind)r,   r4   zerosr2   int8asarraymatvecOverflowError	TypeErrorRuntimeErrorxpxdefault_dtype)r5   r6   vmatvec_vs   &   r'   _init_dtypeLinearOperator._init_dtype  s     ::BBrww7A,::dkk!n5 &^^
 
 "9l; G ..":F
Gs   
 A? ?3B65B6c                   V P                   pTP                  \        VP                  R,          4       Uu. uF  q0P	                  VRRV3,          4      NK  	  upRR7      # u upi )aQ  Default matrix-matrix multiplication handler.

If ``self`` is a linear operator of shape ``(..., M, N)``,
then this method will be called on a shape ``(..., N, K)`` array,
and should return a shape ``(..., M, K)`` array.

Falls back to `_matvec`, so defining that will
define matrix multiplication too (though in a very suboptimal way).
.NNNaxisrH   )r4   stackranger2   r   r5   Xr6   is   ""  r'   r   LinearOperator._matmat  s\     XX xx16qwwr{1CD1CA\\!CAI,'1CD2  
 	
Ds   #A"c                p    V P                   pV P                  VRVP                  3,          4      R,          # )a4  Default matrix-vector multiplication handler.

If ``self`` is a linear operator of shape ``(..., M, N)``,
then this method will be called on a shape
``(..., N)`` array,
and should return a shape ``(..., M)`` array.

Falls back to `_matmat`, so defining that
will define matrix-vector multiplication as well.
..    )r4   r   newaxisr5   xr6   s   && r'   r   LinearOperator._matvec*  s.     XX||Ac2::o./77r)   c                    < V ^8  d   QhRS[ /#    adjointbool)format__classdict__s   "r'   __annotate__LinearOperator.__annotate__8  s     1 1 1r)   c                r   V P                   p\        VR VR7      pV P                  Ev rEpV'       d   WV3MWe3w  rx\        V\        P
                  4      '       d[   V'       d   V P                  V4      MV P                  V4      p	VP                  V^38X  d   V	P                  V^4      p	\        V	4      # Rp
RpVP                  V^38H  ;p'       dw   V'       d   RMRpV'       d   RMRpRV RV R	V R
2p\        P                  ! V\        \        P                  P                  \         4      3R7       VP                  W34      pM>VP"                  ^8  d.   VP                  R,          V8H  ;p'       d   VP                  RR p
V'       g)   V'       g!   RV RV RVP                   2p\%        V4      hV'       d   V P                  V4      MV P                  V4      p	\&        P(                  ! WJ4      pV'       d   VP                  V	. VOVN54      p	V	# V'       d   VP                  V	. VOVN^N54      p	V	# )Tsubokr6   Fz	`rmatvec`z`matvec`z	`rmatmat`z`matmat`zCalling z  on 'column vectors' of shape `(za, 1)` was deprecated in SciPy 1.18.0 and will no longer be possible in SciPy 1.20.0. Please call z! instead for identical behaviour.)skip_file_prefixesNz6Dimension mismatch: `x` must have a shape ending in `(z,)`, or shape `(z, 1)`. Given shape:  rH   )r4   r   r2   
isinstancenpmatrix_rmatvecr   reshaper   r   r    FutureWarningospathdirname__file__r3   r1   rP   broadcast_shapes)r5   re   rj   r6   self_broadcast_dimsMN	inner_dim	outer_dimyx_broadcast_dims
row_vectorcolumn_vector	func_namematmat_func_namemsgbroadcasted_dimss   &&&              r'   _shared_matvecLinearOperator._shared_matvec8  s   XXQdr*%)ZZ"	)0vqf	 a##$+a aAww9a.(IIi+A;,. 
GG	1~55=5'.JI.5{:9+ &K  /00QS  MM]8Q7S 

1l+AVVq[AGGBK9,DDjD wws|mK/	{ ;  !y* 
 S/! 'DMM!T\\!_//0CV

1< 0<)<=A  

1? 0?)?Q?@Ar)   c                $    V P                  V4      # )a'  Matrix-vector multiplication.

Applies ``A`` to `x`, where ``A`` is an ``M`` x ``N``
linear operator (or batch of linear operators)
and `x` is a row vector (or batch of such vectors).

Parameters
----------
x : {matrix, ndarray}
    An array with shape ``(..., N)`` representing a row vector
    (or batch of row vectors).

    .. versionadded:: 1.18.0
        A ``FutureWarning`` is emitted for column vector input of shape
        ``(N, 1)``, for which an array with shape ``(M, 1)`` is returned.
        `matmat` can be called instead for identical behaviour on such input.

Returns
-------
y : {matrix, ndarray}
    An array with shape ``(..., M)``.

Notes
-----
This method wraps the user-specified ``matvec`` routine or overridden
``_matvec`` method to ensure that `y` has the correct shape and type.
r   r5   re   s   &&r'   rL   LinearOperator.matveck  s    8 ""1%%r)   c                (    V P                  VRR7      # )a|  Adjoint matrix-vector multiplication.

Applies ``A^H`` to `x`, where ``A`` is an
``M`` x ``N`` linear operator (or batch of linear operators)
and `x` is a row vector (or batch of such vectors).

Parameters
----------
x : {matrix, ndarray}
    An array with shape ``(..., M)`` representing a row vector
    (or batch of row vectors),
    or an array with shape ``(M, 1)`` representing a column vector.

    .. versionadded:: 1.18.0
        A ``FutureWarning`` is now emitted for column vector input of shape
        ``(M, 1)``, for which an array with shape ``(N, 1)`` is returned.
        `rmatmat` can be called instead for identical behaviour on such input.

Returns
-------
y : {matrix, ndarray}
    An array with shape ``(..., N)``.

Notes
-----
This method wraps the user-specified ``rmatvec`` routine or overridden
``_rmatvec`` method to ensure that `y` has the correct shape and type.
Trj   r   r   s   &&r'   rmatvecLinearOperator.rmatvec  s    : ""1d"33r)   c                v   \        V 4      P                  \        P                  8X  dx   \        V R4      '       d`   \        V 4      P                  \        P                  8w  d8   V P
                  pV P	                  VRVP                  3,          4      R,          # \        hV P                  P                  V4      # )zHDefault implementation of `_rmatvec`.
Defers to `_rmatmat` or `adjoint`._rmatmat.ra   )
r   _adjointr   hasattrr   r4   rc   NotImplementedErrorHr   rd   s   && r'   ry   LinearOperator._rmatvec  s     :."9"99 j))J''>+B+BBXX}}QsBJJ%78@@%%66>>!$$r)   c                    < V ^8  d   QhRS[ /# rh   rk   )rm   rn   s   "r'   ro   rp     s       r)   c                   \        V4      '       g*   \        V4      '       g   \        VR V P                  R7      pVP                  ^8  d   \        RVP                   R24      hVP                  R,          V'       d   V P                  R,          MV P                  R	,          8w  d&   \        RV P                   RVP                   24      h V'       d   V P                  V4      MV P                  V4      p\        T\        P                  4      '       d   \        T4      pT#   \         d5   p\        T4      '       g   \        T4      '       d   \        R4      Thh Rp?ii ; i)
Trr   z-Expected at least 2-d ndarray or matrix, not z-dzDimension mismatch: z, zMultipliying LinearOperator with a sparse matrix failed. Try wrapping the matrix with `aslinearoperator` first, or ensuring the operator's `matmat` function supports sparse input.NrH   )r   r   r   r4   r3   r1   r2   r   r   	ExceptionrN   rv   rw   rx   r   )r5   r]   rj   Yes   &&&  r'   _shared_matmatLinearOperator._shared_matmat  s   1!44$4884A66A:LQVVHTVWXX772;W4::b>$**R.I3DJJ<r!''KLL
	$+a aA a##A  	{{033.
  	s   D& "D& &E%1/E  E%c                $    V P                  V4      # )aI  Matrix-matrix multiplication.

Performs the operation ``A @ X`` where ``A`` is an ``M`` x ``N``
linear operator (or batch of linear operators)
and `X` is a dense ``N`` x ``K`` matrix
(or batch of dense matrices).

Parameters
----------
X : {matrix, ndarray}
    An array with shape ``(..., N, K)`` representing the dense matrix
    (or batch of dense matrices).

Returns
-------
Y : {matrix, ndarray}
    An array with shape ``(..., M, K)``.

Notes
-----
This method wraps any user-specified ``matmat`` routine or overridden
``_matmat`` method to ensure that `Y` has the correct type.
r   r5   r]   s   &&r'   matmatLinearOperator.matmat  s    0 ""1%%r)   c                (    V P                  VRR7      # )a  Adjoint matrix-matrix multiplication.

Performs the operation ``A^H @ X`` where ``A`` is an ``M`` x ``N``
linear operator (or batch of linear operators)
and `X` is a dense ``M`` x ``K`` matrix
(or batch of dense matrices).
The default implementation defers to the adjoint.

Parameters
----------
X : {matrix, ndarray}
    An array with shape ``(..., M, K)`` representing the dense matrix
    (or batch of dense matrices).

Returns
-------
Y : {matrix, ndarray}
    An array with shape ``(..., N, K)``.

Notes
-----
This method wraps any user-specified ``rmatmat`` routine or overridden
``_rmatmat`` method to ensure that `Y` has the correct type.

Tr   r   r   s   &&r'   rmatmatLinearOperator.rmatmat  s    4 ""1d"33r)   c               T   \        V 4      P                  \        P                  8X  db   V P                  pTP	                  \        VP                  R,          4       Uu. uF  q0P                  VRRV3,          4      NK  	  upRR7      # V P                  P                  V4      # u upi )zGDefault implementation of `_rmatmat`; defers to `rmatvec` or `adjoint`..rW   rX   rH   )
r   r   r   r4   rZ   r[   r2   ry   r   r   r\   s   ""  r'   r   LinearOperator._rmatmat	  s    :."9"99B 886;AGGBK6HI6Hqa|,6HIPR    66>>!$$ Js   #B%c                    W,          # )z9Apply this linear operator.

Equivalent to `__matmul__`.
ru   r   s   &&r'   __call__LinearOperator.__call__  s    
 xr)   c                $    V P                  V4      # )zBMultiplication.

Used by the ``*`` operator. Equivalent to `dot`.
)dotr   s   &&r'   __mul__LinearOperator.__mul__  s    
 xx{r)   c                x    \        V4      '       g   \        R4      h\        V RV,          V P                  R7      # )z;Scalar Division.

Returns a lazily scaled linear operator.
z.Can only divide a linear operator by a scalar.g      ?r6   )r   r1   _ScaledLinearOperatorr4   r5   others   &&r'   __truediv__LinearOperator.__truediv__$  s2    
 5!!MNN$T3;488DDr)   c                    \        VR R4      pVf'   \        WP                  P                  ^ 4      RR7      pW P                  8w  d   RV P                   RV 2p\	        V4      hR# )r4   NT)	sparse_okz2Mismatched array namespaces.Namespace for self is z, namespace for x is )getattrr   r4   r.   rN   )r5   re   xp_xr   s   &&  r'   _check_matching_namespace(LinearOperator._check_matching_namespace.  si    q%&<"1hhnnQ&74HD88))-
2GvO  C.  r)   c                   V P                  V4       \        V\        4      '       d   \        WV P                  R7      # \        V4      '       d   \        WV P                  R7      # \        V4      '       g-   \        V4      '       g   V P                  P                  V4      pV P                  R,          pVP                  V38H  pVP                  ^8  ;'       d    VP                  R,          V8H  pV'       g)   V'       g!   RV RV RVP                   2p\        V4      hV'       d   V P                  V4      # V'       d   V P                  V4      # R# )ax  Multi-purpose multiplication method.

Parameters
----------
x : array_like or `LinearOperator` or scalar
    Array-like input will be interpreted as a 1-D row vector or
    2-D matrix (or batch of matrices)
    depending on its shape. See the Returns section for details.

Returns
-------
Ax : array or `LinearOperator`
    - For `LinearOperator` input, operator composition is performed.

    - For scalar input, a lazily scaled operator is returned.

    - Otherwise, the input is expected to take the form of a dense
      1-D vector or 2-D matrix (or batch of matrices),
      interpreted as follows
      (where ``self`` is an ``M`` by ``N`` linear operator):

      - If `x` has shape ``(N,)``
        it is interpreted as a row vector
        and `matvec` is called.
      - If `x` has shape ``(..., N, K)`` for some
        integer ``K``, it is interpreted as a matrix
        (or batch of matrices if there are batch dimensions)
        and `matmat` is called.

See Also
--------
__mul__ : Equivalent method used by the ``*`` operator.
__matmul__ :
    Method used by the ``@`` operator which rejects scalar
    input before calling this method.

Notes
-----
To perform matrix-vector multiplication on batches of vectors,
use `matvec`.

For clarity, it is recommended to use the `matvec` or
`matmat` methods directly instead of this method
when interacting with dense vectors and matrices.

r   z6Dimension mismatch: array input `x` must have shape `(z,)` or a shape ending in `(z), K)` for some integer `K`. Given shape: NrH   r   )r   rv   r   _ProductLinearOperatorr4   r   r   r   r   rK   r2   r3   r1   rL   r   )r5   re   r   vectorrx   r   s   &&    r'   r   LinearOperator.dot9  s   ^ 	&&q)a(()$dhh??^^(TXX>>A;;'9!'<'< HH$$Q'

2A WW_FVVq[55QWWR[A%5FfLQC P../S 1$$%GG9. 
 !o%{{1~%{{1~% r)   c                \    \        V4      '       d   \        R4      hV P                  V4      # )zjMatrix Multiplication.

Used by the ``@`` operator.
Rejects scalar input.
Otherwise, equivalent to `dot`.
0Scalar operands are not allowed, use '*' instead)r   r1   r   r   s   &&r'   
__matmul__LinearOperator.__matmul__  s*     uOPP||E""r)   c                \    \        V4      '       d   \        R4      hV P                  V4      # )zMatrix Multiplication from the right.

Used by the ``@`` operator from the right.
Rejects scalar input.
Otherwise, equivalent to `rdot`.
r   )r   r1   __rmul__r   s   &&r'   __rmatmul__LinearOperator.__rmatmul__  s*     uOPP}}U##r)   c                $    V P                  V4      # )zaMultiplication from the right.

Used by the ``*`` operator from the right. Equivalent to `rdot`.
)rdotr   s   &&r'   r   LinearOperator.__rmul__  s    
 yy|r)   c                  a  S P                  V4       \        V\        4      '       d   \        VS S P                  R7      # \        V4      '       d   \        S VS P                  R7      # \        V4      '       g-   \        V4      '       g   S P                  P                  V4      pS P                  R,          pVP                  V38H  pVP                  ^8  ;'       d    VP                  R	,          V8H  pV'       g*   V'       g"   RV RV RVP                   R2p\        V4      hV 3R lpV'       d"   S P                  P                  V! V4      4      # V'       d(   V! S P                  P                  V! V4      4      4      # R# )
a  Multi-purpose multiplication method from the right.

.. note ::

    This method returns ``x A``.
    To perform adjoint multiplication instead, use one of
    `rmatvec` or `rmatmat`, or take the adjoint first,
    like ``self.H.rdot(x)`` or ``x * self.H``.

Parameters
----------
x : array_like or `LinearOperator` or scalar
    Array-like input will be interpreted as a 1-D row vector or
    2-D matrix (or batch of matrices)
    depending on its shape. See the Returns section for details.

Returns
-------
xA : array or `LinearOperator`
    - For `LinearOperator` input, operator composition is performed.

    - For scalar input, a lazily scaled operator is returned.

    - Otherwise, the input is expected to take the form of a dense
      1-D vector or 2-D matrix (or batch of matrices),
      interpreted as follows
      (where ``self`` is an ``M`` by ``N`` linear operator):

      - If `x` has shape ``(M,)``
        it is interpreted as a row vector.
      - If `x` has shape ``(..., K, M)`` for some
        integer ``K``, it is interpreted as a matrix
        (or batch of matrices if there are batch dimensions).

See Also
--------
dot : Multi-purpose multiplication method from the left.
__rmul__ :
    Equivalent method, used by the ``*`` operator from the right.
__rmatmul__ :
    Method used by the ``@`` operator from the right
    which rejects scalar input before calling this method.
r   z*Dimension mismatch: `x` must have shape `(z,)` or a shape ending in `(K, z&)` for some integer `K`. Given shape: .c                    < V P                   ;;^ 8X  d     V # ;^8X  d     V #  ^8X  d   T P                  #  SP                  P                  T RR4      # )rb   r   rH   )r3   Tr4   moveaxis)re   r5   s   &r'   mTLinearOperator.rdot.<locals>.mT  sO    ff     ss
#xx00B;;r)   Nr   rH   )r   rv   r   r   r4   r   r   r   r   rK   r2   r3   r1   r   rL   r   )r5   re   r   r   rx   r   r   s   f&     r'   r   LinearOperator.rdot  s<   X 	&&q)a(()!Tdhh??^^(qTXX>>A;;'9!'<'< HH$$Q'

2A WW_FVVq[55QWWR[A%5Ff@ D112 4$$%GG9A/ 
 !o%
< vv}}RU++$&&--1.// r)   c                    V P                  V4       \        V4      '       d   \        WV P                  R 7      # \        # )r   )r   r   _PowerLinearOperatorr4   NotImplemented)r5   ps   &&r'   __pow__LinearOperator.__pow__  s0    &&q)q>>'DHH==!!r)   c                    V P                  V4       \        V\        4      '       d   \        WV P                  R7      # \
        # )znLinear operator addition.

The input must be a `LinearOperator`.
A lazily summed linear operator is returned.
r   )r   rv   r   _SumLinearOperatorr4   r   r   s   &&r'   __add__LinearOperator.__add__  s6     	&&q)a((%d$((;;!!r)   c                2    \        V RV P                  R7      # )   r   rH   )r   r4   r5   s   &r'   __neg__LinearOperator.__neg__  s    $T2$((;;r)   c                &    V P                  V) 4      # N)r   r   s   &&r'   __sub__LinearOperator.__sub__  s    ||QBr)   c                    V P                   f   RpMR\        V P                   4      ,           pRP                  R V P                   4       4      pRV RV P                  P
                   RV R2# )	Nzunspecified dtypezdtype=re   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir   )str).0dims   & r'   	<genexpr>*LinearOperator.__repr__.<locals>.<genexpr>  s     8ZcSZs   < z with >)r,   r   joinr2   r&   __name__)r5   dtr2   s   &  r'   __repr__LinearOperator.__repr__  sa    ::$BC

O+B8TZZ885'4>>2236"Q??r)   c                "    V P                  4       # )at  Hermitian adjoint.

Returns the Hermitian adjoint of this linear operator,
also known as the Hermitian
conjugate or Hermitian transpose. For a complex matrix, the
Hermitian adjoint is equal to the conjugate transpose.

Returns
-------
`LinearOperator`
    Hermitian adjoint of self.

See Also
--------
:attr:`~scipy.sparse.linalg.LinearOperator.H` : Equivalent attribute.
)r   r   s   &r'   rj   LinearOperator.adjoint  s    " }}r)   c                "    V P                  4       # )zfHermitian adjoint.

See Also
--------
scipy.sparse.linalg.LinearOperator.adjoint : Equivalent method.
r   r   s   &r'   r   LinearOperator.H/  s     ||~r)   c                "    V P                  4       # )zTranspose.

Returns
-------
`LinearOperator`
    Transpose of the linear operator.

See Also
--------
:attr:`~scipy.sparse.linalg.LinearOperator.T` : Equivalent attribute.
)
_transposer   s   &r'   	transposeLinearOperator.transpose9  s       r)   c                "    V P                  4       # )z`Transpose.

See Also
--------
scipy.sparse.linalg.LinearOperator.transpose : Equivalent method.
)r  r   s   &r'   r   LinearOperator.TG  s     ~~r)   c                .    \        W P                  R7      # )zaDefault implementation of `_adjoint`.
Defers to adjoint functions, e.g. `_rmatvec` for `_matvec`.r   )_AdjointLinearOperatorr4   r   s   &r'   r   LinearOperator._adjointQ  s     &dxx88r)   c                .    \        W P                  R7      # )zXDefault implementation of `_transpose`.
For `_matvec`, defers to `_rmatvec` + `np.conj`.r   )_TransposedLinearOperatorr4   r   s   &r'   r  LinearOperator._transposeV  s     )((;;r)   c                2   < V ^8  d   Qh/ S[ ;R&   S[;R&   # )ri   __class_getitem__r3   )classmethodint)rm   rn   s   "r'   ro   rp   G   s"     H #DI L IM r)   )r4   r,   r3   r2   r   )F)2r   
__module____qualname____firstlineno____doc____array_ufunc__r  typesGenericAliasr  r   r7   r>   rC   rT   r   r   r   rL   r   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rj   propertyr   r  r   r   r  __annotate_func____static_attributes____classdictcell____classcell__r&   rn   s   @@r'   r   r   G   s    |~ O &11C1C%D(*
$,*
(81 1f&<4>%  6&448%E	!L&\	#	$T0l"
"< @&  !    9
<_  r)   c                   d   a a ] tR tRt oRtR
V 3R lltV 3R ltR tR tV 3R lt	R t
R	tVtV ;t# )r   i\  z>Linear operator defined in terms of user-specified operations.c                   < \         SV `  WQV4       RV n        W n        W0n        W`n        W@n        V P                  4        R # )Nru   )r   r7   r#   "_CustomLinearOperator__matvec_impl#_CustomLinearOperator__rmatvec_impl#_CustomLinearOperator__rmatmat_impl"_CustomLinearOperator__matmat_implrT   )	r5   r2   rL   r   r   r,   r   r6   r&   s	   &&&&&&&&r'   r7   _CustomLinearOperator.__init___  s?     	r*	#%%#r)   c                `   < V P                   e   V P                  V4      # \        SV `	  V4      # r   )r$  r   r   r5   r]   r&   s   &&r'   r   _CustomLinearOperator._matmatt  s/    )%%a((7?1%%r)   c                $    V P                  V4      # r   )r!  r   s   &&r'   r   _CustomLinearOperator._matvecz  s    !!!$$r)   c                Z    V P                   pVf   \        R4      hV P                  V4      # )Nzrmatvec is not defined)r"  r   )r5   re   funcs   && r'   ry   _CustomLinearOperator._rmatvec}  s/    ""<%&>??""1%%r)   c                `   < V P                   e   V P                  V4      # \        SV `	  V4      # r   )r#  r   r   r'  s   &&r'   r   _CustomLinearOperator._rmatmat  s0    *&&q))7#A&&r)   c           
     
   \        . V P                  R R OV P                  R,          NV P                  R,          N5V P                  V P                  V P                  V P
                  V P                  V P                  R7      # )N)r2   rL   r   r   r   r,   r6   r   rH   )r   r2   r"  r!  r#  r$  r,   r4   r   s   &r'   r   _CustomLinearOperator._adjoint  sm    $DDJJsODTZZ^DTZZ^D&&&&&&&&**xx
 	
r)   )__matmat_impl__matvec_impl__rmatmat_impl__rmatvec_implr#   )NNNNN)r   r  r  r  r  r7   r   r   ry   r   r   r  r  r  r  s   @@r'   r   r   \  s+     H*&%&'	
 	
r)   r   c                   R   a a ] tR tRt oRtR	V 3R lltR tR tR tR t	Rt
VtV ;t# )
r	  i  z$Adjoint of arbitrary Linear Operatorc                   < . VP                   R R OVP                   R,          NVP                   R,          N5p\        SV `	  VP                  W24       Wn        V3V n        R # Nr   rH   r2   r   r7   r,   Ar#   r5   r:  r6   r2   r&   s   &&& r'   r7   _AdjointLinearOperator.__init__  R    9!''#2,99QWWR[9%,D	r)   c                8    V P                   P                  V4      # r   )r:  ry   r   s   &&r'   r   _AdjointLinearOperator._matvec      vvq!!r)   c                8    V P                   P                  V4      # r   )r:  r   r   s   &&r'   ry   _AdjointLinearOperator._rmatvec      vv~~a  r)   c                8    V P                   P                  V4      # r   )r:  r   r   s   &&r'   r   _AdjointLinearOperator._matmat  r@  r)   c                8    V P                   P                  V4      # r   )r:  r   r   s   &&r'   r   _AdjointLinearOperator._rmatmat  rC  r)   r:  r#   r   r   r  r  r  r  r7   r   ry   r   r   r  r  r  r  s   @@r'   r	  r	    s&     ."!"! !r)   r	  c                   R   a a ] tR tRt oRtR	V 3R lltR tR tR tR t	Rt
VtV ;t# )
r  i  z*Transposition of arbitrary Linear Operatorc                   < . VP                   R R OVP                   R,          NVP                   R,          N5p\        SV `	  VP                  W24       Wn        V3V n        R # r8  r9  r;  s   &&& r'   r7   "_TransposedLinearOperator.__init__  r=  r)   c                    V P                   P                  V P                  P                  V P                   P                  V4      4      4      # r   )r4   conjr:  ry   r   s   &&r'   r   !_TransposedLinearOperator._matvec  /    xx}}TVV__TXX]]1-=>??r)   c                    V P                   P                  V P                  P                  V P                   P                  V4      4      4      # r   )r4   rN  r:  r   r   s   &&r'   ry   "_TransposedLinearOperator._rmatvec  /    xx}}TVV^^DHHMM!,<=>>r)   c                    V P                   P                  V P                  P                  V P                   P                  V4      4      4      # r   )r4   rN  r:  r   r   s   &&r'   r   !_TransposedLinearOperator._matmat  rP  r)   c                    V P                   P                  V P                  P                  V P                   P                  V4      4      4      # r   )r4   rN  r:  r   r   s   &&r'   r   "_TransposedLinearOperator._rmatmat  rS  r)   rH  r   rI  r  s   @@r'   r  r    s(     4@?@? ?r)   r  c                    Vf   \         MTpVf   . pV  F8  pVf   K	  \        VR4      '       g   K  VP                  VP                  4       K:  	  \	        VRV/ # )z;Returns the promoted dtype from input dtypes and operators.r,   r6   )r	   r   appendr,   r   )	operatorsdtypesr6   r%   s   &&& r'   
_get_dtyper\    sT    jbB~?wsG44MM#))$  6)b))r)   c                   X   a a ] tR tRt oRtR
V 3R lltR tR tR tR t	R t
R	tVtV ;t# )r   i  zRepresenting ``A + B``c                l  < \        V\        4      '       d   \        V\        4      '       g   \        R 4      hVP                  Ev rEpVP                  Ev rxp	WV3W38w  d   \        RV RV R24      h\        P
                  ! WG4      p
W3V n        \        SV `!  \        W.VR7      . V
OVNVN5V4       R# ))both operands have to be a LinearOperatorzcannot add  and : shape mismatchr   N)
rv   r   r1   r2   rP   r   r#   r   r7   r\  r5   r:  Br6   A_broadcast_dimsA_MA_NB_broadcast_dimsB_MB_Nr   r&   s   &&&&       r'   r7   _SumLinearOperator.__init__  s    !^,,Jq.4Q4QHII&'gg#	&'gg#	:##{1#U1#5EFGG//0@SF	QFr24Q6F4Q4QS4QSUVr)   c                    V P                   ^ ,          P                  V4      V P                   ^,          P                  V4      ,           # rb   r#   rL   r   s   &&r'   r   _SumLinearOperator._matvec  3    yy|""1%		!(;(;A(>>>r)   c                    V P                   ^ ,          P                  V4      V P                   ^,          P                  V4      ,           # rl  r#   r   r   s   &&r'   ry   _SumLinearOperator._rmatvec  3    yy|##A&1)=)=a)@@@r)   c                    V P                   ^ ,          P                  V4      V P                   ^,          P                  V4      ,           # rl  r#   r   r   s   &&r'   r   _SumLinearOperator._rmatmat  rs  r)   c                    V P                   ^ ,          P                  V4      V P                   ^,          P                  V4      ,           # rl  r#   r   r   s   &&r'   r   _SumLinearOperator._matmat  ro  r)   c                X    V P                   w  rVP                  VP                  ,           # r   r#   r   r5   r:  rc  s   &  r'   r   _SumLinearOperator._adjoint      yyssQSSyr)   r#   r   r   r  r  r  r  r7   r   ry   r   r   r   r  r  r  r  s   @@r'   r   r     s.      	W?AA? r)   r   c                   X   a a ] tR tRt oRtR
V 3R lltR tR tR tR t	R t
R	tVtV ;t# )r   i  zRepresenting ``A @ B``c                f  < \        V\        4      '       d   \        V\        4      '       g   \        R 4      hVP                  Ev rEpVP                  Ev rxp	Wh8w  d   \        RV RV R24      h\        P
                  ! WG4      p
\        SV `  \        W.VR7      . V
OVNV	N5V4       W3V n	        R# )r_  zcannot multiply r`  ra  r   N)
rv   r   r1   r2   rw   r   r   r7   r\  r#   rb  s   &&&&       r'   r7   _ProductLinearOperator.__init__  s    !^,,Jq.4Q4QHII&'gg#	&'gg#	:/s%s:JKLL../?RQFr24Q6F4Q4QS4QSUVF	r)   c                    V P                   ^ ,          P                  V P                   ^,          P                  V4      4      # rl  rm  r   s   &&r'   r   _ProductLinearOperator._matvec  .    yy|""499Q<#6#6q#9::r)   c                    V P                   ^,          P                  V P                   ^ ,          P                  V4      4      # r   rq  r   s   &&r'   ry   _ProductLinearOperator._rmatvec  .    yy|##DIIaL$8$8$;<<r)   c                    V P                   ^,          P                  V P                   ^ ,          P                  V4      4      # r  ru  r   s   &&r'   r   _ProductLinearOperator._rmatmat  r  r)   c                    V P                   ^ ,          P                  V P                   ^,          P                  V4      4      # rl  rx  r   s   &&r'   r   _ProductLinearOperator._matmat  r  r)   c                X    V P                   w  rVP                  VP                  ,          # r   r{  r|  s   &  r'   r   _ProductLinearOperator._adjoint  r~  r)   r  r   r  r  s   @@r'   r   r     s+      	;==; r)   r   c                   X   a a ] tR tRt oRtR
V 3R lltR tR tR tR t	R t
R	tVtV ;t# )r   i
  zRepresenting ``alpha * A``c                T  < \        V\        4      '       g   \        R 4      h\        P                  ! V4      '       g   \        R4      h\        V\
        4      '       d   VP                  w  rW$,          p\        V.V.VR7      p\        SV `%  WQP                  V4       W3V n        R# )LinearOperator expected as Azscalar expected as alphar   N)rv   r   r1   rw   isscalarr   r#   r\  r   r7   r2   )r5   r:  alphar6   alpha_originalr,   r&   s   &&&&  r'   r7   _ScaledLinearOperator.__init__  s    !^,,;<<{{5!!788a.// !A *EA3B/,J	r)   c                v    V P                   ^,          V P                   ^ ,          P                  V4      ,          # r  rm  r   s   &&r'   r   _ScaledLinearOperator._matvec  (    yy|diil11!444r)   c                    V P                   ^,          P                  4       V P                   ^ ,          P                  V4      ,          # r  )r#   	conjugater   r   s   &&r'   ry   _ScaledLinearOperator._rmatvec   1    yy|%%'$))A,*>*>q*AAAr)   c                    V P                   ^,          P                  4       V P                   ^ ,          P                  V4      ,          # r  )r#   r  r   r   s   &&r'   r   _ScaledLinearOperator._rmatmat#  r  r)   c                v    V P                   ^,          V P                   ^ ,          P                  V4      ,          # r  rx  r   s   &&r'   r   _ScaledLinearOperator._matmat&  r  r)   c                `    V P                   w  rVP                  VP                  4       ,          # r   )r#   r   r  )r5   r:  r  s   &  r'   r   _ScaledLinearOperator._adjoint)  s#    99ssU__&&&r)   r  r   r  r  s   @@r'   r   r   
  s-     $ 5BB5' 'r)   r   c                   ^   a a ] tR tRt oRtRV 3R lltR tR tR tR t	R t
R	 tR
tVtV ;t# )r   i.  zRepresenting ``A ** p``c                b  < \        V\        4      '       g   \        R 4      hVP                  R,          VP                  R,          8w  d   RV: 2p\        V4      h\	        V4      '       d   V^ 8  d   \        R4      h\
        SV `  \        V.VR7      VP                  V4       W3V n        R# )r  z7square core-dimensions of LinearOperator expected, got z"non-negative integer expected as pr   Nr   rH   )	rv   r   r1   r2   r   r   r7   r\  r#   )r5   r:  r   r6   r   r&   s   &&&& r'   r7   _PowerLinearOperator.__init__1  s    !^,,;<<772;!''"+%KA5QCS/!||q1uABBQCB/"=F	r)   c                r    \        V4      p\        V P                  ^,          4       F  pV! V4      pK  	  V# r  )r   r[   r#   )r5   funre   resr^   s   &&&  r'   _power_PowerLinearOperator._power=  s0    ajtyy|$Ac(C %
r)   c                \    V P                  V P                  ^ ,          P                  V4      # rl  )r  r#   rL   r   s   &&r'   r   _PowerLinearOperator._matvecC  !    {{499Q<..22r)   c                \    V P                  V P                  ^ ,          P                  V4      # rl  )r  r#   r   r   s   &&r'   ry   _PowerLinearOperator._rmatvecF  !    {{499Q<//33r)   c                \    V P                  V P                  ^ ,          P                  V4      # rl  )r  r#   r   r   s   &&r'   r   _PowerLinearOperator._rmatmatI  r  r)   c                \    V P                  V P                  ^ ,          P                  V4      # rl  )r  r#   r   r   s   &&r'   r   _PowerLinearOperator._matmatL  r  r)   c                D    V P                   w  rVP                  V,          # r   r{  )r5   r:  r   s   &  r'   r   _PowerLinearOperator._adjointO  s    yyssAvr)   r  r   )r   r  r  r  r  r7   r  r   ry   r   r   r   r  r  r  r  s   @@r'   r   r   .  s0     !
3443 r)   r   c                   F   a a ] tR tRt oRtRV 3R lltR tR tRtVt	V ;t
# )MatrixLinearOperatoriT  z8Operator defined by a matrix `A` which implements ``@``.c                |   < \         SV `  VP                  VP                  V4       Wn        R V n        V3V n        R # r   )r   r7   r,   r2   r:  _MatrixLinearOperator__adjr#   )r5   r:  r6   r&   s   &&&r'   r7   MatrixLinearOperator.__init__W  s1    !''2.
D	r)   c                (    V P                   V,          # r   )r:  r   s   &&r'   r   MatrixLinearOperator._matmat]  s    vvzr)   c                    V P                   f'   \        V P                  V P                  R7      V n         V P                   # )Nr   )r  _AdjointMatrixOperatorr:  r4   r   s   &r'   r   MatrixLinearOperator._adjoint`  s,    ::/488DDJzzr)   )r:  __adjr#   r   )r   r  r  r  r  r7   r   r   r  r  r  r  s   @@r'   r  r  T  s     B r)   r  c                   @   a a ] tR tRt oRtRV 3R lltR tRtVtV ;t	# )r  if  z5Representing ``A.H``, for `MatrixLinearOperator` `A`.c                  < Vf   \         MTpVP                  ^8  d8   \        V4      '       d   \        P                  ! VRR4      pMVP
                  pMVP                  p\        SV `!  VP                  V4      VR7       V3V n
        R # )Nr   rH   r   )r	   r3   r   r   swapaxesr   r   r   r7   rN  r#   )r5   r:  r6   A_Tr&   s   &&& r'   r7   _AdjointMatrixOperator.__init__i  si    *Y"66A:{{ooaR0dd##C"-D	r)   c                R    \        V P                  ^ ,          V P                  R7      # )rb   r   )r  r#   r4   r   s   &r'   r   _AdjointMatrixOperator._adjointu  s    #DIIaLTXX>>r)   r  r   )
r   r  r  r  r  r7   r   r  r  r  r  s   @@r'   r  r  f  s     ?
? ?r)   r  c                   T   a a ] tR tRt oR	V 3R lltR tR tR tR tR t	Rt
VtV ;t# )
IdentityOperatoriy  c                (   < \         SV `  W!V4       R # r   )r   r7   )r5   r2   r,   r6   r&   s   &&&&r'   r7   IdentityOperator.__init__z  s    r*r)   c                    V# r   ru   r   s   &&r'   r   IdentityOperator._matvec}      r)   c                    V# r   ru   r   s   &&r'   ry   IdentityOperator._rmatvec  r  r)   c                    V# r   ru   r   s   &&r'   r   IdentityOperator._rmatmat  r  r)   c                    V# r   ru   r   s   &&r'   r   IdentityOperator._matmat  r  r)   c                    V # r   ru   r   s   &r'   r   IdentityOperator._adjoint  s    r)   ru   NN)r   r  r  r  r7   r   ry   r   r   r   r  r  r  r  s   @@r'   r  r  y  s(     + r)   r  c                v   \        V \        4      '       d   V # \        V 4      '       do   \        V \        P                  4      '       gO   \        V 4      p\        V 4      '       d   \        '       g   M\        P                  ! V ^VR7      p \        WR7      # \        V 4      '       d   \        V 4      # \        V \        P                  4      '       d6   \        P                  ! \        P                  ! V 4      4      p \        V 4      # \        V R4      '       d   \        V R4      '       d   RpRpRp\        V R4      '       d   V P                  p\        V R4      '       d   V P                   p\        V R4      '       d   V P"                  p\        V P$                  V P&                  W#VR	7      # \)        R
4      h)a  Return `A` as a `LinearOperator`.

See the `LinearOperator` documentation for additional information.

Parameters
----------
A : object
    Object to convert to a `LinearOperator`. May be any one of the following types:

    - `numpy.ndarray`
    - `numpy.matrix`
    - `scipy.sparse` array
      (e.g. `~scipy.sparse.csr_array`, `~scipy.sparse.lil_array`, etc.)
    - `LinearOperator`
    - An object with ``.shape`` and ``.matvec`` attributes

Returns
-------
B : LinearOperator
    A `LinearOperator` corresponding with `A`

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

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>
)r3   r6   r   r2   rL   Nr   r   r,   )r   r   r,   ztype not understood)rv   r   r   rw   rx   r   r   r   rP   
atleast_ndr  r   
atleast_2drK   r   r   r   r,   r2   rL   rN   )r:  r6   r   r   r,   s   &    r'   r   r     sI   J !^$$ :a#;#;Q!!$$__qqR0A#A--{{#A&&!RYYMM"**Q-(#A&&q'wq(331i  iiG1i  iiG1gGGEGGQXXwu
 	
 )
**r)   r  )+r  r|   r  r   numpyrw   scipyr   scipy._externalr   rP   scipy._lib._array_apir   r   r   r   r   r	   r
   r   r   r   scipy.sparser   scipy.sparse._sputilsr   r   r   r   __all__r   r   r	  r  r\  r   r   r   r   r  r  r  r   ru   r)   r'   <module>r     s   *X 
     2   " R R/
0 Q< Q< Q<h6
N 6
r!^ !,? ?,* >^ >!'N !'H#> #L> $?1 ?&~ ( F+ F+r)   