
    `i                     Z   d Z ddlZddlmZ ddlZddlmZ ddlmZm	Z	 	 ddl
mZ ej        Z[n"# e$ r  G d d          Z e            ZY nw xY wd	d
gZ ej        d          Z ej        ej                  dd            Z ej        ej                  dd            ZddZddZdS )z{Fast Hankel transforms using the FFTLog algorithm.
The implementation closely follows the Fortran code of Hamilton (2000).
    N)warn)_fft)loggammapoch)fhtc                       e Zd Zd ZdS )_DummyModulec                     d S )N )selfnames     k/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupyx/scipy/fft/_fftlog.py__getattr__z_DummyModule.__getattr__   s    4    N)__name__
__module____qualname__r   r   r   r   r	   r	      s#        	 	 	 	 	r   r	   r   ifht           c                 B   | j         d         }|dk    r=|dz
  dz  }t          j        |          }| t          j        | ||z
  z  |z            z  } t	          |||||          }t          | |          }	|dk    r$|	t          j        | ||z
  |z  |z   z            z  }	|	S )a  Compute the fast Hankel transform.

    Computes the discrete Hankel transform of a logarithmically spaced periodic
    sequence using the FFTLog algorithm [1]_, [2]_.

    Parameters
    ----------
    a : cupy.ndarray (..., n)
        Real periodic input array, uniformly logarithmically spaced.  For
        multidimensional input, the transform is performed over the last axis.
    dln : float
        Uniform logarithmic spacing of the input array.
    mu : float
        Order of the Hankel transform, any positive or negative real number.
    offset : float, optional
        Offset of the uniform logarithmic spacing of the output array.
    bias : float, optional
        Exponent of power law bias, any positive or negative real number.

    Returns
    -------
    A : cupy.ndarray (..., n)
        The transformed output array, which is real, periodic, uniformly
        logarithmically spaced, and of the same shape as the input array.

    See Also
    --------
    :func:`scipy.special.fht`
    :func:`scipy.special.fhtoffset` : Return an optimal offset for `fht`.

    References
    ----------
    .. [1] Talman J. D., 1978, J. Comp. Phys., 29, 35
    .. [2] Hamilton A. J. S., 2000, MNRAS, 312, 257 (astro-ph/9905191)

    r      r   offsetbiasshapecupyarangeexpfhtcoeff_fhtq)
adlnmur   r   nj_cjuAs
             r   r   r       s    P 	
A qyysAgKNN$C,--- 	CF666A 	aA qyy	TXtea#gs]V34555Hr   c                 D   | j         d         }|dk    r?|dz
  dz  }t          j        |          }| t          j        |||z
  |z  |z   z            z  } t	          |||||          }t          | |d          }	|dk    r!|	t          j        | ||z
  z  |z            z  }	|	S )aP  Compute the inverse fast Hankel transform.

    Computes the discrete inverse Hankel transform of a logarithmically spaced
    periodic sequence. This is the inverse operation to `fht`.

    Parameters
    ----------
    A : cupy.ndarray (..., n)
        Real periodic input array, uniformly logarithmically spaced.  For
        multidimensional input, the transform is performed over the last axis.
    dln : float
        Uniform logarithmic spacing of the input array.
    mu : float
        Order of the Hankel transform, any positive or negative real number.
    offset : float, optional
        Offset of the uniform logarithmic spacing of the output array.
    bias : float, optional
        Exponent of power law bias, any positive or negative real number.

    Returns
    -------
    a : cupy.ndarray (..., n)
        The transformed output array, which is real, periodic, uniformly
        logarithmically spaced, and of the same shape as the input array.

    See Also
    --------
    :func:`scipy.special.ifht`
    :func:`scipy.special.fhtoffset` : Return an optimal offset for `fht`.

    r   r   r   r   r   T)inverser   )
r+   r%   r&   r   r   r'   r(   r)   r*   r$   s
             r   r   r   _   s    F 	
A qyy1ukKNN!c'S6!9:;;; 	CF666A 	aD!!!A qyy	TXteq3w'#-...Hr   c                    ||}}|dz   |z   dz  }|dz   |z
  dz  }t          j        dt          j        | dz  z  | |z  z  | dz  dz             }	t          j        | dz  dz   t
                    }
t          j        | dz  dz   t
                    }|	|
j        dd<   ||
j        dd<   t          |
|           ||
j        dd<   t          |
|
           |	dt          |z
  z  z  }	|
xj        |j        z  c_        |
xj        t          |z  z  c_        |
xj        |j        z  c_        |
xj        |	z  c_        t          j
        |
|
           d|
j        d<   t          j        |
d                   sd|z  t          |||z
            z  |
d<   |
S )z?Compute the coefficient array for a fast Hankel transform.
    r   r   r   )dtypeN)outr   )r   linspacemathpiemptycompleximagrealr   LN_2r!   isfiniter   )r'   r%   r&   r   r   lnkrqxpxmyr*   vs               r   r"   r"      s    d!D
 q&1*aB
q&1*aBaAF+q3w7a!DDA
16A:W---A
16A:W---AAF111IAF111IQAAF111IQAdTk	AFFafFFFFdQhFFFFafFFFFaKFFHQA AF2J =1 ( !td2rBw'''! Hr   Fc                    | j         d         }t          j        |d                   r+|s)t          d           |                                }d|d<   n@|d         dk    r4|r2t          d           |                                }t          j        |d<   t          j        | d          }|s||z  }n||                                z  }t          j	        ||d          }|ddddf         }|S )zUCompute the biased fast Hankel transform.

    This is the basic FFTLog routine.
    r   r   z.singular transform; consider changing the biasz6singular inverse transform; consider changing the bias)axis.N)
r   r   isinfr   copyinfr   rfftconjirfft)r$   r*   r-   r'   r+   s        r   r#   r#      s     	
A z!A$ 	 	=>>>FFHH!	
1wEFFFFFHHx! 		!"A 	Q 	
QVVXX
1ab!!!A	#ttt)AHr   )r   r   )F)__doc__r2   warningsr   r   cupyx.scipy.fftr   cupyx.scipy.specialr   r   	scipy.fftr   _fht
_scipy_fftImportErrorr	   __all__logr8   _implementsr   r"   r#   r   r   r   <module>rS      s                        . . . . . . . .
 %%%%%%J              JJJ  &/ tx{{ *.!!; ; ; "!;| */""6 6 6 #"6r% % % %P           s   / AA