+
    /is                     N   R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHtH	t	H
t
Ht RR.t ! R R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R 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)issparse)isshape	isintlikeasmatrixis_pydata_spmatrixLinearOperatoraslinearoperatorc                   $  a a ] tR t^8t oRt^tRt]! ]P                  4      t
V 3R 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 tR tR t R t!R t"R t#]$! ]#4      t%R t&]$! ]&4      t'R t(R t)Rt*Vt+V ;t,# ) 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) 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.

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

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)

See Also
--------
aslinearoperator : Construct LinearOperators

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

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.
Python ``int`` could be difficult to automatically cast to numpy integers
in the definition of the `matvec` so the determination may be inaccurate.
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 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 <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   &*, \/var/www/html/photoedit/myenv/lib/python3.14/site-packages/scipy/sparse/linalg/_interface.pyr   LinearOperator.__new__   sx    . 7?#899'/#&CS	!!^%;%;;S	))^-C-CC F'5!E J    c                    Ve   \         P                  ! V4      p\        V4      p\        V4      '       g   \	        RV: R24      hWn        W n        R# )zInitialize this LinearOperator.

To be called by subclasses. ``dtype`` may be None; ``shape`` should
be convertible to a length-2 tuple.
Nzinvalid shape z (must be 2-d))npdtypetupler   
ValueErrorshape)selfr    r#   s   &&&r   __init__LinearOperator.__init__   sG     HHUOEeu~~~eYnEFF

r   c                d   V P                   fq   \        P                  ! V P                  R,          \        P                  R7      p \        P
                  ! V P                  V4      4      pVP                   V n         R# R#   \         d$    \        P                   ! \        4      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.
N)r    )	r    r   zerosr#   int8asarraymatvecOverflowErrorint)r$   vmatvec_vs   &  r   _init_dtypeLinearOperator._init_dtype   sw     ::Brww7A,::dkk!n5
 &^^
  ! +XXc]
+s   %B *B/.B/c                    \         P                  ! VP                   Uu. uF#  q P                  VP	                  R^4      4      NK%  	  up4      # u upi )zDefault matrix-matrix multiplication handler.

Falls back on the user-defined _matvec method, so defining that will
define matrix multiplication (though in a very suboptimal way).
r(   )r   hstackTr,   reshaper$   Xcols   && r   r   LinearOperator._matmat   s;     yyACCHCS++ckk"Q&78CHIIHs   )Ac                D    V P                  VP                  R^4      4      # )aI  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,) or (N, 1) ndarray, and should return a
shape (M,) or (M, 1) ndarray.

This default implementation falls back on _matmat, so defining that
will define matrix-vector multiplication as well.
r(   )matmatr6   r$   xs   &&r   r   LinearOperator._matvec   s     {{199R+,,r   c                   \         P                  ! V4      pV P                  w  r#VP                  V38w  d   VP                  V^38w  d   \        R4      hV P	                  V4      p\        V\         P                  4      '       d   \        V4      pM\         P                  ! V4      pVP                  ^8X  d   VP                  V4      pV# VP                  ^8X  d   VP                  V^4      pV# \        R4      h)a  Matrix-vector multiplication.

Performs the operation y=A@x where A is an MxN linear
operator and x is a column vector or 1-d array.

Parameters
----------
x : {matrix, ndarray}
    An array with shape (N,) or (N,1).

Returns
-------
y : {matrix, ndarray}
    A matrix or ndarray with shape (M,) or (M,1) depending
    on the type and shape of the x argument.

Notes
-----
This matvec wraps the user-specified matvec routine or overridden
_matvec method to ensure that y has the correct shape and type.

dimension mismatchz/invalid shape returned by user-defined matvec())r   
asanyarrayr#   r"   r   
isinstancematrixr   r+   ndimr6   r$   r>   MNys   &&   r   r,   LinearOperator.matvec   s    0 MM!jj77qd?qww1Q%/122LLOa##A

1A66Q;		!A  VVq[		!AA  NOOr   c                   \         P                  ! V4      pV P                  w  r#VP                  V38w  d   VP                  V^38w  d   \        R4      hV P	                  V4      p\        V\         P                  4      '       d   \        V4      pM\         P                  ! V4      pVP                  ^8X  d   VP                  V4      pV# VP                  ^8X  d   VP                  V^4      pV# \        R4      h)a	  Adjoint matrix-vector multiplication.

Performs the operation y = A^H @ x where A is an MxN linear
operator and x is a column vector or 1-d array.

Parameters
----------
x : {matrix, ndarray}
    An array with shape (M,) or (M,1).

Returns
-------
y : {matrix, ndarray}
    A matrix or ndarray with shape (N,) or (N,1) depending
    on the type and shape of the x argument.

Notes
-----
This rmatvec wraps the user-specified rmatvec routine or overridden
_rmatvec method to ensure that y has the correct shape and type.

rA   z0invalid shape returned by user-defined rmatvec())r   rB   r#   r"   _rmatvecrC   rD   r   r+   rE   r6   rF   s   &&   r   rmatvecLinearOperator.rmatvec  s    0 MM!jj77qd?qww1Q%/122MM!a##A

1A66Q;		!A  VVq[		!AA  OPPr   c                h   \        V 4      P                  \        P                  8X  dq   \        V R4      '       dY   \        V 4      P                  \        P                  8w  d1   V P	                  VP                  R^4      4      P                  R4      # \        hV P                  P                  V4      # )z6Default implementation of _rmatvec; defers to adjoint._rmatmatr(   )	r   _adjointr   hasattrrP   r6   NotImplementedErrorHr,   r=   s   &&r   rL   LinearOperator._rmatvecE  s}    :."9"99j))T
++~/F/FF}}QYYr1%56>>rBB%%66==##r   c                d   \        V4      '       g(   \        V4      '       g   \        P                  ! V4      pVP                  ^8w  d   \        RVP                   R24      hVP                  ^ ,          V P                  ^,          8w  d&   \        RV P                   RVP                   24      h 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)a  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}
    An array with shape (N,K).

