o
    0 i                     @   s@   d dl Z d dlZd dlmZ d dlmZ d dlmZ dd ZdS )    N)device)_util)sparsec                 C   s  ddl m} t| st| } t|  t| | jd }|j	dks*t
||kr.td| jdks8| jdkr<| j}nt| jd}t }| j}d}d}tj||d}	tdtj}
|dkrd|j}n|j}||||| jj| jjj| jjj| jjj|jj|||	jj|
jj |	tj}	|	S )	aE  Solves linear system with cholesky decomposition.

    Find the solution to a large, sparse, linear system of equations.
    The function solves ``Ax = b``. Given two-dimensional matrix ``A`` is
    decomposed into ``L * L^*``.

    Args:
        A (cupy.ndarray or cupyx.scipy.sparse.csr_matrix): The input matrix
            with dimension ``(N, N)``. Must be positive-definite input matrix.
            Only symmetric real matrix is supported currently.
        b (cupy.ndarray): Right-hand side vector.

    Returns:
        ret (cupy.ndarray): The solution vector ``x``.

    r   )cusolver   z+b must be 1-d array whose size is same as Afdg      ?)dtype) Zcupy_backends.cuda.libsr   r   Zisspmatrix_csrZ
csr_matrixr   Z_assert_stacked_squareZ_assert_cupy_arrayshapendimlen
ValueErrorr	   numpyZpromote_typesr   Zget_cusolver_sp_handlennzcupyemptyZint32ZscsrlsvcholZdcsrlsvcholZ_descrZ
descriptordataZptrZindptrindicesctypesZastypeZfloat64)Abr   mr	   handler   ZtolZreorderxsingularityZ
csrlsvchol r   f/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/cupyx/linalg/sparse/_solve.pylschol	   s6   




r   )	r   r   Z	cupy.cudar   Zcupy.linalgr   Zcupyx.scipyr   r   r   r   r   r   <module>   s    