a
    BCCfu                     @   s   d dl Zd dlmZ ddlmZmZ ddlmZm	Z	 d dl
mZmZ g dZedZdd
dZdddZdddZdddZdddddZdS )    N)warn   )rfftirfft   )loggammapoch)array_namespacecopy)fhtifht	fhtoffset        c              	   C   s   t | }| jd }|dkrR|d d }|j||jd}| || ||  |  } |t|||||d}	t| |	|d}
|dkr|
|| || | |  9 }
|
S )Nr   r   r   Zdtype)offsetbiasxpr	   shapeZarangeZfloat64expZasarrayfhtcoeff_fhtq)adlnmur   r   r   nj_cjuA r"   U/var/www/html/django/DPS/env/lib/python3.9/site-packages/scipy/fft/_fftlog_backend.pyr      s    
 r   c              
   C   s   t | }| jd }|dkrT|d d }|j||jd}| |||| | |   } |t|||||dd}	t| |	d|d}
|dkr|
|| ||  |  }
|
S )	Nr   r   r   r   r   T)r   r   inverse)r$   r   r   )r!   r   r   r   r   r   r   r   r   r    r   r"   r"   r#   r   )   s    
r   Fc                 C   s  || }}|d | d }|d | d }	t dt j| d  | |  | d d }
t j| d d td}t j| d d td}|
|jdd< |	|jdd< t||d ||jdd< t||d |
dt|  9 }
| j|j8  _| jt| 7  _| j|j7  _| j|
7  _t j	||d d|jd< t 
|d sRd| t|	||	  |d< t |d r|stdd	d
 t|}d|d< n2|d dkr|rtdd	d
 t|}t j|d< |S )z:Compute the coefficient array for a fast Hankel transform.r   r   r   r   N)outr   z.singular transform; consider changing the bias   )
stacklevelz6singular inverse transform; consider changing the bias)npZlinspacepiemptycompleximagrealr   LN_2r   isfiniter   isinfr   r
   inf)r   r   r   r   r   r$   lnkrqr   xmyr    vr"   r"   r#   r   D   s:    
(


r   c                 C   s   || }}|d | d }|d | d }t jd|   }t|d|  }	t|d|  }
t| |  |	j|
j t j  }||t | |   S )a  Return optimal offset for a fast Hankel transform.

    Returns an offset close to `initial` that fulfils the low-ringing
    condition of [1]_ for the fast Hankel transform `fht` with logarithmic
    spacing `dln`, order `mu` and bias `bias`.

    Parameters
    ----------
    dln : float
        Uniform logarithmic spacing of the transform.
    mu : float
        Order of the Hankel transform, any positive or negative real number.
    initial : float, optional
        Initial value for the offset. Returns the closest value that fulfils
        the low-ringing condition.
    bias : float, optional
        Exponent of power law bias, any positive or negative real number.

    Returns
    -------
    offset : float
        Optimal offset of the uniform logarithmic spacing of the transform that
        fulfils a low-ringing condition.

    Examples
    --------
    >>> from scipy.fft import fhtoffset
    >>> dln = 0.1
    >>> mu = 2.0
    >>> initial = 0.5
    >>> bias = 0.0
    >>> offset = fhtoffset(dln, mu, initial, bias)
    >>> offset
    0.5454581477676637

    See Also
    --------
    fht : Definition of the fast Hankel transform.

    References
    ----------
    .. [1] Hamilton A. J. S., 2000, MNRAS, 312, 257 (astro-ph/9905191)

    r   r   y              ?)r(   r)   r   r.   r,   round)r   r   initialr   r2   r3   r   r4   r5   ZzpZzmargr"   r"   r#   r   v   s    .
r   r   c                C   s^   |du rt }| jd }t| dd}|s0||9 }n||| }t||dd}|j|dd}|S )zUCompute the biased fast Hankel transform.

    This is the basic FFTLog routine.
    Nr   )Zaxis)r(   r   r   Zconjr   flip)r   r    r$   r   r   r!   r"   r"   r#   r      s    

r   )r   r   )r   r   )r   r   F)r   r   )F)numpyr(   warningsr   Z_basicr   r   Zspecialr   r   Zscipy._lib._array_apir	   r
   __all__logr.   r   r   r   r   r   r"   r"   r"   r#   <module>   s   



2
9