Ë
    ÏÍ:j±X  ã                   óè  — 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y)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                   óT   — 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y)Ú
MultiUFuncNF)Úforce_complex_outputc                óÖ  — t        |t        j                  «      sät        |t        j                  j
                  «      r|j                  «       }n2t        |t        j                  j                  «      r|}nt        d«      ‚t        «       }|D ]U  }t        |t        j                  «      st        d|› �«      ‚|j                  t        d„ |j                  D «       «      «       ŒW t        |«      dkD  rt        d«      ‚|| _        || _        || _        || _        || _        d | _        d | _        d | _        d„ | _        d„ | _        |r|j1                  d«      d	   | _        y d | _        y )
Nz7ufunc_or_ufuncs should be a ufunc or a ufunc collectionz2All ufuncs must have type `numpy.ufunc`. Received c              3   óD   K  — | ]  }|j                  d «      d   –— Œ y­w)z->r   N)Úsplit)Ú.0Úxs     úo/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/scipy/special/_multiufuncs.pyú	<genexpr>z&MultiUFunc.__init__.<locals>.<genexpr>+   s   è ø€ Ò.UÀA¨q¯w©w°t«}¸QÕ/?Ñ.Uùs   ‚ r   z*All ufuncs must take the same input types.c                   ó   — y)N© r   ©ÚargsÚkwargss     r   ú<lambda>z%MultiUFunc.__init__.<locals>.<lambda>7   s   � ó    c                  ó   — i S ©Nr   r   s     r   r   z%MultiUFunc.__init__.<locals>.<lambda>8   s   € ¸R€ r   z

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_kwargsr   Ú__text_signature__)	ÚselfÚufunc_or_ufuncsÚnameÚdocr   Údefault_kwargsÚufuncs_iterÚseen_input_typesr#   s	            r   Ú__init__zMultiUFunc.__init__   sK  € ä˜/¬2¯8©8Ô4Ü˜/¬;¯?©?×+BÑ+BÔCØ-×4Ñ4Ó6‘Ü˜O¬[¯_©_×-EÑ-EÔFØ-‘ä ð "5ó 6ð 6ô
  #›uÐØ$ò W�Ü! %¬¯©Ô2Ü$ð &2Ø2AÐ1Bð&Dó Eð Eà ×$Ñ$¤YÑ.UÈÏÉÔ.UÓ%UÕVð	Wô
 Ð#Ó$ qÒ(Ü Ð!MÓNÐNàˆŒØ /ˆÔØˆŒ
Ø&:ˆÔ#Ø-ˆÔØ#'ˆÔ Ø!ˆÔØˆŒ	Ù#=ˆÔ Ù%?ˆÔ"Ù:= #§)¡)¨FÓ"3°AÑ"6ˆÕÀ4ˆÕr   c                 ó   — | j                   S r    )r1   )r:   s    r   Ú__doc__zMultiUFunc.__doc__;   s   € à�z‰zÐr   c                 ó   — || _         y)z3Set `key` method by decorating a function.
        N)r6   ©r:   Úfuncs     r   Ú_override_keyzMultiUFunc._override_key?   s   € ð ˆ�	r   c                 ó   — || _         y r    )r7   rE   s     r   Ú_override_ufunc_default_argsz'MultiUFunc._override_ufunc_default_argsD   s
   € Ø#'ˆÕ r   c                 ó   — || _         y r    )r8   rE   s     r   Ú_override_ufunc_default_kwargsz)MultiUFunc._override_ufunc_default_kwargsG   s
   € Ø%)ˆÕ"r   c                 óF   — |j                   €d|_         d|_        || _        y)z9Set `resolve_out_shapes` method by decorating a function.Nz2Resolve to output shapes based on relevant inputs.Úresolve_out_shapes)rC   r/   r4   rE   s     r   Ú_override_resolve_out_shapesz'MultiUFunc._override_resolve_out_shapesJ   s%   € à�<‰<ÐàHð ŒLà,ˆŒØ#'ˆÕ r   c                 ó   — || _         y r    )r5   rE   s     r   Ú_override_finalize_outz!MultiUFunc._override_finalize_outR   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   )r:   r   Ú	ufunc_keys      r   Ú_resolve_ufunczMultiUFunc._resolve_ufuncU   sH   € ô �d×+Ñ+¬R¯X©XÔ6Ø×(Ñ(Ð(à�D—I‘IÑ' Ñ'ˆ	Ø×$Ñ$ YÑ/Ð/r   c                 ó¸  — | j                   |z  }| | j                  di |¤Žz  } | j                  di |¤Ž}||j                   d  D �cg c]  }t	        j
                  |«      ‘Œ }} | j                  di |¤Ž}| j                  ��*t        d„ |D «       «      } | j                  g |d |j                    ¢|¢|j                  ‘­i |¤Ž}t        d„ |D «       «      }	t        |d«      r4|	|j                  dz  z   }
