+
    nDjqA                        R t ^ RIt^ RIHtHtHt ^ RIHtHtH	t	 ^RI
HtHt ^RIHtHtHt ^RIHt . ROtR tRR ltRR	 ltRR
 ltRR lt]! RR4      R 4       t]! R4      RR l4       tRR lt]! RR4      R 4       tR# )z!Cholesky decomposition functions.N)asarray_chkfiniteasarray
empty_like)_asarray_validated_apply_over_batch_deprecate_dtypes)LinAlgError_datacopied)get_lapack_funcs_normalize_lapack_dtype_ensure_aligned_and_native)_batched_linalgc           
          R T  RV Uu. uF  q"R,          NK  	  up RV Uu. uF  q"R,          NK  	  up R2p\        V4      hu upi u upi )z	Internal z return info = lapack_infoz for slices num.)r   )routine_nameerr_lstemsgs   &&  W/data/cameron/venvs/s3viz/lib/python3.14/site-packages/scipy/linalg/_decomp_cholesky.py_check_format_errors_warningsr      sf    
L>G1TGqM2B2BG1T0U V)01Axx12!	5  c
 2U1s
   A
A	c                   \        WR7      p\        P                  ! V4      pVP                  R	,          VP                  R
,          8w  d   \	        RVP                  : 24      h\        RV4       \        WR4      w  rR\        WR4      w  rRT;'       dF    VP                  ^8H  ;'       d/    VP                  R,          ;'       g    VP                  R,          pVP                  R	,          ^ 8X  d;   VP                  RR
 p\        P                  ! VR,           VP                  R7      pV# \        P                  ! WQW#4      w  rxV'       d   \        RV4       V# )z,Common code for cholesky() and cho_factor().)check_finitez8Expected a square matrix or batch thereof, got a1.shape=zlinalg.choleskyF_CONTIGUOUSC_CONTIGUOUSNdtypepotrf)    r!   )r   np
atleast_2dshape
ValueErrorr   r   r   ndimflagszerosr   r   	_choleskyr   )	aloweroverwrite_acleanr   a1batch_shapecr   s	   &&&&&    r   r)   r)      s   
 
A	9B	r	B	xx|rxx|#T288+VWW',-b>OB0AOB N NBGGqL N N0LLBHH^4L  
xx|qhhsmHH[6): !**2kIJA%gw7H    c                $    \        WVRVR7      pV# )av  
Compute the Cholesky decomposition of a matrix.

Returns the Cholesky decomposition, :math:`A = L L^*` or
:math:`A = U^* U` of a Hermitian positive-definite matrix A.

Parameters
----------
a : (..., M, M) array_like
    Matrix to be decomposed
lower : bool, optional
    Whether to compute the upper- or lower-triangular Cholesky
    factorization. During decomposition, only the selected half of the
    matrix is referenced. Default is upper-triangular.
overwrite_a : bool, optional
    Whether to overwrite data in `a` (may improve performance). Default is False.
    See :ref:`tutorial_linalg_overwrite` for details.
check_finite : bool, optional
    Whether to check that the entire input matrix contains only finite numbers.
    Disabling may give a performance gain, but may result in problems
    (crashes, non-termination) if the inputs do contain infinities or NaNs.

Returns
-------
c : (..., M, M) ndarray
    Upper- or lower-triangular Cholesky factor of `a`.

Raises
------
LinAlgError : if decomposition fails.

See Also
--------
cho_factor : Compute the Cholesky decomposition without explicitly setting
                the other triangle to 0.

Notes
-----
During the finiteness check (if selected), the entire matrix `a` is
checked. During decomposition, `a` is assumed to be symmetric or Hermitian
(as applicable), and only the half selected by option `lower` is referenced.
Consequently, if `a` is asymmetric/non-Hermitian, `cholesky` may still
succeed if the symmetric/Hermitian matrix represented by the selected half
is positive definite, yet it may fail if an element in the other half is
non-finite.

Examples
--------
>>> import numpy as np
>>> from scipy.linalg import cholesky
>>> a = np.array([[1,-2j],[2j,5]])
>>> L = cholesky(a, lower=True)
>>> L
array([[ 1.+0.j,  0.+0.j],
       [ 0.+2.j,  1.+0.j]])
>>> L @ L.T.conj()
array([[ 1.+0.j,  0.-2.j],
       [ 0.+2.j,  5.+0.j]])

