o
    Ö­j¸  ã                   @   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 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)ÚfhtÚifhtÚ	fhtoffsetç        c              	   C   s®   t | ƒ}| | ¡} | jd }|dkr.|d d }|j||jd�}| | | ||  | ¡ } | t|||||d�¡}	t| |	|d�}
|dkrU|
| | || | |  ¡9 }
|
S )Néÿÿÿÿr   r   r   ©Údtype)ÚoffsetÚbias©Úxp©r	   ÚasarrayÚshapeÚarangeÚfloat64ÚexpÚfhtcoeffÚ_fhtq)ÚaÚdlnÚmur   r   r   ÚnÚj_cÚjÚuÚA© r%   úV/var/www/html/CropPilot/venv/lib/python3.10/site-packages/scipy/fft/_fftlog_backend.pyr
      s   

 r
   c              
   C   s°   t | ƒ}| | ¡} | jd }|dkr/|d d }|j||jd�}| | ||| | |  ¡ } | t|||||dd�¡}	t| |	d|d�}
|dkrV|
| | ||  | ¡ }
|
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 dkršd|jd< t  
|d ¡s®d| t|	||	 ƒ |d< t  |d ¡rÈ|sÈtdd	d
� t  |¡}d|d< |S |d dkrà|ràt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)ÚnpÚlinspaceÚpiÚemptyÚcomplexÚimagÚrealr   ÚLN_2r   Úisfiniter   Úisinfr   ÚcopyÚinf)r    r   r   r   r   r'   ÚlnkrÚqr   ÚxmÚyr#   Úvr%   r%   r&   r   F   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   r2   r0   Úround)r   r   Úinitialr   r7   r8   r   r9   r:   ÚzpÚzmÚargr%   r%   r&   r   y   s   
.r   r   c                C   s^   |du rt }| jd }t| dd�}|s||9 }n|| |¡ }t||dd�}|j|dd�}|S )zUCompute the biased fast Hankel transform.

    This is the basic FFTLog routine.
    Nr   )Úaxis)r+   r   r   Úconjr   Úflip)r   r#   r'   r   r    r$   r%   r%   r&   r   ²   s   

r   )r   r   )r   r   F)F)Únumpyr+   Úwarningsr   Ú_basicr   r   Úspecialr   r   Úscipy._lib._array_apir	   Ú__all__Úlogr2   r
   r   r   r   r   r%   r%   r%   r&   Ú<module>   s    




39