Returns
-------
Y : {matrix, ndarray}
    A matrix or ndarray with shape (M,K) depending on
    the type of the X argument.

Notes
-----
This matmat wraps any user-specified matmat routine or overridden
_matmat method to ensure that y has the correct type.

$expected 2-d ndarray or matrix, not -ddimension mismatch: , zdUnable to multiply a LinearOperator with a sparse matrix. Wrap the matrix in aslinearoperator first.N)r   r   r   rB   rE   r"   r#   r   	Exception	TypeErrorrC   rD   r   r$   r8   Yes   &&  r   r<   LinearOperator.matmatQ  s    . 1!44a A66Q;CAFF82NOO771:A&3DJJ<r!''KLL	QA a##A  	{{033B  	   2C0 0D/;/D**D/c                d   \        V4      '       g(   \        V4      '       g   \        P                  ! V4      pVP                  ^8w  d   \        RVP                   R24      hVP                  ^ ,          V P                  ^ ,          8w  d&   \        RV P                   RVP                   24      h 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)a  Adjoint matrix-matrix multiplication.

Performs the operation y = A^H @ x where A is an MxN linear
operator and x is a column vector or 1-d array, or 2-d array.
The default implementation defers to the adjoint.

Parameters
----------
X : {matrix, ndarray}
    A matrix or 2D array.

Returns
-------
Y : {matrix, ndarray}
    A matrix or 2D array depending on the type of the input.

Notes
-----
This rmatmat wraps the user-specified rmatmat routine.

rW   rX   rY   rZ   zfUnable to multiply a LinearOperator with a sparse matrix. Wrap the matrix in aslinearoperator() first.N)r   r   r   rB   rE   r"   r#   rP   r[   r\   rC   rD   r   r]   s   &&  r   rmatmatLinearOperator.rmatmat  s    , 1!44a A66Q;CAFF82NOO771:A&3DJJ<r!''KLL	a A a##A  	{{033D  	ra   c                .   \        V 4      P                  \        P                  8X  dO   \        P                  ! VP
                   Uu. uF#  q P                  VP                  R^4      4      NK%  	  up4      # V P                  P                  V4      # u upi )z@Default implementation of _rmatmat defers to rmatvec or adjoint.r(   )