Tr+   r,   r-   r   )r)   )r*   r+   r,   r   r0   s   &&&& r   choleskyr4   :   s    | 	!k)	+AHr1   c                r    \        WVRVR7      pV P                  RR p\        P                  ! WR7      pWF3# )ay  
Compute the Cholesky decomposition of a matrix, to use in cho_solve.

Returns a matrix containing the Cholesky decomposition,
``A = L L*`` or ``A = U* U`` of a Hermitian positive-definite matrix `a`.
The return value can be directly used as the first parameter to cho_solve.

.. warning::
    If `overwrite_a` is disabled, this function matches `cholesky` and
    zeros the other triangle. If it is enabled, the returned matrix may
    contain random data in the entries not used by the Cholesky
    decomposition, saving out on the explicit putting to 0 done by
    `cholesky`.

Parameters
----------
a : (..., M, M) array_like
    Matrix to be decomposed
lower : bool, optional
    Whether to compute the upper or lower triangular Cholesky factorization.
    During decomposition, only the selected half of the matrix is referenced.
    (Default: upper-triangular)
overwrite_a : bool, optional
    Whether to overwrite data in ``a`` (may improve performance). Default is False.
    See :ref:`tutorial_linalg_overwrite` for details.
check_finite : bool, optional
    Whether to check that the entire input matrix contains only finite numbers.
    Disabling may give a performance gain, but may result in problems
    (crashes, non-termination) if the inputs do contain infinities or NaNs.

Returns
-------
c : (..., M, M) ndarray
    Matrix whose upper or lower triangle contains the Cholesky factor
    of `a`. Other parts of the matrix contain random data.
lower : ndarray, bool
    Flag indicating whether the factor is in the lower or upper triangle

Raises
------
LinAlgError
    Raised if decomposition fails.

See Also
--------
cholesky : Compute the Cholesky decomposition and explicitly put the
            other triangle to 0.
cho_solve : Solve a linear set equations using the Cholesky factorization
            of a matrix.

Notes
-----
During the finiteness check (if selected), the entire matrix `a` is
checked. During decomposition, `a` is assumed to be symmetric or Hermitian
(as applicable), and only the half selected by option `lower` is referenced.
Consequently, if `a` is asymmetric/non-Hermitian, `cholesky` may still
succeed if the symmetric/Hermitian matrix represented by the selected half
is positive definite, yet it may fail if an element in the other half is
non-finite.

Examples
--------
>>> import numpy as np
>>> from scipy.linalg import cho_factor
>>> A = np.array([[9, 3, 1, 5], [3, 7, 5, 1], [1, 5, 9, 2], [5, 1, 2, 6]],
...             dtype=float, order="F")
>>> A_ref = np.copy(A)
>>> c, low = cho_factor(A)
>>> c
array([[3.        , 1.        , 0.33333333, 1.66666667],
       [0.        , 2.44948974, 1.90515869, -0.27216553],
       [0.        , 0.        , 2.29330749, 0.8559528 ],
       [0.        , 0.        , 0.        , 1.55418563]])
>>> np.allclose(c.T @ c - A, np.zeros((4, 4)))
True
>>> c, low = cho_factor(A, overwrite_a=True)
>>> c
array([[3.        , 1.        , 0.33333333, 1.66666667],
       [3.        , 2.44948974, 1.90515869, -0.27216553],
       [1.        , 5.        , 2.29330749, 0.8559528 ],
       [5.        , 1.        , 2.        , 1.55418563]])
>>> np.allclose(np.triu(c).T @ np.triu(c) - A_ref, np.zeros((4, 4)))
True

Fr3   N)repsr    )r)   r$   r"   tile)r*   r+   r,   r   r0   r/   	ret_lowers   &&&&   r   
cho_factorr9   }   s?    n 	!k!-	/A ''#2,K0I<r1   c                &    V w  rE\        WAWRVR7      # )a  Solve the linear equations A x = b, given the Cholesky factorization of A.

The documentation is written assuming array arguments are of specified
"core" shapes. However, array argument(s) of this function may have additional
"batch" dimensions prepended to the core shape. In this case, the array is treated
as a batch of lower-dimensional slices; see :ref:`linalg_batch` for details.

Parameters
----------
c_and_lower : tuple, (array, bool)
    Cholesky factorization of an array, as given by cho_factor.
    The first element of the
    tuple is the matrix containing the Cholesky factor, and the second element is a
    boolean flag indicating whether the factor is in the lower or upper triangle.
b : array
    Right-hand side
