
    `i                     Z    d dl Z d dlZd dlZd dlZd dlmZ d
dddZddZ	 	 dddd	ZdS )    N)_coreTdtypec                   ||t          j        dt                     t          | |||          }	 t	          j        |          }n# t          $ r ||z  cY S w xY wt	          j        |j                  }||dddf         z  }||dddf         z  }t	          j	        |j        dd|j                   t	          j
        |          r"t	          j	        |j        dd|j                   |S )a:  Returns the Pearson product-moment correlation coefficients of an array.

    Args:
        a (cupy.ndarray): Array to compute the Pearson product-moment
            correlation coefficients.
        y (cupy.ndarray): An additional set of variables and observations.
        rowvar (bool): If ``True``, then each row represents a variable, with
            observations in the columns. Otherwise, the relationship is
            transposed.
        bias (None): Has no effect, do not use.
        ddof (None): Has no effect, do not use.
        dtype: Data type specifier. By default, the return data-type will have
            at least `numpy.float64` precision.

    Returns:
        cupy.ndarray: The Pearson product-moment correlation coefficients of
        the input array.

    .. seealso:: :func:`numpy.corrcoef`

    Nz/bias and ddof have no effect and are deprecatedr      )out)warningswarnDeprecationWarningcovcupydiag
ValueErrorsqrtrealclipiscomplexobjimag)	ayrowvarbiasddofr   r	   dstddevs	            p/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupy/_statistics/correlation.pycorrcoefr   
   s   , 4+G(	* 	* 	* aF%
(
(
(CIcNN   Sy YqvF6!!!T'?C6$'?CIchA38,,,, 1	#(Bsx0000Js   A AAvalidc                 $   | j         dk    s|j         dk    rt          d          | j        dk    s|j        dk    rt          d          t          j        j                            | ||          }|dk    rBt          j        j                            | |                                ddd         |          }nW|dk    rBt          j        j        	                    | |                                ddd         |          }nt          d	          |S )
ad  Returns the cross-correlation of two 1-dimensional sequences.

    Args:
        a (cupy.ndarray): first 1-dimensional input.
        v (cupy.ndarray): second 1-dimensional input.
        mode (str, optional): `valid`, `same`, `full`

    Returns:
        cupy.ndarray: Discrete cross-correlation of a and v.

    .. seealso:: :func:`numpy.correlate`

    r   zArray arguments cannot be emptyr   z!object too deep for desired arraydirectNr   fftzUnsupported method)
sizer   ndimr   _mathmisc_choose_conv_method_dot_convolveconj_fft_convolve)r   vmodemethodr	   s        r   	correlater.   5   s     	v{{afkk:;;;v{{afkk<=== Z_00At<<Fjo++Aqvvxx"~tDD	5jo++Aqvvxx"~tDD-...J    Fc                   |"|t          |          k    rt          d          | j        dk    rt          d          |w|%t          j        | j        t          j                  }nP|j        dk    rt          d          t          j        t          j        | j        |j        t          j        f          }t          j
        | d|          }|s|j        d         dk    r|j        }|j        d         dk    r(t          j
        g                               dd          S |Jt          j
        |d	d|
          }|s|j        d         dk    r|j        }t          j        ||fd          }||rdnd}d}	|t!          |t          j                  st%          d          |j        j        dvrt%          d          |                    t*                    }|j        dk    rt-          d          |j        d         |j        d         k    rt-          d          |}	|t!          |t          j                  st%          d          |                    t*                    }|j        dk    rt-          d          |j        d         |j        d         k    rt-          d          |	|}	n|	|z  }	t          j        |d|	d          \  }
}|d         }|	|j        d         |z
  }n,|dk    r|}n#|||z
  }n||t1          |	|z            z  |z  z
  }|dk    rt3          j        dt6          d           d}||                    d          dddf         z  }|	|j        }n
||	z  j        }|                    |                                          dt          j        |          z  z  }|                                S )ap  Returns the covariance matrix of an array.

    This function currently does not support ``fweights`` and ``aweights``
    options.

    Args:
        a (cupy.ndarray): Array to compute covariance matrix.
        y (cupy.ndarray): An additional set of variables and observations.
        rowvar (bool): If ``True``, then each row represents a variable, with
            observations in the columns. Otherwise, the relationship is
            transposed.
        bias (bool): If ``False``, normalization is by ``(N - 1)``, where N is
            the number of observations given (unbiased estimate). If ``True``,
            then normalization is by ``N``.
        ddof (int): If not ``None`` the default value implied by bias is
            overridden. Note that ``ddof=1`` will return the unbiased estimate
            and ``ddof=0`` will return the simple average.

        fweights (cupy.ndarray, int): 1-D array of integer frequency weights.
            the number of times each observation vector should be repeated.
            It is required that fweights >= 0. However, the function will not
            error when fweights < 0 for performance reasons.
        aweights (cupy.ndarray): 1-D array of observation vector weights.
            These relative weights are typically large for observations
            considered "important" and smaller for observations considered
            less "important". If ``ddof=0`` the array of weights can be used
            to assign probabilities to observation vectors.
            It is required that aweights >= 0. However, the function will not
            error when aweights < 0 for performance reasons.
        dtype: Data type specifier. By default, the return data-type will have
            at least `numpy.float64` precision.

    Returns:
        cupy.ndarray: The covariance matrix of the input array.

    .. seealso:: :func:`numpy.cov`

    Nzddof must be integer   zInput must be <= 2-dzy must be <= 2-d)ndminr   r   r   F)copyr2   r   )axiszfweights must be a cupy.ndarray
bBhHiIlLqQzfweights must be integerr   z'cannot handle multidimensional fweightsz,incompatible numbers of samples and fweightszaweights must be a cupy.ndarrayz'cannot handle multidimensional aweightsz,incompatible numbers of samples and aweightsT)r4   weightsreturnedz!Degrees of freedom <= 0 for slice)
stacklevelg        ) intr   r$   numpypromote_typesr   float64	functoolsreducer   arrayshapeTreshaper   concatenate_method
isinstancendarray	TypeErrorcharastypefloatRuntimeErroraveragesumr
   r   RuntimeWarningmeandotr)   squeeze)r   r   r   r   r   fweightsaweightsr   Xwavgw_sumfactX_Tr	   s                  r   r   r   S   s   P DCII--/000vzz/000}9'??EEvzz !3444$#!'5=1 E
 	
1AU+++A agajAooCwqzQz"~~%%a+++}JquAU;;; 	!'!*//A$aV!444|qqaA(DL11 	313 3 3>l22*, , ,???//=19; ; ;>!
**>@ @ @(DL11 	313 3 3???//=19; ; ;>!
**>@ @ @9AAMAaaTBBBJC!HE 	ywqzD 			t|tc!H*oo-55qyy9$	4 	4 	4 	4Q4	  Ayc1ui
%%



q4<#5#55
6C;;==r/   )NTNN)r   )NTFNNN)r=   r
   r:   r   r   r   r.   r    r/   r   <module>rZ      s                (D ( ( ( ( (V   < 26 $A/3A A A A A A Ar/   