r   rQ   r   r   r4   r5   rM   r6   rT   r<   r7   s   && r   rP   LinearOperator._rmatmat  sg    :."9"9999!##N#3ll3;;r1+=>#NOO66==## Os   )Bc                    W,          # N r=   s   &&r   __call__LinearOperator.__call__  s	    vr   c                $    V P                  V4      # rh   )dotr=   s   &&r   __mul__LinearOperator.__mul__  s    xx{r   c                v    \         P                  ! V4      '       g   \        R 4      h\        V RV,          4      # )z.Can only divide a linear operator by a scalar.g      ?)r   isscalarr"   _ScaledLinearOperatorr$   others   &&r   __truediv__LinearOperator.__truediv__  s.    {{5!!MNN$T3u955r   c                   \        V\        4      '       d   \        W4      # \        P                  ! V4      '       d   \        W4      # \        V4      '       g(   \        V4      '       g   \        P                  ! V4      pVP                  ^8X  g*   VP                  ^8X  d*   VP                  ^,          ^8X  d   V P                  V4      # VP                  ^8X  d   V P                  V4      # \        RV: 24      h)a"  Matrix-matrix or matrix-vector multiplication.

Parameters
----------
x : array_like
    1-d or 2-d array, representing a vector or matrix.

Returns
-------
Ax : array
    1-d or 2-d array (depending on the shape of x) that represents
    the result of applying this linear operator on x.

)expected 1-d or 2-d array or matrix, got )rC   r   _ProductLinearOperatorr   rq   rr   r   r   r+   rE   r#   r,   r<   r"   r=   s   &&r   rm   LinearOperator.dot  s     a(()$22[[^^(11A;;'9!'<'<JJqMvv{affkaggajAo{{1~%1{{1~% #LQE!RSSr   c                r    \         P                  ! V4      '       d   \        R 4      hV P                  V4      # z0Scalar operands are not allowed, use '*' instead)r   rq   r"   rn   rs   s   &&r   
__matmul__LinearOperator.__matmul__  s2    ;;u / 0 0||E""r   c                r    \         P                  ! V4      '       d   \        R 4      hV P                  V4      # r|   )r   rq   r"   __rmul__rs   s   &&r   __rmatmul__LinearOperator.__rmatmul__  s2    ;;u / 0 0}}U##r   c                r    \         P                  ! V4      '       d   \        W4      # V P                  V4      # rh   )r   rq   rr   _rdotr=   s   &&r   r   LinearOperator.__rmul__  s(    ;;q>>(11::a= r   c                r   \        V\        4      '       d   \        W4      # \        P                  ! V4      '       d   \        W4      # \        V4      '       g(   \        V4      '       g   \        P                  ! V4      pVP                  ^8X  g*   VP                  ^8X  dH   VP                  ^ ,          ^8X  d0   V P                  P                  VP                  4      P                  # VP                  ^8X  d0   V P                  P                  VP                  4      P                  # \        RV: 24      h)a  Matrix-matrix or matrix-vector multiplication from the right.

Parameters
----------
x : array_like
    1-d or 2-d array, representing a vector or matrix.

Returns
-------
xA : array
    1-d or 2-d array (depending on the shape of x) that represents
    the result of applying this linear operator on x from the right.

Notes
-----
This is copied from dot to implement right multiplication.
rx   )rC   r   ry   r   rq   rr   r   r   r+   rE   r#   r5   r,   r<   r"   r=   s   &&r   r   LinearOperator._rdot  s    $ a(()!22[[^^(11A;;'9!'<'<JJqM vv{affkaggajAovv}}QSS)+++1vv}}QSS)+++ #LQE!RSSr   c                \    \         P                  ! V4      '       d   \        W4      # \        # rh   )r   rq   _PowerLinearOperatorNotImplemented)r$   ps   &&r   __pow__LinearOperator.__pow__  s     ;;q>>'00!!r   c                P    \        V\        4      '       d   \        W4      # \        # rh   )rC   r   _SumLinearOperatorr   r=   s   &&r   __add__LinearOperator.__add__  s     a((%d..!!r   c                    \        V R4      # )   r(   )rr   r$   s   &r   __neg__LinearOperator.__neg__!  s    $T2..r   c                &    V P                  V) 4      # rh   )r   r=   s   &&r   __sub__LinearOperator.__sub__$  s    ||QBr   c           	         V P                   w  rV P                  f   RpMR\        V P                  4      ,           pRV RV RV P                  P                   RV R2	# )Nzunspecified dtypezdtype=<r>    z with >)r#   r    strr   __name__)r$   rG   rH   dts   &   r   __repr__LinearOperator.__repr__'  sZ    jj::$BC

O+B1#Qqc4>>2236"Q??r   c                "    V P                  4       # )a;  Hermitian adjoint.

Returns the Hermitian adjoint of self, aka the Hermitian
conjugate or Hermitian transpose. For a complex matrix, the
Hermitian adjoint is equal to the conjugate transpose.