|j                  |
«      }
|
|j                   d  }nVt	        j                  |	Ž }t	        j                  |t        j                  «      st        j                  }|j                  |fz  }| j                   rt        d„ |D «       «      }t        d„ t#        ||«      D «       «      }||d<    ||i |¤Ž}| j$                  �| j%                  |«      }|S c c}w )	Nc              3   óF   K  — | ]  }t        j                  |«      –— Œ y ­wr    )r"   Úshape©r   Ú	ufunc_args     r   r   z&MultiUFunc.__call__.<locals>.<genexpr>k   s   è ø€ Ò$U¸Y¤R§X¡X¨i×%8Ñ$Uùs   ‚!c              3   óˆ   K  — | ]:  }t        |d «      r|j                  nt        j                  t        |«      «      –— Œ< y­w)ÚdtypeN)ÚhasattrrZ   r"   ÚtyperW   s     r   r   z&MultiUFunc.__call__.<locals>.<genexpr>p   s>   è ø€ ò %Bà)2ô 9@À	È7Ô8S Y§_¢_Ü*,¯(©(´4¸	³?Ó*Có&Dñ %Bùs   ‚A AÚresolve_dtypesr    c              3   óH   K  — | ]  }t        j                  d |«      –— Œ y­w)y              ð?N)r"   Úresult_type)r   Úufunc_out_dtypes     r   r   z&MultiUFunc.__call__.<locals>.<genexpr>€   s%   è ø€ ò )RØ-<ô *,¯©¸¸O×)Lñ )Rùs   ‚ "c              3   óP   K  — | ]  \  }}t        j                  ||¬ «      –— Œ  y­w))rZ   N)r"   Úempty)r   Úufunc_out_shaper`   s      r   r   z&MultiUFunc.__call__.<locals>.<genexpr>ƒ   s,   è ø€ ò DÙ<˜O¨_ô Ÿ™ ¸×HÐHñ Dùs   ‚$&Úoutr   )r3   r7   rS   Úninr"   Úasarrayr8   r4   ÚtupleÚnoutr[   r]   r_   Ú
issubdtypeÚinexactÚfloat64r2   Úzipr5   )r:   r   r   r#   ÚargÚ
ufunc_argsÚufunc_kwargsÚufunc_arg_shapesÚufunc_out_shapesÚufunc_arg_dtypesÚufunc_dtypesÚufunc_out_dtypesr`   rd   s                 r   Ú__call__zMultiUFunc.__call__^   s  € Ø×%Ñ%¨Ñ.ˆàÐ(�×(Ñ(Ñ2¨6Ñ2Ñ2ˆà#�×#Ñ#Ñ- fÑ-ˆð 26°u·y±y°j°kÐ1BÖC¨#”b—j‘j •oÐCˆ
ÐCà1�t×1Ñ1Ñ;°FÑ;ˆà×$Ñ$Ñ0Ü$Ñ$UÈ*Ô$UÓUÐØ7˜t×7Ñ7ð  B¸¸kÀÇ	Á	¸zÐ9Jð  BØ9Ið BØKPÏ:É:ò Bà:@ñ BÐô  %ñ %Bà6@ô%Bó  BÐô �uÐ.Ô/Ø/°%·*±*¸wÑ2FÑF�Ø$×3Ñ3°LÓA�Ø#/°·±°°Ð#=Ñ ä"$§.¡.Ð2BÐ"C�ÜŸ™ o´r·z±zÔBÜ&(§j¡j�Oà#(§:¡:°Ð0BÑ#BÐ à×*Ò*Ü#(ñ )RØ@Pô)Ró $RÐ ô ñ DäÐ/Ð1AÓBôDó DˆCð #&ˆL˜Ñá�ZÐ0 <Ñ0ˆØ×ÑÐ*Ø×$Ñ$ SÓ)ˆCàˆ
ùòO Ds   Á	G)NN)r/   Ú
__module__Ú__qualname__rA   ÚpropertyrC   rG   rI   rK   rN   rP   rS   ru   r   r   r   r   r      sI   „ ð HØ&+ô HðD ñó ðòò
(ò*ò(ò"ò0ó/r   r   r   a   sph_legendre_p(n, m, theta, *, diff_n=0)

    Spherical Legendre polynomial of the first kind.

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

    Returns
    -------
    ndarray or tuple of 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                 óZ   — t        | dd¬«      } d| cxk  rdk  sn t        d| › d�«      ‚| S ©Nrz   F©Ústrictr   é   úGdiff_n is currently only implemented for orders 0, 1, and 2, received: ú.©r   r)   ry   s    r   Ú_rƒ   ·   óB   € ä  ¨¸%Ô@€FØ�Ô˜!ÔÜðØ ˜ ð$ó
ð 	
ð €Mr   c                 ó0   — t        j                  | dd«      S ©Néÿÿÿÿr   ©r"   Úmoveaxis©rd   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`.

    Parameters
    ----------
    n : int
        Degree of the spherical Legendre polynomials. Must have ``n >= 0``.
    m : int
        Order of the spherical Legendre polynomials.
    theta : array_like
        Input value.
    diff_n : int, optional
        A non-negative integer. Compute and return all derivatives up
        to order `diff_n`. Default is 0.

    Returns
    -------
    ndarray
        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                 óZ   — t        | dd¬«      } d| cxk  rdk  sn t        d| › d�«      ‚| S r|   r‚   ry   s    r   rƒ   rƒ   ë   r„   r   c                 ó   — ddgdgz   iS ©NÚaxesr   )r   r   r‡   r   ry   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_shaperh   rz   s        r   rƒ   rƒ   û   sR   € ä�aœ×)Ñ)Ô*¨q°1ªuÜÐ<Ó=Ð=à�‰U�Aœ˜A›‘J ‘NÐ# kÑ1°V¸a±Z°MÑAÐCÐCr   c                 ó0   — t        j                  | dd«      S r†   rˆ   rŠ   s    r   rƒ   rƒ     r‹   r   r   aY  assoc_legendre_p(n, m, z, *, branch_cut=2, norm=False, diff_n=0)

    Associated Legendre polynomial of the first kind.

    Defined as

    .. math::

        P_n^m(z) = (-1)^m (1 - z^2)^{m/2}
            \frac{d^m}{dz^m} P_n(z)

    where :math:`P_n` is the Legendre polynomial.

    This definition includes the Condon-Shortley phase :math:`(-1)^m`.

    Parameters
    ----------
    n : array_like of ints
        Degree of the associated Legendre polynomial. Must have ``n >= 0``.
    m : array_like of ints
        Order of the associated Legendre polynomial.
    z : array_like
        Input value.
    branch_cut : array_like of ints, optional
        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 : bool, optional
        If ``True``, compute the normalized associated Legendre polynomial.
        Default is ``False``.
    diff_n : int, optional
        A non-negative integer. Compute and return all derivatives up
        to order ``diff_n``. Default is 0.

    Returns
    -------
    ndarray or tuple of 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)!}}

    Examples
    --------
    Evaluate :math:`P_2^1(z)` on :math:`[-1, 1]`:

    >>> import numpy as np
    >>> from scipy.special import assoc_legendre_p
    >>> z = np.linspace(-1, 1, 11)
    >>> expected = -3 * z * np.sqrt(1 - z**2)
    >>> np.allclose(assoc_legendre_p(2, 1, z), expected)
    True

    Compute the normalized associated Legendre polynomial:

    >>> scale = np.sqrt(5/12)
    >>> np.allclose(assoc_legendre_p(2, 1, z, norm=True), scale * expected)
    True
    r   F©Ú
