
    
9j                    n    S SK Jr  S SKrS SKrS SKrS SKrS SKJr  SSS.S jjrS	S jr  S
SS.S jjr	g)    )annotationsN)_coredtypec                   Uc  Ub  [         R                  " S[        5        [        XX%S9n [        R
                  " U5      n[        R                  " UR                  5      nXhSS2S4   -  nXhSSS24   -  n[        R                  " UR                  SSUR                  S9  [        R                  " U5      (       a+  [        R                  " UR                  SSUR                  S9  U$ ! [         a    Xf-  s $ f = f)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	            V/home/wildlama/miniconda3/lib/python3.13/site-packages/cupy/_statistics/correlation.pycorrcoefr      s    , 4+G(	* aF
(CIIcN YYqvvF!T'?C$'?CIIchhA388,		#((Bsxx0J  ys   C, ,C=<C=c                0   U R                   S:X  d  UR                   S:X  a  [        S5      eU R                  S:w  d  UR                  S:w  a  [        S5      e[        R                  R
                  R                  XU5      nUS:X  a@  [        R                  R
                  R                  XR                  5       SSS2   U5      nU$ US:X  a@  [        R                  R
                  R                  XR                  5       SSS2   U5      nU$ [        S	5      e)
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.   7   s     	vv{affk:;;vv{affk<== ZZ__00t<Fjjoo++Avvx"~tD
 J	 
5jjoo++Avvx"~tD J -..    c                  Ub  U[        U5      :w  a  [        S5      eU R                  S:  a  [        S5      eUc  Uc0  [        R                  " U R
                  [        R                  5      nOeUR                  S:  a  [        S5      e[        R                  " [        R                  U R
                  UR
                  [        R                  45      n[        R                  " U SUS9nU(       d  U R                  S:w  a  UR                  nUR                  S   S:X  a&  [        R                  " / 5      R                  SS5      $ UbS  [        R                  " USSUS	9nU(       d  UR                  S   S:w  a  UR                  n[        R                  " X4SS
9nUc  U(       a  SOSnSn	Ub  [!        U[        R"                  5      (       d  [%        S5      eUR
                  R&                  S;  a  [%        S5      eUR)                  [*        S9nUR                  S:  a  [-        S5      eUR                  S   UR                  S   :w  a  [-        S5      eUn	Ub  [!        U[        R"                  5      (       d  [%        S5      eUR)                  [*        S9nUR                  S:  a  [-        S5      eUR                  S   UR                  S   :w  a  [-        S5      eU	c  Un	OX-  n	[        R.                  " USU	SS9u  pUS   nU	c  UR                  S   U-
  nO&US:X  a  UnOUc  X-
  nOX[1        X-  5      -  U-  -
  nUS::  a  [2        R4                  " S[6        SS9  SnXR9                  SS
9SS2S4   -  nU	c  UR                  nOX-  R                  nUR;                  UR=                  5       5      U-  nUR?                  5       $ )a  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   )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Tshape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   U   sg   P DCI-/00vvz/00}9''?Evvz !344$$##!''5==1E
 	

1AU+AaffkCCwwqzQzz"~%%a++}JJqt1E:!''!*/A$$aV!4|qaA(DLL1113 3>>l2*, ,???/==19; ;>>!
*>@ @(DLL1113 3???/==19; ;>>!
*>@ @9AMAaaTBJC!HE 	ywwqzD 			|c!*o-55qy9$	4Q4	  Ayccuii
%%

d
"C;;=r/   )NTNN)valid)NTFNNN)

__future__r   r=   r   r:   r   r   r   r.   r    r/   r   <module>r\      s@    "     (D (V< 26 $A/3Ar/   