Can be abbreviated self.H instead of self.adjoint().

Returns
-------
A_H : LinearOperator
    Hermitian adjoint of self.
)rQ   r   s   &r   adjointLinearOperator.adjoint0  s     }}r   c                "    V P                  4       # )zTranspose this linear operator.

Returns a LinearOperator that represents the transpose of this one.
Can be abbreviated self.T instead of self.transpose().
)
_transposer   s   &r   	transposeLinearOperator.transposeB  s       r   c                    \        V 4      # )z6Default implementation of _adjoint; defers to rmatvec.)_AdjointLinearOperatorr   s   &r   rQ   LinearOperator._adjointL  s    %d++r   c                    \        V 4      # )z>Default implementation of _transpose; defers to rmatvec + conj)_TransposedLinearOperatorr   s   &r   r   LinearOperator._transposeP  s    (..r   r    r#   )-r   
__module____qualname____firstlineno____doc__rE   __array_ufunc__classmethodtypesGenericAlias__class_getitem__r   r%   r1   r   r   r,   rM   rL   r<   rc   rP   rj   rn   ru   rm   r}   r   r   r   r   r   r   r   r   r   propertyrT   r   r5   rQ   r   __static_attributes____classdictcell____classcell__r   __classdict__s   @@r   r   r   8   s     \| DO $E$6$67 ,*J
--^-^
$-^+Z$6T>#$!"TH""/ @  	A! 	A,/ /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   iU  z>Linear operator defined in terms of user-specified operations.c                   < \         SV `  WQ4       RV n        W n        W0n        W`n        W@n        V P                  4        R # )Nri   )r   r%   r   "_CustomLinearOperator__matvec_impl#_CustomLinearOperator__rmatvec_impl#_CustomLinearOperator__rmatmat_impl"_CustomLinearOperator__matmat_implr1   )r$   r#   r,   rM   r<   r    rc   r   s   &&&&&&&r   r%   _CustomLinearOperator.__init__X  s;    &	#%%#r   c                `   < V P                   e   V P                  V4      # \        SV `	  V4      # rh   )r   r   r   r$   r8   r   s   &&r   r   _CustomLinearOperator._matmate  s/    )%%a((7?1%%r   c                $    V P                  V4      # rh   )r   r=   s   &&r   r   _CustomLinearOperator._matveck  s    !!!$$r   c                Z    V P                   pVf   \        R4      hV P                  V4      # )Nzrmatvec is not defined)r   rS   )r$   r>   funcs   && r   rL   _CustomLinearOperator._rmatvecn  s/    ""<%&>??""1%%r   c                `   < V P                   e   V P                  V4      # \        SV `	  V4      # rh   )r   r   rP   r   s   &&r   rP   _CustomLinearOperator._rmatmatt  s0    *&&q))7#A&&r   c           	         \        V P                  ^,          V P                  ^ ,          3V P                  V P                  V P                  V P
                  V P                  R7      # )r   )r#   r,   rM   r<   rc   r    )r   r#   r   r   r   r   r    r   s   &r   rQ   _CustomLinearOperator._adjointz  sQ    $DJJqM4::a=+I,0,?,?-1-?-?,0,?,?-1-?-?+/::7 	7r   )__matmat_impl__matvec_impl__rmatmat_impl__rmatvec_implr   )NNNN)r   r   r   r   r   r%   r   r   rL   rP   rQ   r   r   r   r   s   @@r   r   r   U  s+     H&%&'7 7r   r   c                   N   a a ] tR tRt oRtV 3R 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                   ^,          VP                   ^ ,          3p\        SV `	  VP                  VR7       Wn        V3V n        R# r   r   Nr#   r   r%   r    Ar   r$   r   r#   r   s   && r   r%   _AdjointLinearOperator.__init__  A    QWWQZ(qwwe4D	r   c                8    V P                   P                  V4      # rh   )r   rL   r=   s   &&r   r   _AdjointLinearOperator._matvec      vvq!!r   c                8    V P                   P                  V4      # rh   )r   r   r=   s   &&r   rL   _AdjointLinearOperator._rmatvec      vv~~a  r   c                8    V P                   P                  V4      # rh   )r   rP   r=   s   &&r   r   _AdjointLinearOperator._matmat  r   r   c                8    V P                   P                  V4      # rh   )r   r   r=   s   &&r   rP   _AdjointLinearOperator._rmatmat  r   r   r   r   r   r   r   r   r   r%   r   rL   r   rP   r   r   r   r   s   @@r   r   r     s&     ."!"! !r   r   c                   N   a a ] tR tRt oRtV 3R 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                   ^,          VP                   ^ ,          3p\        SV `	  VP                  VR7       Wn        V3V n        R# r   r   r   s   && r   r%   "_TransposedLinearOperator.__init__  r   r   c                    \         P                  ! V P                  P                  \         P                  ! V4      4      4      # rh   )r   conjr   rL   r=   s   &&r   r   !_TransposedLinearOperator._matvec  &    wwtvvrwwqz233r   c                    \         P                  ! V P                  P                  \         P                  ! V4      4      4      # rh   )r   r   r   r   r=   s   &&r   rL   "_TransposedLinearOperator._rmatvec  &    wwtvv~~bggaj122r   c                    \         P                  ! V P                  P                  \         P                  ! V4      4      4      # rh   )r   r   r   rP   r=   s   &&r   r   !_TransposedLinearOperator._matmat  r   r   c                    \         P                  ! V P                  P                  \         P                  ! V4      4      4      # rh   )r   r   r   r   r=   s   &&r   rP   "_TransposedLinearOperator._rmatmat  r   r   r   r   r   s   @@r   r   r     s&     44343 3r   r   c                     Vf   . pV  F8  pVf   K	  \        VR4      '       g   K  VP                  VP                  4       K:  	  \        P                  ! V!  # )Nr    )rR   appendr    r   result_type)	operatorsdtypesr   s   && r   
