§
    fŠtjÊK  ã                   ó¸  — d dl Z d dlZd dlZddlmZ ddlmZmZm	Z	m
Z
 ddlmZmZmZmZ g d¢Z G d„ d¦  «        Z ee	d	d
d ¬¦  «        Z	e	j        d„ ¦   «         Ze	j        d„ ¦   «         Z eeddd ¬¦  «        Zej        d„ ¦   «         Zej        d„ ¦   «         Zej        d„ ¦   «         Zej        d„ ¦   «         Z eeddddd ¬¦  «        Zej        d„ ¦   «         Zej        d„ ¦   «         Zej        d„ ¦   «         Z eeddddd ¬¦  «        Zej        d„ ¦   «         Zej        d„ ¦   «         Zej        d „ ¦   «         Zej        d!„ ¦   «         Zej        d"„ ¦   «         Z eed#d$d ¬¦  «        Zej        d%„ ¦   «         Zej        d&„ ¦   «         Z eed'd(d ¬¦  «        Zej        d)„ ¦   «         Zej        d*„ ¦   «         Zej        d+„ ¦   «         Zej        d,„ ¦   «         Z ee
d-d.d/d ¬0¦  «        Z
e
j        d1„ ¦   «         Ze
j        d2„ ¦   «         Z eed3d4d/d ¬0¦  «        Zej        d5„ ¦   «         Zej        d6„ ¦   «         Zej        d7„ ¦   «         Zej        d8„ ¦   «         ZdS )9é    Né   ©Ú_nonneg_int_or_fail)Ú
legendre_pÚassoc_legendre_pÚsph_legendre_pÚ
sph_harm_y)Úlegendre_p_allÚassoc_legendre_p_allÚsph_legendre_p_allÚsph_harm_y_all)r   r   r   r
   r	   r   r   r   c                   ó\   — e Zd Zdddœd„Zed„ ¦   «         Zd„ Zd„ Zd„ Zd	„ Z	d
