§
    `ƒi.  ã                   óh   — d Z ddlmZ ddlmZ ddlmZ eez   dz   Z ej        ddded	¬
¦  «        Z	dS )z©
The source code here is an adaptation with minimal changes from the following
SciPy Cython file:

https://github.com/scipy/scipy/blob/master/scipy/special/sph_harm.pxd
é    )Ú_core)Úpoch_definition)Úlpmv_definitiona{  

#include <cupy/complex.cuh>

// include for CUDART_NAN, CUDART_INF
#include <cupy/math_constants.h>

#define NPY_PI        3.141592653589793238462643383279502884  /* pi */

// from scipy/special/sph_harm.pxd
__device__ complex<double> sph_harmonic(int m, int n, double theta, double phi)
{
    double x, prefactor;
    complex<double> val;
    int mp;

    x = cos(phi);
    if (abs(m) > n)
    {
        // sf_error.error("sph_harm", sf_error.ARG,
        //                "m should not be greater than n")
        return CUDART_NAN;
    }
    if (n < 0)
    {
        // sf_error.error("sph_harm", sf_error.ARG, "n should not be negative")
        return CUDART_NAN;
    }
    if (m < 0)
    {
        mp = -m;
        prefactor = poch(n + mp + 1, -2 * mp);
        if ((mp % 2) == 1)
        {
            prefactor = -prefactor;
        }
    }
    else
    {
        mp = m;
    }
    val = pmv_wrap(mp, n, x);
    if (m < 0)
    {
        val *= prefactor;
    }
    val *= sqrt((2*n + 1) / 4.0 / NPY_PI);
    val *= sqrt(poch(n + m + 1, -2 * m));

    complex<double> exponent(0, m * theta);
    val *= exp(exponent);

    return val;
}
Úcupyx_scipy_lpmv)ziiff->Fziidd->Dzllff->Fzlldd->Dz3out0 = out0_type(sph_harmonic(in0, in1, in2, in3));zJSpherical Harmonic.

    .. seealso:: :meth:`scipy.special.sph_harm`

    )ÚpreambleÚdocN)
Ú__doc__Úcupyr   Úcupyx.scipy.special._pochr   Úcupyx.scipy.special._lpmvr   Úsph_harmonic_definitionÚcreate_ufuncÚsph_harm© ó    úq/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupyx/scipy/special/_sph_harm.pyú<module>r      s”   ððð ð Ð Ð Ð Ð Ð à 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5ð Øñð6ñ8ð ðz ˆ5ÔØØ0Ø9Ø$ð	ð
ñ 
ô 
€€€r   