_get_dtyper     sH    ~?wsG44MM#))$  >>6""r   c                   P   a a ] tR tRt oV 3R ltR tR tR tR tR t	Rt
VtV ;t# )	r   i  c                (  < \        V\        4      '       d   \        V\        4      '       g   \        R 4      hVP                  VP                  8w  d   \        RV RV R24      hW3V n        \
        SV `  \        W.4      VP                  4       R# ))both operands have to be a LinearOperatorzcannot add  and : shape mismatchN)rC   r   r"   r#   r   r   r%   r   r$   r   Br   s   &&&r   r%   _SumLinearOperator.__init__  sw    !^,,q.11HII77agg{1#U1#5EFGGF	QF+QWW5r   c                    V P                   ^ ,          P                  V4      V P                   ^,          P                  V4      ,           #     r   r,   r=   s   &&r   r   _SumLinearOperator._matvec  3    yy|""1%		!(;(;A(>>>r   c                    V P                   ^ ,          P                  V4      V P                   ^,          P                  V4      ,           # r  r   rM   r=   s   &&r   rL   _SumLinearOperator._rmatvec  3    yy|##A&1)=)=a)@@@r   c                    V P                   ^ ,          P                  V4      V P                   ^,          P                  V4      ,           # r  r   rc   r=   s   &&r   rP   _SumLinearOperator._rmatmat  r  r   c                    V P                   ^ ,          P                  V4      V P                   ^,          P                  V4      ,           # r  r   r<   r=   s   &&r   r   _SumLinearOperator._matmat  r  r   c                X    V P                   w  rVP                  VP                  ,           # rh   r   rT   r$   r   r  s   &  r   rQ   _SumLinearOperator._adjoint      yyssQSSyr   r   r   r   r   r   r%   r   rL   rP   r   rQ   r   r   r   r   s   @@r   r   r     s*     6?AA? r   r   c                   P   a a ] tR tRt oV 3R ltR tR tR tR tR t	Rt
VtV ;t# )	ry   i  c                x  < \        V\        4      '       d   \        V\        4      '       g   \        R 4      hVP                  ^,          VP                  ^ ,          8w  d   \        RV RV R24      h\        SV `  \        W.4      VP                  ^ ,          VP                  ^,          34       W3V n        R# )r  zcannot multiply r  r  N)rC   r   r"   r#   r   r%   r   r   r  s   &&&r   r%   _ProductLinearOperator.__init__  s    !^,,q.11HII771:#/s%s:JKLLQF+67ggaj!''!*5M	OF	r   c                    V P                   ^ ,          P                  V P                   ^,          P                  V4      4      # r  r
  r=   s   &&r   r   _ProductLinearOperator._matvec  .    yy|""499Q<#6#6q#9::r   c                    V P                   ^,          P                  V P                   ^ ,          P                  V4      4      # r   r  r=   s   &&r   rL   _ProductLinearOperator._rmatvec  .    yy|##DIIaL$8$8$;<<r   c                    V P                   ^,          P                  V P                   ^ ,          P                  V4      4      # r%  r  r=   s   &&r   rP   _ProductLinearOperator._rmatmat  r'  r   c                    V P                   ^ ,          P                  V P                   ^,          P                  V4      4      # r  r  r=   s   &&r   r   _ProductLinearOperator._matmat  r#  r   c                X    V P                   w  rVP                  VP                  ,          # rh   r  r  s   &  r   rQ   _ProductLinearOperator._adjoint  r  r   r  r  r   s   @@r   ry   ry     s(     ;==; r   ry   c                   P   a a ] tR tRt oV 3R ltR tR tR tR tR t	Rt