„ Z
d„ Zd„ ZdS )Ú
MultiUFuncNF)Úforce_complex_outputc                ó¸  — t          |t          j        ¦  «        s÷t          |t          j        j        ¦  «        r|                     ¦   «         }n1t          |t          j        j        ¦  «        r|}nt          d¦  «        ‚t          ¦   «         }|D ]_}t          |t          j        ¦  «        st          d|› �¦  «        ‚| 
                    t          d„ |j        D ¦   «         ¦  «        ¦  «         Œ`t          |¦  «        dk    rt          d¦  «        ‚|| _        || _        || _        || _        || _        d | _        d | _        d | _        d„ | _        d„ | _        d S )Nz7ufunc_or_ufuncs should be a ufunc or a ufunc collectionz2All ufuncs must have type `numpy.ufunc`. Received c              3   óL   K  — | ]}|                      d ¦  «        d         V — Œ dS )z->r   N)Úsplit)Ú.0Úxs     úX/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/scipy/special/_multiufuncs.pyú	<genexpr>z&MultiUFunc.__init__.<locals>.<genexpr>+   s1   è è € Ð.UÐ.UÀA¨q¯wªw°t©}¬}¸QÔ/?Ð.UÐ.UÐ.UÐ.UÐ.UÐ.Uó    r   z*All ufuncs must take the same input types.c                  ó   — dS )N© r   ©ÚargsÚkwargss     r   ú<lambda>z%MultiUFunc.__init__.<locals>.<lambda>7   s   € ¸2€ r   c                  ó   — i S ©Nr   r   s     r   r   z%MultiUFunc.__init__.<locals>.<lambda>8   s   € ¸R€ r   )Ú
isinstanceÚnpÚufuncÚcollectionsÚabcÚMappingÚvaluesÚIterableÚ
ValueErrorÚsetÚaddÚ	frozensetÚtypesÚlenÚ__name__Ú_ufunc_or_ufuncsÚ_MultiUFunc__docÚ!_MultiUFunc__force_complex_outputÚ_default_kwargsÚ_resolve_out_shapesÚ_finalize_outÚ_keyÚ_ufunc_default_argsÚ_ufunc_default_kwargs)	ÚselfÚufunc_or_ufuncsÚnameÚdocr   Údefault_kwargsÚufuncs_iterÚseen_input_typesr#   s	            r   Ú__init__zMultiUFunc.__init__   s~  € å˜/­2¬8Ñ4Ô4ð 	OÝ˜/­;¬?Ô+BÑCÔCð 6Ø-×4Ò4Ñ6Ô6��Ý˜O­[¬_Ô-EÑFÔFð 6Ø-��å ð "5ñ 6ô 6ð 6õ
  #™uœuÐØ$ð Wð W�Ý! %­¬Ñ2Ô2ð EÝ$ð &DØ2Að&Dð &Dñ Eô Eð Eà ×$Ò$¥YÐ.UÐ.UÈÌÐ.UÑ.UÔ.UÑ%UÔ%UÑVÔVÐVÐVÝÐ#Ñ$Ô$ qÒ(Ð(Ý Ð!MÑNÔNÐNàˆŒØ /ˆÔØˆŒ
Ø&:ˆÔ#Ø-ˆÔØ#'ˆÔ Ø!ˆÔØˆŒ	Ø#=Ð#=ˆÔ Ø%?Ð%?ˆÔ"Ð"Ð"r   c                 ó   — | j         S r    )r1   )r9   s    r   Ú__doc__zMultiUFunc.__doc__:   s
   € àŒzÐr   c                 ó   — || _         dS )z3Set `key` method by decorating a function.
        N)r6   ©r9   Úfuncs     r   Ú_override_keyzMultiUFunc._override_key>   s   € ð ˆŒ	ˆ	ˆ	r   c                 ó   — || _         d S r    )r7   rD   s     r   Ú_override_ufunc_default_argsz'MultiUFunc._override_ufunc_default_argsC   s   € Ø#'ˆÔ Ð Ð r   c                 ó   — || _         d S r    )r8   rD   s     r   Ú_override_ufunc_default_kwargsz)MultiUFunc._override_ufunc_default_kwargsF   s   € Ø%)ˆÔ"Ð"Ð"r   c                 ó>   — |j         €d|_         d|_        || _        dS )z9Set `resolve_out_shapes` method by decorating a function.Nz2Resolve to output shapes based on relevant inputs.Úresolve_out_shapes)rB   r/   r4   rD   s     r   Ú_override_resolve_out_shapesz'MultiUFunc._override_resolve_out_shapesI   s)   € àŒ<ÐàHð ŒLà,ˆŒØ#'ˆÔ Ð Ð r   c                 ó   — || _         d S r    )r5   rD   s     r   Ú_override_finalize_outz!MultiUFunc._override_finalize_outQ   s   € Ø!ˆÔÐÐr   c                 ó‚   — t          | j        t          j        ¦  «        r| j        S  | j        di |¤Ž}| j        |         S )z.Resolve to a ufunc based on keyword arguments.r   )r!   r0   r"   r#   r6   )r9   r   Ú	ufunc_keys      r   Ú_resolve_ufunczMultiUFunc._resolve_ufuncT   sI   € õ �dÔ+­R¬XÑ6Ô6ð 	)ØÔ(Ð(à�D”IÐ'Ð' Ð'Ð'ˆ	ØÔ$ YÔ/Ð/r   c                 óR  — | j         |z  }| | j        d	i |¤Žz  } | j        d	i |¤Ž}d„ ||j         d …         D ¦   «         } | j        d	i |¤Ž}| j        ��,t          d„ |D ¦   «         ¦  «        } | j        g |d |j         …         ¢|¢|j        ‘R i |¤Ž}t          d„ |D ¦   «         ¦  «        }t          |d¦  «        r3||j        dz  z   }	| 	                    |	¦  «        }	|	|j         d …         }
nDt          j        |Ž }t          j        |t          j        ¦  «        st          j        }|j        |fz  }
| j        rt          d„ |
D ¦   «         ¦  «        }
t          d„ t!          ||
¦  «        D ¦   «         ¦  «        }||d<    ||i |¤Ž}| j        �|                      |¦  «        }|S )
Nc                 ó6   — g | ]}t          j        |¦  «        ‘ŒS r   )r"   Úasarray)r   Úargs     r   ú
<listcomp>z'MultiUFunc.__call__.<locals>.<listcomp>e   s    € ÐCÐCÐC¨#•b”j ‘o”oÐCÐCÐCr   c              3   ó>   K  — | ]}t          j        |¦  «        V — Œd S r    )r"   Úshape©r   Ú	ufunc_args     r   r   z&MultiUFunc.__call__.<locals>.<genexpr>j   s,   è è € Ð$UÐ$U¸Y¥R¤X¨iÑ%8Ô%8Ð$UÐ$UÐ$UÐ$UÐ$UÐ$Ur   c              3   ó†   K  — | ]<}t          |d ¦  «        r|j        n t          j        t          |¦  «        ¦  «        V — Œ=dS )ÚdtypeN)Úhasattrr]   r"   ÚtyperZ   s     r   r   z&MultiUFunc.__call__.<locals>.<genexpr>o   sh   è è € ð %Bð %Bà)2õ 9@À	È7Ñ8SÔ8Sð &D Y¤_ _Ý*,¬(µ4¸	±?´?Ñ*CÔ*Cð%Bð %Bð %Bð %Bð %Bð %Br   Úresolve_dtypesr    c              3   ó@   K  — | ]}t          j        d |¦  «        V — ŒdS )y              ð?N)r"   Úresult_type)r   Úufunc_out_dtypes     r   r   z&MultiUFunc.__call__.<locals>.<genexpr>   sJ   è è € ð )Rð )RØ-<õ *,¬¸¸OÑ)LÔ)Lð )Rð )Rð )Rð )Rð )Rð )Rr   c              3   óH   K  — | ]\  }}t          j        ||¬ ¦  «        V — ŒdS ))r]   N)r"   Úempty)r   Úufunc_out_shaperc   s      r   r   z&MultiUFunc.__call__.<locals>.<genexpr>‚   sQ   è è € ð Dð DÙ<˜O¨_õ œ ¸ÐHÑHÔHð Dð Dð Dð Dð Dð Dr   Úoutr   )r3   r7   rR   Úninr8   r4   ÚtupleÚnoutr^   r`   r"   rb   Ú
issubdtypeÚinexactÚfloat64r2   Úzipr5   )r9   r   r   r#   Ú
ufunc_argsÚufunc_kwargsÚufunc_arg_shapesÚufunc_out_shapesÚufunc_arg_dtypesÚufunc_dtypesÚufunc_out_dtypesrc   rg   s                r   Ú__call__zMultiUFunc.__call__]   sz  € ØÔ%¨Ñ.ˆàÐ(�Ô(Ð2Ð2¨6Ð2Ð2Ñ2ˆà#�Ô#Ð-Ð- fÐ-Ð-ˆð DÐC°°u´y°j°k°kÔ1BÐCÑCÔCˆ
à1�tÔ1Ð;Ð;°FÐ;Ð;ˆàÔ$Ñ0Ý$Ð$UÐ$UÈ*Ð$UÑ$UÔ$UÑUÔUÐØ7˜tÔ7ð  B¸¸kÀÄ	¸z¸kÔ9Jð  BØ9Ið BØKPÌ:ð Bð  Bð  Bà:@ð Bð  BÐõ  %ð %Bð %Bà6@ð%Bñ %Bô %Bñ  Bô  BÐõ �uÐ.Ñ/Ô/ð 	CØ/°%´*¸wÑ2FÑF�Ø$×3Ò3°LÑAÔA�Ø#/°´°°°Ô#=Ð Ð å"$¤.Ð2BÐ"C�Ýœ oµr´zÑBÔBð 1Ý&(¤j�Oà#(¤:°Ð0BÑ#BÐ àÔ*ð RÝ#(ð )Rð )RØ@Pð)Rñ )Rô )Rñ $Rô $RÐ õ ð Dð DåÐ/Ð1AÑBÔBðDñ Dô Dñ Dô DˆCð #&ˆL˜Ñàˆe�ZÐ0 <Ð0Ð0ˆØÔÐ*Ø×$Ò$ SÑ)Ô)ˆCàˆ
r   )NN)r/   Ú
__module__Ú__qualname__r@   ÚpropertyrB   rF   rH   rJ   rM   rO   rR   rv   r   r   r   r   r      sÀ   € € € € € ð@Ø&+ð@ð @ð @ð @ð @ðB ðð ñ „Xððð ð ð
(ð (ð (ð*ð *ð *ð(ð (ð (ð"ð "ð "ð0ð 0ð 0ð/ð /ð /ð /ð /r   r   r   a¢  sph_legendre_p(n, m, theta, *, diff_n=0)

    Spherical Legendre polynomial of the first kind.

    Parameters
    ----------
    n : ArrayLike[int]
        Degree of the spherical Legendre polynomial. Must have ``n >= 0``.
    m : ArrayLike[int]
        Order of the spherical Legendre polynomial.
    theta : ArrayLike[float]
        Input value.
    diff_n : Optional[int]
        A non-negative integer. Compute and return all derivatives up
        to order ``diff_n``. Default is 0.

    Returns
    -------
    p : ndarray or tuple[ndarray]
        Spherical Legendre polynomial with ``diff_n`` derivatives.

    Notes
    -----
    The spherical counterpart of an (unnormalized) associated Legendre polynomial has
    the additional factor

    .. math::

        \sqrt{\frac{(2 n + 1) (n - m)!}{4 \pi (n + m)!}}

    It is the same as the spherical harmonic :math:`Y_{n}^{m}(\theta, \phi)`
    with :math:`\phi = 0`.
    ©Údiff_nc                 ón   — t          | dd¬¦  «        } d| cxk    rdk    sn t          d| › d�¦  «        ‚| S ©Nr{   F©Ústrictr   é   úGdiff_n is currently only implemented for orders 0, 1, and 2, received: ú.©r   r)   rz   s    r   Ú_r„   ¶   óe   € å  ¨¸%Ð@Ñ@Ô@€FØ�ÐÐÒÐ˜!ÒÐÐÐÝð$Ø ð$ð $ð $ñ
ô 
ð 	
ð €Mr   c                 ó.   — t          j        | dd¦  «        S ©Néÿÿÿÿr   ©r"   Úmoveaxis©rg   s    r   r„   r„   Á   ó   € åŒ;�s˜B Ñ"Ô"Ð"r   r   aì  sph_legendre_p_all(n, m, theta, *, diff_n=0)

    All spherical Legendre polynomials of the first kind up to the
    specified degree ``n``, order ``m``, and all derivatives up
    to order ``diff_n``.

    Output shape is ``(diff_n + 1, n + 1, 2 * m + 1, ...)``. The entry at
    ``(i, j, k)`` corresponds to the ``i``-th derivative, degree ``j``, and
    order ``k`` for all ``0 <= i <= diff_n``, ``0 <= j <= n``, and
    ``-m <= k <= m``.

    See Also
    --------
    sph_legendre_p
    c                 ón   — t          | dd¬¦  «        } d| cxk    rdk    sn t          d| › d�¦  «        ‚| S r}   rƒ   rz   s    r   r„   r„   Û   r…   r   c                 ó   — ddgdgz   iS ©NÚaxesr   )r   r   rˆ   r   rz   s    r   r„   r„   æ   s   € à�R�D˜J˜<Ñ'Ð(Ð(r   c                 óª   — t          | t          j        ¦  «        r| dk     rt          d¦  «        ‚| dz   dt	          |¦  «        z  dz   f|z   |dz   fz   fS )Nr   ú!n must be a non-negative integer.r   r€   )r!   ÚnumbersÚIntegralr)   Úabs)ÚnÚmÚtheta_shaperj   r{   s        r   r„   r„   ë   s^   € å�a�Ô)Ñ*Ô*ð >¨q°1ªu¨uÝÐ<Ñ=Ô=Ð=à�‰U�A�˜A™œ‘J ‘NÐ# kÑ1°V¸a±Z°MÑAÐCÐCr   c                 ó.   — t          j        | dd¦  «        S r‡   r‰   r‹   s    r   r„   r„   ó   rŒ   r   r   a—  assoc_legendre_p(n, m, z, *, branch_cut=2, norm=False, diff_n=0)

    Associated Legendre polynomial of the first kind.

    Parameters
    ----------
    n : ArrayLike[int]
        Degree of the associated Legendre polynomial. Must have ``n >= 0``.
    m : ArrayLike[int]
        order of the associated Legendre polynomial.
    z : ArrayLike[float | complex]
        Input value.
    branch_cut : Optional[ArrayLike[int]]
        Selects branch cut. Must be 2 (default) or 3.
        2: cut on the real axis ``|z| > 1``
        3: cut on the real axis ``-1 < z < 1``
    norm : Optional[bool]
        If ``True``, compute the normalized associated Legendre polynomial.
        Default is ``False``.
    diff_n : Optional[int]
        A non-negative integer. Compute and return all derivatives up
        to order ``diff_n``. Default is 0.

    Returns
    -------
    p : ndarray or tuple[ndarray]
        Associated Legendre polynomial with ``diff_n`` derivatives.

    Notes
    -----
    The normalized counterpart of an (unnormalized) associated Legendre
    polynomial has the additional factor

    .. math::

        \sqrt{\frac{(2 n + 1) (n - m)!}{2 (n + m)!}}
    r€   F©Ú
branch_cutÚnormr{   c                 ór   — t          |dd¬¦  «        }d|cxk    rdk    sn t          d|› d�¦  «        ‚||fS r}   rƒ   rš   s      r   r„   r„   #  sj   € å  ¨¸%Ð@Ñ@Ô@€FØ�ÐÐÒÐ˜!ÒÐÐÐÝð$Ø ð$ð $ð $ñ
ô 
ð 	
ð �ˆ<Ðr   c                 ó   — | fS r    r   rš   s      r   r„   r„   .  ó
   € àˆ;Ðr   c                 ó.   — t          j        | dd¦  «        S r‡   r‰   r‹   s    r   r„   r„   3  rŒ   r   r   a  assoc_legendre_p_all(n, m, z, *, branch_cut=2, norm=False, diff_n=0)

    All associated Legendre polynomials of the first kind up to the
    specified degree ``n``, order ``m``, and all derivatives up
    to order ``diff_n``.

    Output shape is ``(diff_n + 1, n + 1, 2 * m + 1, ...)``. The entry at
    ``(i, j, k)`` corresponds to the ``i``-th derivative, degree ``j``, and
    order ``k`` for all ``0 <= i <= diff_n``, ``0 <= j <= n``, and
    ``-m <= k <= m``.

    See Also
    --------
    assoc_legendre_p
    c                 ó´   — t          |t          j        ¦  «        r|dk    st          d|› d�¦  «        ‚d|cxk    rdk    sn t          d|› d�¦  «        ‚||fS ©Nr   z1diff_n must be a non-negative integer, received: r‚   r€   r�   )r!   r“   r”   r)   rš   s      r   r„   r„   M  s–   € å˜¥Ô 0Ñ1Ô1ð 