overwrite_b : bool, optional
    Whether to overwrite data in b (may improve performance)
    See :ref:`tutorial_linalg_overwrite` for details.
check_finite : bool, optional
    Whether to check that the input matrices contain only finite numbers.
    Disabling may give a performance gain, but may result in problems
    (crashes, non-termination) if the inputs do contain infinities or NaNs.

Returns
-------
x : array
    The solution to the system A x = b

See Also
--------
cho_factor : Cholesky factorization of a matrix

Examples
--------
>>> import numpy as np
>>> from scipy.linalg import cho_factor, cho_solve
>>> A = np.array([[9, 3, 1, 5], [3, 7, 5, 1], [1, 5, 9, 2], [5, 1, 2, 6]])
>>> c, low = cho_factor(A)
>>> x = cho_solve((c, low), [1, 1, 1, 1])
>>> np.allclose(A @ x - [1, 1, 1, 1], np.zeros(4))
True

overwrite_br   )
_cho_solve)c_and_lowerbr<   r   r0   r+   s   &&&&  r   	cho_solver@      s    Z HAaEVVr1   c                    V'       d   \        V4      p\        V 4      p M\        V4      p\        V 4      p V P                  ^8w  g*   V P                  ^ ,          V P                  ^,          8w  d   \	        R4      hV P                  ^,          VP                  ^ ,          8w  d'   \	        RV P                   RVP                   R24      hVP
                  ^ 8X  de   \        \        P                  ! ^VP                  R7      R3\        P                  ! ^V P                  R7      4      P                  p\        WVR7      # T;'       g    \        WQ4      p\        R
W34      w  pV! WW#R7      w  rV	^ 8w  d   \	        RV	)  R	24      hV# )   z$The factored matrix c is not square.zincompatible dimensions (z and )r   Tr+   r<   illegal value in zth argument of internal potrs)potrs)r   r   r&   r$   r%   sizer@   r"   eyer   onesr   r	   r
   )
r0   r?   r+   r<   r   b1dtrF   xinfos
   &&&&&     r   r=   r=     s:   q!a QZAJvv{aggajAGGAJ.?@@wwqzRXXa[ 4QWWIU288*ANOO 
ww!|q14813385 	"''33R!3Kj1'2FEA@GAqy,dUG3PQRRHr1   c                   V'       d   \        V 4      p M\        V 4      p V P                  ^ 8X  dH   \        \        P
                  ! ^ ^ .^^..V P                  R7      4      P                  p\        WR7      # \        RV 34      w  pV! WVR7      w  rgV^ 8  d   \        V R24      hV^ 8  d   \        RV R24      hV# )a  
Cholesky decompose a banded Hermitian positive-definite matrix.

The matrix a is stored in ab either in lower-diagonal or upper-
diagonal ordered form::

    ab[u + i - j, j] == a[i,j]        (if upper form; i <= j)
    ab[    i - j, j] == a[i,j]        (if lower form; i >= j)

Example of ab (shape of a is (6,6), u=2)::

    upper form:
    *   *   a02 a13 a24 a35
    *   a01 a12 a23 a34 a45
    a00 a11 a22 a33 a44 a55

    lower form:
    a00 a11 a22 a33 a44 a55
    a10 a21 a32 a43 a54 *
    a20 a31 a42 a53 *   *

Parameters
----------
ab : (u + 1, M) array_like
    Banded matrix
overwrite_ab : bool, optional
    Discard data in ab (may enhance performance)
    See :ref:`tutorial_linalg_overwrite` for details.
lower : bool, optional
    Is the matrix in the lower form. (Default is upper form)
check_finite : bool, optional
    Whether to check that the input matrix contains only finite numbers.
    Disabling may give a performance gain, but may result in problems
    (crashes, non-termination) if the inputs do contain infinities or NaNs.

Returns
-------
c : (u + 1, M) ndarray
    Cholesky factorization of a, in the same banded format as ab

See Also
--------
cho_solve_banded :
    Solve a linear set equations, given the Cholesky factorization
    of a banded Hermitian.

Examples
--------
>>> import numpy as np
>>> from scipy.linalg import cholesky_banded
>>> from numpy import allclose, zeros, diag
>>> Ab = np.array([[0, 0, 1j, 2, 3j], [0, -1, -2, 3, 4], [9, 8, 7, 6, 9]])
>>> A = np.diag(Ab[0,2:], k=2) + np.diag(Ab[1,1:], k=1)
>>> A = A + A.conj().T + np.diag(Ab[2, :])
>>> c = cholesky_banded(Ab)
>>> C = np.diag(c[0, 2:], k=2) + np.diag(c[1, 1:], k=1) + np.diag(c[2, :])
>>> np.allclose(C.conj().T @ C - A, np.zeros((5, 5)))
True

r   )r+   overwrite_abz'-th leading minor not positive definiterE   z-th argument of internal pbtrf)pbtrf)r   r   rG   cholesky_bandedr"   arrayr   r   r
   r   r%   )abrO   r+   r   rK   rP   r0   rM   s   &&&&    r   rQ   rQ   ,  s    | r"R[ 
