
    `iR
                     v    d dl Z d dl mZ dZ ej        ddde          Z ej        ddd	e          ZddZdS )    N)_coreaA  
#include <cupy/math_constants.h>

__device__ double spherical_yn_real(int n, double x) {
    double s, s0, s1;

    if (isnan(x))
        return x;
    if (x < 0) {
        if (n % 2 == 0)
            return -spherical_yn_real(n, -x);
        else
            return spherical_yn_real(n, -x);
    }
    if (isinf(x))
        return 0;
    if (x == 0)
        return -CUDART_INF;

    s0 = -cos(x) / x;
    if (n == 0) {
        return s0;
    }
    s1 = (s0 - sin(x)) / x;
    for (int k = 2; k <= n; ++k) {
        s = (2.0 * k - 1.0) * s1 / x - s0;
        if (isinf(s)) {
            return s;
        }
        s0 = s1;
        s1 = s;
    }

    return s1;
}

__device__ double spherical_yn_d_real(int n, double x) {
    double s, s0, s1;

    if (isnan(x))
        return x;
    if (x < 0) {
        if (n % 2 == 0)
            return -spherical_yn_d_real(n, -x);
        else
            return spherical_yn_d_real(n, -x);
    }
    if (isinf(x))
        return 0;
    if (x == 0)
        return CUDART_INF;

    if (n == 1) {
        return (sin(x) + cos(x) / x) / x;
    }
    s0 = -cos(x) / x;
    s1 = (s0 - sin(x)) / x;
    for (int k = 2; k <= n; ++k) {
        s = (2.0 * k - 1.0) * s1 / x - s0;
        if (isinf(s)) {
            return s;
        }
        s0 = s1;
        s1 = s;
    }

    return s0 - (n + 1.0) * s1 / x;
}
cupyx_scipy_spherical_yn_real)zif->dzid->dz-out0 = out0_type(spherical_yn_real(in0, in1)))preamblecupyx_scipy_spherical_dyn_realz0out0 = out0_type(spherical_yn_d_real(in0, in1));Fc                     t          j        |          r|rt          t          |rt          | |          S t	          | |          S )a  Spherical Bessel function of the second kind or its derivative.

    Parameters
    ----------
    n : cupy.ndarray
        Order of the Bessel function.
    z : cupy.ndarray
        Argument of the Bessel function.
        Real-valued input.
    derivative : bool, optional
        If True, the value of the derivative (rather than the function
        itself) is returned.

    Returns
    -------
    yn : cupy.ndarray

    See Also
    -------
    :func:`scipy.special.spherical_yn`

    )cupyiscomplexobjNotImplementedError_spherical_dyn_real_spherical_yn_real)nz
derivatives      y/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/cupyx/scipy/special/_spherical_bessel.pyspherical_ynr   Y   sS    .  	, 	&%%%% 	,&q!,,,%a+++    )F)r   r   spherical_bessel_preamblecreate_ufuncr   r   r    r   r   <module>r      s          D L (U'#3&	    )e($6&	    ,  ,  ,  ,  ,  ,r   