L iddlZddlmZddlmZmZddlmZm Z ddl m Z gdZ ejdZdd Zdd Zdd Zdd Zddd dZy)N)warn)rfftirfft)loggammapoch)array_namespace)fhtifht fhtoffsetc t|}|j|}|jd}|dk7rC|dz dz }|j||j}||j | ||z z|zz}|jt |||||} t|| |} |dk7r!| |j | z |z|zzz} | S)Nrrrdtype)offsetbiasxpr asarrayshapearangefloat64expfhtcoeff_fhtq) adlnmurrrnj_cjuAs _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/scipy/fft/_fftlog_backend.pyr r s  B 1 A  A qysAg IIarzzI * ua#gs*+ + 8AsBvDABA arA qy RVVTEAGS=612 33 Hc t|}|j|}|jd}|dk7rE|dz dz }|j||j}||j |||z |z|zzz}|jt |||||d} t|| d|} |dk7r| |j | z z|zz} | S) NrrrrrT)rrinverse)r)rr) r%rr rrrr!r"r#r$rs r&r r *s  B 1 A  A qysAg IIarzzI * ta#gs]V345 5 8AsBvD$OPA aDR(A qy RVVTE1s7OC' (( Hr'cv||}}|dz|zdz }|dz|z dz } tjdtj|dzz||zz |dzdz} tj|dzdzt} tj|dzdzt} | | j dd| | j ddt| | || j ddt| | | dt|z zz} | xj | j zc_| xj t|zz c_| xj | j z c_| xj | z c_tj| | |dzdk(rd| j d<tj| dsd|zt| || z z| d<tj| dr+|s)tdd tj| } d| d<| S| ddk(r7|r5td d tj| } tj| d<| S) z:Compute the coefficient array for a fast Hankel transform.rrrrN)outrz.singular transform; consider changing the bias) stacklevelz6singular inverse transform; consider changing the bias)nplinspacepiemptycompleximagrealrLN_2risfiniter isinfrcopyinf) r!rr rrr)lnkrqrxmyr$vs r&rrFsd!D Q$q&!B Q$q&!B Aruuad|QsU+QT!V4A Aaw'A Aaw'AAFF1IAFF1I QAAFF1I QAD4KAFFaffFFFd1fFFFaffFFFaKFFF1! 1uzr  ;;qt !td2r"uo%!  xx!~g =!L GGAJ! H 1w ERST GGAJvv! Hr'cP||}}|dz|zdz }|dz|z dz }tjd|zz }t|d|zz} t|d|zz} t|z |z | j| jztjz z} || tj | z |zzS)aReturn 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) rry?)r.r0rr5r3round) rr initialrr:r;rr<r=zpzmargs r&r r ys\t!D Q$q&!B Q$q&!B qu A "r!t) B "r!t) B $; rww0"%%7 7C 3#&+ ++r'rc|t}|jd}t|d}|s||z}n||j|z}t ||d}|j |d}|S)zUCompute the biased fast Hankel transform. This is the basic FFTLog routine. r)axis)r.rrconjrflip)rr$r)rr!r%s r&rrso  z   A QRA  Q RWWQZ aA A Hr')rI)rIrIF)F)numpyr.warningsr_basicrrspecialrr scipy._lib._array_apir __all__logr5r r rr rr'r&rRsL$1 &rvvay 8 80 f6,r T r'