ww!|RXX1v1v&6bhhGHNN"''j2%0FEB,?GAaxTF"IJKKax,TF2PQRRHr1   c                &    V w  rE\        WAWRVR7      # )a  
Solve the linear equations ``A x = b``, given the Cholesky factorization of
the banded Hermitian ``A``.

The documentation is written assuming array arguments are of specified
"core" shapes. However, array argument(s) of this function may have additional
"batch" dimensions prepended to the core shape. In this case, the array is treated
as a batch of lower-dimensional slices; see :ref:`linalg_batch` for details.

Parameters
----------
cb_and_lower : tuple, (ndarray, bool)
    The first element of the tuple is the matrix containing the Cholesky factor,
    as provided by `cholesky_banded`. The second element is a boolean flag
    indicating whether the factor is in the lower triangle, as provided *to*
    `cholesky_banded`.
b : array_like
    Right-hand side
overwrite_b : bool, optional
    If True, the function will overwrite the values in `b`.
    See :ref:`tutorial_linalg_overwrite` for details.
check_finite : bool, optional
    Whether to check that the input matrices contain only finite numbers.
    Disabling may give a performance gain, but may result in problems
    (crashes, non-termination) if the inputs do contain infinities or NaNs.

Returns
-------
x : array
    The solution to the system A x = b

See Also
--------
cholesky_banded : Cholesky factorization of a banded matrix

Notes
-----

.. versionadded:: 0.8.0

Examples
--------
>>> import numpy as np
>>> from scipy.linalg import cholesky_banded, cho_solve_banded
>>> Ab = np.array([[0, 0, 1j, 2, 3j], [0, -1, -2, 3, 4], [9, 8, 7, 6, 9]])
>>> A = np.diag(Ab[0,2:], k=2) + np.diag(Ab[1,1:], k=1)
>>> A = A + A.conj().T + np.diag(Ab[2, :])
>>> c = cholesky_banded(Ab)
>>> x = cho_solve_banded((c, False), np.ones(5))
>>> np.allclose(A @ x - np.ones(5), np.zeros(5))
True

r;   )_cho_solve_banded)cb_and_lowerr?   r<   r   cbr+   s   &&&&  r   cho_solve_bandedrX   }  s     l KRRE*68 8r1   c                 r   V'       d   \        V 4      p \        V4      pM\        V 4      p \        V4      pV P                  R,          VP                  ^ ,          8w  d   \        R4      hVP                  ^ 8X  dv   \        \        P                  ! ^ ^ .^^..V P                  R7      4      p\        VR3\        P                  ! ^VP                  R7      4      P                  p\        WR7      # \        R	W34      w  pV! WW#R7      w  rV	^ 8  d   \        V	 R24      hV	^ 8  d   \        RV	)  R24      hV# )
   z&shapes of cb and b are not compatible.r   TrD   z&th leading minor not positive definiterE   zth argument of internal pbtrsr   )pbtrs)r   r   r$   r%   rG   rQ   r"   rR   r   rX   rI   r   r
   r   )
rW   r?   r+   r<   r   mrK   r[   rL   rM   s
   &&&&&     r   rU   rU     s   r"a R[AJ 
xx|qwwqz!ABB 	vv{BHHq!fq!f%5RXXFGq$i!'')BCII!&&j2'2FEB@GAaxTF"HIJJax,dUG3PQRRHr1   )r4   r9   r@   rQ   rX   )FFTT)FFT)FT)r0   rB   )r?   z1|2)rS   rB   )rW   rB   )__doc__numpyr"   r   r   r   scipy._lib._utilr   r   r   _miscr   r	   lapackr
   r   r    r   __all__r   r)   r4   r9   r@   r=   rQ   rX   rU    r1   r   <module>re      s    '  8 8 V U +  @@F^B.Wb 8\* +8 9M M`88v 9l+ ,r1   