VtV ;t# )	rr   i  c                `  < \        V\        4      '       g   \        R 4      h\        P                  ! V4      '       g   \        R4      h\        V\
        4      '       d   VP                  w  rW#,          p\        V.\        V4      .4      p\        SV `)  WAP                  4       W3V n        R# )LinearOperator expected as Azscalar expected as alphaN)rC   r   r"   r   rq   rr   r   r   r   r   r%   r#   )r$   r   alphaalpha_originalr    r   s   &&&  r   r%   _ScaledLinearOperator.__init__  s    !^,,;<<{{5!!788a.// !A *EA3e.(J	r   c                v    V P                   ^,          V P                   ^ ,          P                  V4      ,          # r%  r
  r=   s   &&r   r   _ScaledLinearOperator._matvec   (    yy|diil11!444r   c                    \         P                  ! V P                  ^,          4      V P                  ^ ,          P                  V4      ,          # r%  )r   r   r   rM   r=   s   &&r   rL   _ScaledLinearOperator._rmatvec  1    wwtyy|$tyy|';';A'>>>r   c                    \         P                  ! V P                  ^,          4      V P                  ^ ,          P                  V4      ,          # r%  )r   r   r   rc   r=   s   &&r   rP   _ScaledLinearOperator._rmatmat  r9  r   c                v    V P                   ^,          V P                   ^ ,          P                  V4      ,          # r%  r  r=   s   &&r   r   _ScaledLinearOperator._matmat	  r6  r   c                l    V P                   w  rVP                  \        P                  ! V4      ,          # rh   )r   rT   r   r   )r$   r   r1  s   &  r   rQ   _ScaledLinearOperator._adjoint  s$    99ssRWWU^##r   r  r  r   s   @@r   rr   rr     s(      5??5$ $r   rr   c                   V   a a ] tR tRt oV 3R ltR tR tR tR tR t	R t
R	tVtV ;t# )
r   i  c                X  < \        V\        4      '       g   \        R 4      hVP                  ^ ,          VP                  ^,          8w  d   \        RV: 24      h\	        V4      '       d   V^ 8  d   \        R4      h\
        SV `  \        V.4      VP                  4       W3V n        R# )r0  z$square LinearOperator expected, got z"non-negative integer expected as pN)	rC   r   r"   r#   r   r   r%   r   r   )r$   r   r   r   s   &&&r   r%   _PowerLinearOperator.__init__  s    !^,,;<<771:#CA5IJJ||q1uABBQC!''2F	r   c                    \         P                  ! VR R7      p\        V P                  ^,          4       F  pV! V4      pK  	  V# )T)copy)r   arrayranger   )r$   funr>   resis   &&&  r   _power_PowerLinearOperator._power  s7    hhqt$tyy|$Ac(C %
r   c                \    V P                  V P                  ^ ,          P                  V4      # r  )rJ  r   r,   r=   s   &&r   r   _PowerLinearOperator._matvec#  !    {{499Q<..22r   c                \    V P                  V P                  ^ ,          P                  V4      # r  )rJ  r   rM   r=   s   &&r   rL   _PowerLinearOperator._rmatvec&  !    {{499Q<//33r   c                \    V P                  V P                  ^ ,          P                  V4      # r  )rJ  r   rc   r=   s   &&r   rP   _PowerLinearOperator._rmatmat)  rQ  r   c                \    V P                  V P                  ^ ,          P                  V4      # r  )rJ  r   r<   r=   s   &&r   r   _PowerLinearOperator._matmat,  rN  r   c                D    V P                   w  rVP                  V,          # rh   r  )r$   r   r   s   &  r   rQ   _PowerLinearOperator._adjoint/  s    yyssaxr   r  )r   r   r   r   r%   rJ  r   rL   rP   r   rQ   r   r   r   r   s   @@r   r   r     s-     	3443 r   r   c                   >   a a ] tR tRt oV 3R ltR tR tRtVtV ;t	# )MatrixLinearOperatori4  c                z   < \         SV `  VP                  VP                  4       Wn        R V n        V3V n        R # rh   )r   r%   r    r#   r   _MatrixLinearOperator__adjr   )r$   r   r   s   &&r   r%   MatrixLinearOperator.__init__5  s/    !''*
D	r   c                8    V P                   P                  V4      # rh   )r   rm   )r$   r8   s   &&r   r   MatrixLinearOperator._matmat;  s    vvzz!}r   c                j    V P                   f   \        V P                  4      V n         V P                   # rh   )r[  _AdjointMatrixOperatorr   r   s   &r   rQ   MatrixLinearOperator._adjoint>  s&    ::/7DJzzr   )r   __adjr   )
r   r   r   r   r%   r   rQ   r   r   r   r   s   @@r   rY  rY  4  s      r   rY  c                   <   a  ] tR tRt o R t]R 4       tR tRtV t	R# )r`  iD  c                    VP                   P                  4       V n        V3V n        VP                  ^,          VP                  ^ ,          3V n        R# )r   N)r5   r   r   r   r#   )r$   adjoint_arrays   &&r   r%   _AdjointMatrixOperator.__init__E  sB    %%'"$	"((+]-@-@-CC
r   c                <    V P                   ^ ,          P                  # r  )r   r    r   s   &r   r    _AdjointMatrixOperator.dtypeJ  s    yy|!!!r   c                :    \        V P                  ^ ,          4      # r  )rY  r   r   s   &r   rQ   _AdjointMatrixOperator._adjointN  s    #DIIaL11r   )r   r   r#   N)
r   r   r   r   r%   r   r    rQ   r   r   )r   s   @r   r`  r`  D  s)     D
 " "2 2r   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# )