Ø˜!’�ÝØIÀÐIÐIÐIñ
ô 
ð 	
ð �ÐÐÒÐ˜!ÒÐÐÐÝð$Ø ð$ð $ð $ñ
ô 
ð 	
ð �ˆ<Ðr   c                 ó   — | fS r    r   rš   s      r   r„   r„   \  rŸ   r   c                 ó   — dddgdgz   iS r�   r   rš   s      r   r„   r„   a  s   € à�R˜�H 
˜|Ñ+Ð,Ð,r   c                 ó>  — |d         }t          | t          j        ¦  «        r| dk     rt          d¦  «        ‚t          |t          j        ¦  «        r|dk     rt          d¦  «        ‚| dz   dt	          |¦  «        z  dz   ft          j        ||¦  «        z   |dz   fz   fS )Nr{   r   r’   z!m must be a non-negative integer.r   r€   ©r!   r“   r”   r)   r•   r"   Úbroadcast_shapes)r–   r—   Úz_shapeÚbranch_cut_shaperj   r   r{   s          r   r„   r„   f  s¯   € à�HÔ€Få�a�Ô)Ñ*Ô*ð >¨q°1ªu¨uÝÐ<Ñ=Ô=Ð=Ý�a�Ô)Ñ*Ô*ð >¨q°1ªu¨uÝÐ<Ñ=Ô=Ð=à�‰U�A�˜A™œ‘J ‘NÐ#Ý
Ô˜GÐ%5Ñ6Ô6ñ7Ø:@À1¹*¸ñGð Ið Ir   c                 ó.   — t          j        | dd¦  «        S r‡   r‰   r‹   s    r   r„   r„   s  rŒ   r   r   a  legendre_p(n, z, *, diff_n=0)

    Legendre polynomial of the first kind.

    Parameters
    ----------
    n : ArrayLike[int]
        Degree of the Legendre polynomial. Must have ``n >= 0``.
    z : ArrayLike[float]
        Input value.
    diff_n : Optional[int]
        A non-negative integer. Compute and return all derivatives up
        to order ``diff_n``. Default is 0.

    Returns
    -------
    p : ndarray or tuple[ndarray]
        Legendre polynomial with ``diff_n`` derivatives.

    See Also
    --------
    legendre

    References
    ----------
    .. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
           Functions", John Wiley and Sons, 1996.
           https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
    c                 ó°   — t          | t          j        ¦  «        r| dk     rt          d| › d�¦  «        ‚d| cxk    rdk    sn t	          d| › d�¦  «        ‚| S r¢   )r!   r“   r”   r)   ÚNotImplementedErrorrz   s    r   r„   r„   ›  s�   € å�v�wÔ/Ñ0Ô0ð 