branch_cutÚnormrz   c                 ó^   — t        |dd¬«      }d|cxk  rdk  sn t        d|› d�«      ‚||fS r|   r‚   r™   s      r   rƒ   rƒ   O  sG   € ä  ¨¸%Ô@€FØ�Ô˜!ÔÜðØ ˜ ð$ó
ð 	
ð �ˆ<Ðr   c                 ó   — | fS r    r   r™   s      r   rƒ   rƒ   Z  ó
   € àˆ;Ðr   c                 ó0   — t        j                  | dd«      S r†   rˆ   rŠ   s    r   rƒ   rƒ   _  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`.

    Parameters
    ----------
    n : int
        Degree of the associated Legendre polynomials. Must have ``n >= 0``.
    m : int
        Order of the associated Legendre polynomials.
    z : array_like
        Input value.
    branch_cut : array_like of ints, optional
        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 : bool, optional
        If ``True``, compute the normalized associated Legendre polynomials.
        Default is ``False``.
    diff_n : int, optional
        A non-negative integer. Compute and return all derivatives up
        to order ``diff_n``. Default is 0.

    Returns
    -------
    ndarray
        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ƒ   �  sk   € ä˜¤× 0Ñ 0Ô1Ø˜!’ÜØ?À¸xÀqÐ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ƒ   £  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 )Nrz   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_shaperh   r   rz   s          r   rƒ   rƒ   ¨  s™   € à�HÑ€Fä�aœ×)Ñ)Ô*¨q°1ªuÜÐ<Ó=Ð=Ü�aœ×)Ñ)Ô*¨q°1ªuÜÐ<Ó=Ð=à�‰U�Aœ˜A›‘J ‘NÐ#Ü
×Ñ˜GÐ%5Ó6ñ7Ø:@À1¹*¸ñGð Ið Ir   c                 ó0   — t        j                  | dd«      S r†   rˆ   rŠ   s    r   rƒ   rƒ   µ  r‹   r   r   až  legendre_p(n, z, *, diff_n=0)

    Legendre polynomial of the first kind.

    Parameters
    ----------
    n : array_like of ints
        Degree of the Legendre polynomial. Must have ``n >= 0``.
    z : array_like
        Input value.
    diff_n : int, optional
        A non-negative integer. Compute and return all derivatives up
        to order ``diff_n``. Default is 0.

    Returns
    -------
    p : ndarray or tuple of 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

    Examples
    --------
    Evaluate the Legendre polynomial :math:`P_3` at :math:`z = 0.5`:

    >>> import numpy as np
    >>> from scipy.special import legendre_p
    >>> np.allclose(legendre_p(3, 0.5), -0.4375)
    True

    Compute the value and first derivative with respect to ``z``:

    >>> p, dp = legendre_p(3, 0.5, diff_n=1)
    >>> np.allclose([p, dp], [-0.4375, 0.375])
    True
    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)   ÚNotImplementedErrorry   s    r   rƒ   rƒ   ì  se   € ä�vœw×/Ñ/Ô0°f¸q²jÜØ?À¸xÀqÐIó
ð 	
ð �Ô˜!ÔÜ!ðØ ˜ ð$ó
ð 	
ð €Mr   c                 ó0   — 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`.

    Parameters
    ----------
    n : int
        Degree of the Legendre polynomials. Must have ``n >= 0``.
    z : array_like
        Input value.
    diff_n : int, optional
        A non-negative integer. Compute and return all derivatives up
        to order ``diff_n``. Default is 0.

    Returns
    -------
    ndarray
        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                 óZ   — t        | dd¬«      } d| cxk  rdk  sn t        d| › d�«      ‚| S r|   r‚   ry   s    r   rƒ   rƒ     r„   r   c                 ó   — dddgiS )Nr�   r   )r   r‡   r   ry   s    r   rƒ   rƒ   *  s   € à�R˜�MÐ"Ð"r   c                 óF   — t        | dd¬«      } || dz   f|z   |dz   fz   fz  S )Nr•   Fr}   r   r   )r•   r§   rh   rz   s       r   rƒ   rƒ   /  s4   € ä˜A˜s¨5Ô1€Aà�A˜‘E�8˜gÑ%¨°!©¨Ñ5Ð7Ñ7Ð7r   c                 ó0   — t        j                  | dd«      S r†   rˆ   rŠ   s    r   rƒ   rƒ   6  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 : array_like of ints
        Degree of the harmonic. Must have ``n >= 0``. This is
        often denoted by ``l`` (lower case L) in descriptions of
        spherical harmonics.
    m : array_like of ints
        Order of the harmonic.
    theta : array_like
        Polar (colatitudinal) coordinate; must be in ``[0, pi]``.
    phi : array_like
        Azimuthal (longitudinal) coordinate; must be in ``[0, 2*pi]``.
    diff_n : int, optional
        A non-negative integer. Compute and return all derivatives up
        to order `diff_n`. Default is 0.

    Returns
    -------
    ndarray or tuple of ndarray
       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   rz   c                 óZ   — t        | dd¬«      } d| cxk  rdk  sn t        d| › d�«      ‚| S r|   r‚   ry   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 y ©Nr‡   r   ).r   r   r   .r   é   ©rV   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`.

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

    Returns
    -------
    ndarray or tuple of ndarray
        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                 óZ   — t        | dd¬«      } d| cxk  rdk  sn t        d| › d�«      ‚| S )Nrz   Fr}   r   r   z=diff_n is currently only implemented for orders 2, received: r�   r‚   ry   s    r   rƒ   rƒ   Ã  r„   r   c                 ó   — dddgdgz   iS )Nr�   r   )r   r   éþÿÿÿr‡   r   ry   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 )Nrz   r   r‘   r   r   r¥   )r•   r–   r—   Ú	phi_shaperh   r   rz   s          r   rƒ   rƒ   Ó  sw   € à�HÑ€Fä�aœ×)Ñ)Ô*¨q°1ªuÜÐ<Ó=Ð=à�‰U�Aœ˜A›‘J ‘NÐ#¤b×&9Ñ&9¸+ÀyÓ&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 y r³   rµ   rŠ   s    r   rƒ   rƒ   Þ  r¶   r   )r$   r’   Únumpyr"   Ú_input_validationr   Ú_special_ufuncsr   r   r   r	   Ú_gufuncsr
   r   r   r   Ú__all__r   rG   rƒ   rP   rK   rN   rI   r   r   r   ú<module>rÂ      sè  ðÛ Û Û å 2÷:ó :÷;ó ;ò	€÷uñ uñp ØØð ð@ ôG$€ðN ×Ññó ðð ×&Ñ&ñ#ó 'ð#ñ  ØØðð: ôA!Ð ðH ×!Ñ!ñó "ðð ×2Ñ2ñ)ó 3ð)ð ×0Ñ0ñDó 1ðDð ×*Ñ*ñ#ó +ð#ñ ØØð@ð@ ˜E¨!ôGDÐ ðN ×Ññó  ðð ×.Ñ.ñó /ðð ×(Ñ(ñ#ó )ð#ñ "ØØð$ðH ˜E¨!ôO(Ð ðV ×#Ñ#ñó $ðð ×2Ñ2ñó 3ðð ×4Ñ4ñ-ó 5ð-ð ×2Ñ2ñ	Ió 3ð	Ið ×,Ñ,ñ#ó -ð#ñ ØØð+ðV ô]/€
ðd ×Ññ
ó ð
ð ×"Ñ"ñ#ó #ð#ñ ØØðð2 ô9€ð@ ×Ññó ðð ×.Ñ.ñ#ó /ð#ð ×,Ñ,ñ8ó -ð8ð ×&Ñ&ñ#ó 'ð#ñ ØØð?ð~ #¨1ôEC€
ðL ×Ññó ðð ×"Ñ"ñ	:ó #ð	:ñ ØØð#ðF #¨1ôM'€ðT ×Ññó ðð ×.Ñ.ñ1ó /ð1ð ×,Ñ,ñ#ó -ð#ð ×&Ñ&ñ	:ó 'ñ	:r   