IdentityOperatoriR  c                &   < \         SV `  W!4       R # rh   )r   r%   )r$   r#   r    r   s   &&&r   r%   IdentityOperator.__init__S  s    &r   c                    V# rh   ri   r=   s   &&r   r   IdentityOperator._matvecV      r   c                    V# rh   ri   r=   s   &&r   rL   IdentityOperator._rmatvecY  rq  r   c                    V# rh   ri   r=   s   &&r   rP   IdentityOperator._rmatmat\  rq  r   c                    V# rh   ri   r=   s   &&r   r   IdentityOperator._matmat_  rq  r   c                    V # rh   ri   r   s   &r   rQ   IdentityOperator._adjointb  s    r   ri   rh   r  r   s   @@r   rl  rl  R  s(     ' r   rl  c                   \        V \        4      '       d   V # \        V \        P                  4      '       g!   \        V \        P                  4      '       dR   V P
                  ^8  d   \        R4      h\        P                  ! \        P                  ! V 4      4      p \        V 4      # \        V 4      '       g   \        V 4      '       d   \        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"                  VW#R7      # \%        R	4      h)
a  Return A as a LinearOperator.

'A' may be any of the following types:
 - ndarray
 - matrix
 - sparse array (e.g. csr_array, lil_array, etc.)
 - LinearOperator
 - An object with .shape and .matvec attributes

See the LinearOperator documentation for additional information.

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>
zarray must have ndim <= 2r#   r,   NrM   rc   r    )rM   rc   r    ztype not understood)rC   r   r   ndarrayrD   rE   r"   
atleast_2dr+   rY  r   r   rR   rM   rc   r    r#   r,   r\   )r   rM   rc   r    s   &   r   r   r   f  s(   4 !^$$	Arzz	"	"jBII&>&>66A:899MM"**Q-(#A&&	!*1--#A&& 1g71h#7#7GGEq)$$))q)$$))q'""!!''188W*1@ @ 122r   rh   )r   r   r   numpyr   scipy.sparser   scipy.sparse._sputilsr   r   r   r   __all__r   r   r   r   r   r   ry   rr   r   rY  r`  rl  r   ri   r   r   <module>r     s   *X    ! R R/
0Z/ Z/z+7N +7\!^ !*3 3.# 6^ 8$N $D >  F>  21 2~ (63r   