
    
9jM                    <    S SK Jr  S SKrS SKJr  S SKrS rSS jrg)    )annotationsN)_utilc                    SSK Jn  [        R                  " U 5        [        R                  " U 5        [        R
                  " U 5        [        R                  " U 5      nUR                  X5      $ )a  Compute the inverse of a Hermitian matrix.

This function computes a inverse of a real symmetric or complex hermitian
positive-definite matrix using Cholesky factorization. If matrix ``a`` is
not positive definite, Cholesky factorization fails and it raises an error.

Args:
    a (cupy.ndarray): Real symmetric or complex hermitian maxtix.

Returns:
    cupy.ndarray: The inverse of matrix ``a``.
r   lapack)cupyxr   r   _assert_cupy_array
_assert_2d_assert_stacked_squarestacked_identity_likeposv)ar   bs      M/home/wildlama/miniconda3/lib/python3.13/site-packages/cupyx/linalg/_solve.pyinvhr   	   sR     	Q 
Q	  ###A&A;;q    c                   SSK Jn  U u  pVU(       a  U(       a$  [        R                  " UR                  S   S5      O#[        R
                  " UR                  S   S5      n[        R                  " USUS   US   4   5      R                  5       (       d  [        S5      e[        R                  " U5      R                  5       (       d  [        S5      eU(       ds  UR                  S:X  a2  UR                  R                  (       a  [        R                  " USS	S
9nO1UR                  R                  (       a  [        R                  " USS	S
9nUR                  XQUS9$ )ak  
Solves the linear system Ax = b using the Cholesky factorization of A.
Batched input arrays are also supported.

Args:
    c (tuple of cupy.ndarray and bool): The first tuple item is the
        Cholesky factor of the matrix `A`, typically obtained from
        `cupy.linalg.cholesky`. The second item is a bool that indicates
        whether the Cholesky factor is stored in the lower-triangular
        part (when True) or in the upper-triangular part (when False).
    b (cupy.ndarray): Right-hand side array.
    overwrite_b (bool, optional): If True, the contents of `b` may be
        overwritten for efficiency. Default is False.
    check_finite (bool, optional): If True, checks whether the input arrays
        contain only finite numbers. Disabling this may improve performance
        but can lead to crashes or non-termination if NaNs or infs are
        present. Default is True.

Returns:
    cupy.ndarray: Solution to the linear system Ax = b.

See Also:
    cupy.linalg.cho_factor: Computes the Cholesky factorization.

Examples:
    >>> import cupy as cp
    >>> from cupy.linalg import cholesky, cho_solve
    >>> A = cp.array([[9, 3, 1, 5],
    ...               [3, 7, 5, 1],
    ...               [1, 5, 9, 2],
    ...               [5, 1, 2, 6]])
    >>> c= cholesky(A)
    >>> x = cho_solve((c, True), cp.ones(4))
    >>> cp.allclose(A @ x, cp.ones(4))
    True
r   r      .z%Input array contains NaN or infinity.   FT)ordercopyC)lower)r   r   numpytril_indicesshapetriu_indicescupyisfiniteall
ValueErrorndimflagsf_contiguousasarrayc_contiguouspotrs)c_and_lowerr   overwrite_bcheck_finiter   cr   indexess           r   	cho_solver/   "   s   J JQ :?5%%aggbk26%%aggbk15 	}}QsGAJ
:;<@@BBDEE}}Q##%%DEE 66Q;ww##LL#D9 ww##LL#D9<<E<**r   )FT)
__future__r   r   cupy.linalgr   r    r   r/    r   r   <module>r3      s    "   2>+r   