
    `i                     ,    d dl Z d dlZd dlZd ZddZdS )    Nc                 *   t          j        | j        t           j                  r5t	          |                               d                                          }n'|                     d                                          }t          j        |          S )N   )cupy
issubdtypedtypecomplexfloatingabspowersumsqrt)xsqnorms     s/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupyx/scipy/sparse/linalg/_norm.py_sparse_frobenius_normr      sg    qw 455 "Qa$$&&!!9V    c                 	   t           j        j                            |           st	          d          ||dv rt          |           S |                                 } |d}n]t          |t                    sHd}	 t          |          }n# t          $ r t	          |          w xY w||k    rt	          |          |f}d}t          |          dk    r|\  }}| |cxk    r|k     rn n| |cxk    r|k     sn t          d|d| j                  ||z  ||z  k    rt          d	          |dk    rt          |d
k    rt          |dk    r5t          |                               |                                          S |t"          j        k    r5t          |                               |                                          S |dk    r5t          |                               |                                          S |t"          j         k    r5t          |                               |                                          S |dv rt          |           S t          d          t          |          dk    rd|\  }| |cxk    r|k     sn t          d|d| j                  |t"          j        k    rGt          |                               |                                                                          S |t"          j         k    rGt          |                               |                                                                          S |dk    rf| dk                        t"          j                                      |                                                              t"          j                  S |dk    r5t          |                               |                                          S |dv rZt3          j        t          |                               d                              |                                                    S 	 |dz    n# t          $ r t          d          w xY wt3          j        t          |                               |                              |          d|z                                            S t          d          )a  Norm of a cupy.scipy.spmatrix

    This function is able to return one of seven different sparse matrix norms,
    depending on the value of the ``ord`` parameter.

    Args:
        x (sparse matrix) : Input sparse matrix.
        ord (non-zero int, inf, -inf, 'fro', optional) : Order of the norm (see
            table under ``Notes``). inf means numpy's `inf` object.
        axis : (int, 2-tuple of ints, None, optional): If `axis` is an
            integer, it specifies the axis of `x` along which to
            compute the vector norms.  If `axis` is a 2-tuple, it specifies the
            axes that hold 2-D matrices, and the matrix norms of these matrices
            are computed.  If `axis` is None then either a vector norm
            (when `x` is 1-D) or a matrix norm (when `x` is 2-D) is returned.
    Returns:
        ndarray : 0-D or 1-D array or norm(s).

    .. seealso:: :func:`scipy.sparse.linalg.norm`
    z)input is not sparse. use cupy.linalg.normN)Nfrof)r      z6'axis' must be None, an integer or a tuple of integersr   zInvalid axis z for an array with shape zDuplicate axes given.r   )axis)Nr   r   z Invalid norm order for matrices.r   )r   NzInvalid norm order for vectors.z&Improper number of dimensions to norm.)cupyxscipysparseissparse	TypeErrorr   tocsr
isinstancetupleintlen
ValueErrorshapeNotImplementedErrorr	   r   maxnumpyinfmintoarrayravelastypefloat32int_r   r   r
   )	r   ordr   msgint_axisndrow_axiscol_axisas	            r   normr6      s   , ;&&q)) GDFFF |111%a((( 	
		A|e$$ F	!4yyHH 	! 	! 	!C.. 	!8C.. {	
B
4yyA~~!(x$$$$"$$$$$")=)=)=)=2)=)=)=)=*"ddAGG- . . .b=HrM))4555!88%%BYY%%AXXq66::8:,,00222EIq66::8:,,00222BYYq66::8:,,00222UYJq66::8:,,00222&&&)!,,,?@@@	Taq2*"ddAGG- . . .%)q66::1:%%--//55777UYJq66::1:%%--//55777AXXF??5=115515==CCEELL
  AXXq66::1:%%++---I9SVV\\!__00a08899??AAADa D D D !BCCCD:c!ffll3//333;;QWEEKKMMMABBBs   :B
 
B$$Q* *R)NN)r'   r   cupyx.scipy.sparser   r   r6    r   r   <module>r9      s\           `C `C `C `C `C `Cr   