°f¸q²j°jÝØIÀÐIÐIÐIñ
ô 
ð 	
ð �ÐÐÒÐ˜!ÒÐÐÐÝ!ð$Ø ð$ð $ð $ñ
ô 
ð 	
ð €Mr   c                 ó.   — t          j        | dd¦  «        S r‡   r‰   r‹   s    r   r„   r„   ©  rŒ   r   r
   aŽ  legendre_p_all(n, z, *, diff_n=0)

    All Legendre polynomials of the first kind up to the specified degree
    ``n`` and all derivatives up to order ``diff_n``.

    Output shape is ``(diff_n + 1, n + 1, ...)``. The entry at ``(i, j)``
    corresponds to the ``i``-th derivative and degree ``j`` for all
    ``0 <= i <= diff_n`` and ``0 <= j <= n``.

    See Also
    --------
    legendre_p
    c                 ón   — t          | dd¬¦  «        } d| cxk    rdk    sn t          d| › d�¦  «        ‚| S r}   rƒ   rz   s    r   r„   r„   Á  r…   r   c                 ó   — dddgiS )Nr�   r   )r   rˆ   r   rz   s    r   r„   r„   Ì  s   € à�R˜�MÐ"Ð"r   c                 óN   — t          | dd¬¦  «        } || dz   f|z   |dz   fz   fz  S )Nr–   Fr~   r   r   )r–   r¨   rj   r{   s       r   r„   r„   Ñ  s:   € å˜A˜s¨5Ð1Ñ1Ô1€Aà�A˜‘E�8˜gÑ%¨°!©¨Ñ5Ð7Ñ7Ð7r   c                 ó.   — t          j        | dd¦  «        S r‡   r‰   r‹   s    r   r„   r„   Ø  rŒ   r   r	   aÌ  sph_harm_y(n, m, theta, phi, *, diff_n=0)

    Spherical harmonics. They are defined as

    .. math::

        Y_n^m(\theta,\phi) = \sqrt{\frac{2 n + 1}{4 \pi} \frac{(n - m)!}{(n + m)!}}
            P_n^m(\cos(\theta)) e^{i m \phi}

    where :math:`P_n^m` are the (unnormalized) associated Legendre polynomials.

    Parameters
    ----------
    n : ArrayLike[int]
        Degree of the harmonic. Must have ``n >= 0``. This is
        often denoted by ``l`` (lower case L) in descriptions of
        spherical harmonics.
    m : ArrayLike[int]
        Order of the harmonic.
    theta : ArrayLike[float]
        Polar (colatitudinal) coordinate; must be in ``[0, pi]``.
    phi : ArrayLike[float]
        Azimuthal (longitudinal) coordinate; must be in ``[0, 2*pi]``.
    diff_n : Optional[int]
        A non-negative integer. Compute and return all derivatives up
        to order ``diff_n``. Default is 0.

    Returns
    -------
    y : ndarray[complex] or tuple[ndarray[complex]]
       Spherical harmonics with ``diff_n`` derivatives.

    Notes
    -----
    There are different conventions for the meanings of the input
    arguments ``theta`` and ``phi``. In SciPy ``theta`` is the
    polar angle and ``phi`` is the azimuthal angle. It is common to
    see the opposite convention, that is, ``theta`` as the azimuthal angle
    and ``phi`` as the polar angle.

    Note that SciPy's spherical harmonics include the Condon-Shortley
    phase [2]_ because it is part of `sph_legendre_p`.

    With SciPy's conventions, the first several spherical harmonics
    are

    .. math::

        Y_0^0(\theta, \phi) &= \frac{1}{2} \sqrt{\frac{1}{\pi}} \\
        Y_1^{-1}(\theta, \phi) &= \frac{1}{2} \sqrt{\frac{3}{2\pi}}
                                    e^{-i\phi} \sin(\theta) \\
        Y_1^0(\theta, \phi) &= \frac{1}{2} \sqrt{\frac{3}{\pi}}
                                 \cos(\theta) \\
        Y_1^1(\theta, \phi) &= -\frac{1}{2} \sqrt{\frac{3}{2\pi}}
                                 e^{i\phi} \sin(\theta).

    References
    ----------
    .. [1] Digital Library of Mathematical Functions, 14.30.
           https://dlmf.nist.gov/14.30
    .. [2] https://en.wikipedia.org/wiki/Spherical_harmonics#Condon.E2.80.93Shortley_phase
    T)r   r{   c                 ón   — t          | dd¬¦  «        } d| cxk    rdk    sn t          d| › d�¦  «        ‚| S r}   rƒ   rz   s    r   r„   r„   !  r…   r   c                 ó  — | j         d         dk    r| d         S | j         d         dk    r| d         | dddgddgf         fS | j         d         dk    r-| d         | dddgddgf         | dddgddggddgddggf         fS d S ©Nrˆ   r   ).r   r   r€   .r   é   ©rY   r‹   s    r   r„   r„   ,  óº   € àŒ	�"Œ˜ÒÐØ�9Œ~ÐàŒ	�"Œ˜ÒÐØ�9Œ~˜s 3¨¨A¨°°A°Ð#6Ô7Ð7Ð7àŒ	�"Œ˜ÒÐØ�I”  C¨!¨Q¨°!°Q°Ð$7Ô 8Ø��q˜!�f˜q !˜fÐ%¨¨A¨°°A°Ð'7Ð7Ô8ð:ð 	:ð 	Ðr   r   a˜  sph_harm_y_all(n, m, theta, phi, *, diff_n=0)

    All spherical harmonics up to the specified degree ``n``, order ``m``,
    and all derivatives up to order ``diff_n``.

    Returns a tuple of length ``diff_n + 1`` (if ``diff_n > 0``). The first
    entry corresponds to the spherical harmonics, the second entry
    (if ``diff_n >= 1``) to the gradient, and the third entry
    (if ``diff_n >= 2``)  to the Hessian matrix. Each entry is an array of
    shape ``(n + 1, 2 * m + 1, ...)``, where the entry at ``(i, j)``
    corresponds to degree ``i`` and order ``j`` for all ``0 <= i <= n``
    and ``-m <= j <= m``.

    See Also
    --------
    sph_harm_y
    c                 ón   — t          | dd¬¦  «        } d| cxk    rdk    sn t          d| › d�¦  «        ‚| S )Nr{   Fr~   r   r€   z=diff_n is currently only implemented for orders 2, received: r‚   rƒ   rz   s    r   r„   r„   P  r…   r   c                 ó   — dddgdgz   iS )Nr�   r   )r   r   éþÿÿÿrˆ   r   rz   s    r   r„   r„   [  s   € à�R˜�H Ð/Ñ/Ð0Ð0r   c                 óè   — |d         }t          | t          j        ¦  «        r| dk     rt          d¦  «        ‚| dz   dt	          |¦  «        z  dz   ft          j        ||¦  «        z   |dz   |dz   fz   fS )Nr{   r   r’   r   r€   r¦   )r–   r—   r˜   Ú	phi_shaperj   r   r{   s          r   r„   r„   `  sƒ   € à�HÔ€Få�a�Ô)Ñ*Ô*ð >¨q°1ªu¨uÝÐ<Ñ=Ô=Ð=à�‰U�A�˜A™œ‘J ‘NÐ#¥bÔ&9¸+ÀyÑ&QÔ&QÑQØ	�!‰�V˜a‘ZÐ ñ!ð #ð #r   c                 ó  — | j         d         dk    r| d         S | j         d         dk    r| d         | dddgddgf         fS | j         d         dk    r-| d         | dddgddgf         | dddgddggddgddggf         fS d S r´   r¶   r‹   s    r   r„   r„   k  r·   r   )r$   r“   Únumpyr"   Ú_input_validationr   Ú_special_ufuncsr   r   r   r	   Ú_gufuncsr
   r   r   r   Ú__all__r   rF   r„   rO   rJ   rM   rH   r   r   r   ú<module>rÃ      s„  ðØ Ð Ð Ð Ø €€€Ø Ð Ð Ð à 2Ð 2Ð 2Ð 2Ð 2Ð 2ð:ð :ð :ð :ð :ð :ð :ð :ð :ð :ð :ð :ð;ð ;ð ;ð ;ð ;ð ;ð ;ð ;ð ;ð ;ð ;ð ;ð	ð 	ð 	€ðtð tð tð tð tñ tô tð tðn �ØØð ð@ ðG$ñ $ô $€ðN Ôðð ñ Ôðð Ô&ð#ð #ñ 'Ô&ð#ð  �ZØØðð ð#ñ ô Ð ð* Ô!ðð ñ "Ô!ðð Ô2ð)ð )ñ 3Ô2ð)ð Ô0ðDð Dñ 1Ô0ðDð Ô*ð#ð #ñ +Ô*ð#ð �:ØØð$ðH ˜E¨!ðO(ñ (ô (Ð ðV Ôðð ñ  Ôðð Ô.ðð ñ /Ô.ðð Ô(ð#ð #ñ )Ô(ð#ð "�zØØðð ˜E¨!ð#ñ ô Ð ð* Ô#ðð ñ $Ô#ðð Ô2ðð ñ 3Ô2ðð Ô4ð-ð -ñ 5Ô4ð-ð Ô2ð	Ið 	Iñ 3Ô2ð	Ið Ô,ð#ð #ñ -Ô,ð#ð ˆZØØðð8 ð? ñ  ô  €
ðF Ôð
ð 
ñ Ôð
ð Ô"ð#ð #ñ #Ô"ð#ð �ØØðð ðñ ô €ð& Ôðð ñ Ôðð Ô.ð#ð #ñ /Ô.ð#ð Ô,ð8ð 8ñ -Ô,ð8ð Ô&ð#ð #ñ 'Ô&ð#ð ˆZØØð=ðz #¨1ðAAñ Aô A€
ðH Ôðð ñ Ôðð Ô"ð	:ð 	:ñ #Ô"ð	:ð �ØØðð  #¨1ð'ñ ô €ð. Ôðð ñ Ôðð Ô.ð1ð 1ñ /Ô.ð1ð Ô,ð#ð #ñ -Ô,ð#ð Ô&ð	:ð 	:ñ 'Ô&ð	:ð 	:ð 	:r   