| Server IP : 217.160.0.135 / Your IP : 216.73.217.37 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/scipy/special/__pycache__/ |
Upload File : |
�
d�c�_ � �d � d dl Z d dlZd dlZd dlZd dlmZmZmZmZm Z m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZmZ ddlmZ ddlmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ ddlm%Z% ddl&m'Z' g d�Z(dHd
�Z)d� Z*d� Z+d
� Z,d� Z-d� Z.d� Z/d� Z0dId�Z1dId�Z2dId�Z3d� Z4dJd�Z5dJd�Z6dJd�Z7dJd�Z8dJd�Z9dJd�Z:d� Z;d� Z<d� Z=d � Z>d!� Z?d"� Z@dKd$�ZAeZBd%� ZCd&� ZDd'� ZEd(� ZFdLd*�ZGd+� ZHd,� ZId-� ZJd.� ZKd/� ZLd0� ZMd1� ZNd2� ZOd3� ZPd4� ZQd5� ZRd6� ZSd7� ZTd8� ZUd9� ZVd:� ZWd;� ZXd<� ZYd=� ZZd>� Z[d?� Z\d@� Z]dMdA�Z^dIdB�Z_dC� Z`dIdD�ZadIdE�ZbdHdF�ZcdNdG�ZddS )O� N)�pi�asarray�floor�isscalar� iscomplex�real�imag�sqrt�where�mgrid�sin�place�
issubdtype�extract�inexact�nan�zeros�sinc� )�_ufuncs)� mathieu_a� mathieu_b�iv�jv�gamma�psi�hankel1�hankel2�yv�kv�poch�binom)�_specfun)� _comb_int):�ai_zeros�assoc_laguerre� bei_zeros�
beip_zeros� ber_zeros� bernoulli�
berp_zeros�bi_zeros�clpmn�comb�digamma�diric� erf_zeros�euler� factorial�
factorial2�
factorialk�
fresnel_zeros�fresnelc_zeros�fresnels_zeros�h1vp�h2vp�ivp�jn_zeros�jnjnp_zeros� jnp_zeros�
jnyn_zeros�jvp� kei_zeros�
keip_zeros�kelvin_zeros� ker_zeros�
kerp_zeros�kvp�lmbda�lpmn�lpn�lqmn�lqn�mathieu_even_coef�mathieu_odd_coef�
obl_cv_seq�pbdn_seq�pbdv_seq�pbvv_seq�perm� polygamma�
pro_cv_seq�
riccati_jn�
riccati_ynr �y0_zeros�y1_zeros� y1p_zeros�yn_zeros� ynp_zeros�yvp�zetaTc �F � |rt j | � � } n1| t | � � k rt | � � } nt � � �| dk rt � � �nB# t t
f$ r.}|� d� |� � � � |�d }~ww xY w| S )Nr z!{} must be a non-negative integer)�operator�indexr �int�
ValueError� TypeError� __class__�format)�n�var_name�strict�errs �6/usr/lib/python3/dist-packages/scipy/special/_basic.py�_nonneg_int_or_failrk Q s� � �[�� ���q�!�!�A�A�
�%��(�(�]�]��A���A�A��,�,���q�5�5��,�,�� ��� �"� [� [� [��m�m�?�F�F�x�P�P�Q�Q�WZ�Z�����[�����Hs �AA �B�0)B�Bc
�� � t | � � t |� � }} t || | z
z � � }t | ||z
z � � } t | j t � � r| j }nt }t | j |� � }t j |� � j dk rd}n"t j |� � j dk rd}nd}|dk |t |� � k z }t ||t � � | dz } t | � � }d|z
t |� � |k z }t || � � }t ||� � } |t z }
t ||t# d t j |
� � | dz
z � � � � d|z
d|z
z }t || � � }t ||� � } t ||� � }t ||t | |z � � | |z z � � |S )
a# Periodic sinc function, also called the Dirichlet function.
The Dirichlet function is defined as::
diric(x, n) = sin(x * n/2) / (n * sin(x / 2)),
where `n` is a positive integer.
Parameters
----------
x : array_like
Input data
n : int
Integer defining the periodicity.
Returns
-------
diric : ndarray
Examples
--------
>>> import numpy as np
>>> from scipy import special
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(-8*np.pi, 8*np.pi, num=201)
>>> plt.figure(figsize=(8, 8));
>>> for idx, n in enumerate([2, 3, 4, 9]):
... plt.subplot(2, 2, idx+1)
... plt.plot(x, special.diric(x, n))
... plt.title('diric, n={}'.format(n))
>>> plt.show()
The following example demonstrates that `diric` gives the magnitudes
(modulo the sign and scaling) of the Fourier coefficients of a
rectangular pulse.
Suppress output of values that are effectively 0:
>>> np.set_printoptions(suppress=True)
Create a signal `x` of length `m` with `k` ones:
>>> m = 8
>>> k = 3
>>> x = np.zeros(m)
>>> x[:k] = 1
Use the FFT to compute the Fourier transform of `x`, and
inspect the magnitudes of the coefficients:
>>> np.abs(np.fft.fft(x))
array([ 3. , 2.41421356, 1. , 0.41421356, 1. ,
0.41421356, 1. , 2.41421356])
Now find the same values (up to sign) using `diric`. We multiply
by `k` to account for the different scaling conventions of
`numpy.fft.fft` and `diric`:
>>> theta = np.linspace(0, 2*np.pi, m, endpoint=False)
>>> k * special.diric(theta, k)
array([ 3. , 2.41421356, 1. , -0.41421356, -1. ,
-0.41421356, 1. , 2.41421356])
g�C��]r2<g�dy���=gV瞯�<gH�����z>g����MbP?r � r ���)r r �dtyper �floatr �shape�np�finfo�epsr r r r
�absr r �pow�round)
�xrf �ytype�y�minval�mask1�denom�mask2�xsub�nsub�zsub�mask�dsubs
rj r0 r0 a s� � �B �1�:�:�w�q�z�z�q�A���Q�q�S� ���A���Q�q�S� ���A��!�'�7�#�#� �������
�a�g�u���A�
�x�����U�"�"���� ��%��� �u� $� $������
�!�V��U�1�X�X�
�&�E� �!�U�C���� �A��A���F�F�E�
�u�W��U���f�,�-�E��5�!���D��5�!���D��"�9�D� �!�U�C��B�H�T�N�N�D��F�3�4�4�5�5�5�
�e�G��%�� �D��4����D��4����D��4����D� �!�T�3�t�D�y�>�>�4��9�-�.�.�.��H� c � � t | � � rt | � � | k s| dk rt d� � �t | � � } t j | � � \ }}}}|d| dz � |d| � |d| � |d| � fS )a Compute zeros of integer-order Bessel functions Jn and Jn'.
Results are arranged in order of the magnitudes of the zeros.
Parameters
----------
nt : int
Number (<=1200) of zeros to compute
Returns
-------
zo[l-1] : ndarray
Value of the lth zero of Jn(x) and Jn'(x). Of length `nt`.
n[l-1] : ndarray
Order of the Jn(x) or Jn'(x) associated with lth zero. Of length `nt`.
m[l-1] : ndarray
Serial number of the zeros of Jn(x) or Jn'(x) associated
with lth zero. Of length `nt`.
t[l-1] : ndarray
0 if lth zero in zo is zero of Jn(x), 1 if it is a zero of Jn'(x). Of
length `nt`.
See Also
--------
jn_zeros, jnp_zeros : to get separated arrays of zeros.
References
----------
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
Functions", John Wiley and Sons, 1996, chapter 5.
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
i� zNumber must be integer <= 1200.r N)r r rb ra r# �jdzo)�ntrf �m�t�zos rj r= r= � s� � �D �B�<�<� <�E�"�I�I��O�O��d����:�;�;�;� �R���B��-��#�#�K�A�q�!�R�
�a��1��f�:�q��"��v�q��"��v�q��"��v�-�-r� c �4 � t |� � rt | � � st d� � �t | � � | k st |� � |k rt d� � �|dk rt d� � �t j t | � � |� � S )a� Compute nt zeros of Bessel functions Jn(x), Jn'(x), Yn(x), and Yn'(x).
Returns 4 arrays of length `nt`, corresponding to the first `nt`
zeros of Jn(x), Jn'(x), Yn(x), and Yn'(x), respectively. The zeros
are returned in ascending order.
Parameters
----------
n : int
Order of the Bessel functions
nt : int
Number (<=1200) of zeros to compute
Returns
-------
Jn : ndarray
First `nt` zeros of Jn
Jnp : ndarray
First `nt` zeros of Jn'
Yn : ndarray
First `nt` zeros of Yn
Ynp : ndarray
First `nt` zeros of Yn'
See Also
--------
jn_zeros, jnp_zeros, yn_zeros, ynp_zeros
References
----------
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
Functions", John Wiley and Sons, 1996, chapter 5.
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
Examples
--------
Compute the first three roots of :math:`J_1`, :math:`J_1'`,
:math:`Y_1` and :math:`Y_1'`.
>>> from scipy.special import jnyn_zeros
>>> jn_roots, jnp_roots, yn_roots, ynp_roots = jnyn_zeros(1, 3)
>>> jn_roots, yn_roots
(array([ 3.83170597, 7.01558667, 10.17346814]),
array([2.19714133, 5.42968104, 8.59600587]))
Plot :math:`J_1`, :math:`J_1'`, :math:`Y_1`, :math:`Y_1'` and their roots.
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.special import jnyn_zeros, jvp, jn, yvp, yn
>>> jn_roots, jnp_roots, yn_roots, ynp_roots = jnyn_zeros(1, 3)
>>> fig, ax = plt.subplots()
>>> xmax= 11
>>> x = np.linspace(0, xmax)
>>> ax.plot(x, jn(1, x), label=r"$J_1$", c='r')
>>> ax.plot(x, jvp(1, x, 1), label=r"$J_1'$", c='b')
>>> ax.plot(x, yn(1, x), label=r"$Y_1$", c='y')
>>> ax.plot(x, yvp(1, x, 1), label=r"$Y_1'$", c='c')
>>> zeros = np.zeros((3, ))
>>> ax.scatter(jn_roots, zeros, s=30, c='r', zorder=5,
... label=r"$J_1$ roots")
>>> ax.scatter(jnp_roots, zeros, s=30, c='b', zorder=5,
... label=r"$J_1'$ roots")
>>> ax.scatter(yn_roots, zeros, s=30, c='y', zorder=5,
... label=r"$Y_1$ roots")
>>> ax.scatter(ynp_roots, zeros, s=30, c='c', zorder=5,
... label=r"$Y_1'$ roots")
>>> ax.hlines(0, 0, xmax, color='k')
>>> ax.set_ylim(-0.6, 0.6)
>>> ax.set_xlim(0, xmax)
>>> ax.legend(ncol=2, bbox_to_anchor=(1., 0.75))
>>> plt.tight_layout()
>>> plt.show()
�Arguments must be scalars.zArguments must be integers.r znt > 0)r rb r r# �jyzoru �rf r� s rj r? r? � s� � �V
�R�L�L� 7�X�a�[�[� 7��5�6�6�6�
�a���A�
�
�5��9�9��?�?��6�7�7�7�
�a�����"�"�"��=��Q����$�$�$r� c �. � t | |� � d S )a/ Compute zeros of integer-order Bessel functions Jn.
Compute `nt` zeros of the Bessel functions :math:`J_n(x)` on the
interval :math:`(0, \infty)`. The zeros are returned in ascending
order. Note that this interval excludes the zero at :math:`x = 0`
that exists for :math:`n > 0`.
Parameters
----------
n : int
Order of Bessel function
nt : int
Number of zeros to return
Returns
-------
ndarray
First `nt` zeros of the Bessel function.
See Also
--------
jv: Real-order Bessel functions of the first kind
jnp_zeros: Zeros of :math:`Jn'`
References
----------
.. [1] Zhang, Shanjie and Jin, Jianming. "Computation of Special
Functions", John Wiley and Sons, 1996, chapter 5.
https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
Examples
--------
Compute the first four positive roots of :math:`J_3`.
>>> from scipy.special import jn_zeros
>>> jn_zeros(3, 4)
array([ 6.3801619 , 9.76102313, 13.01520072, 16.22346616])
Plot :math:`J_3` and its first four positive roots. Note
that the root located at 0 is not returned by `jn_zeros`.
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.special import jn, jn_zeros
>>> j3_roots = jn_zeros(3, 4)
>>> xmax = 18
>>> xmin = -1
>>> x = np.linspace(xmin, xmax, 500)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, jn(3, x), label=r'$J_3$')
>>> ax.scatter(j3_roots, np.zeros((4, )), s=30, c='r',
... label=r"$J_3$_Zeros", zorder=5)
>>> ax.scatter(0, 0, s=30, c='k',
... label=r"Root at 0", zorder=5)
>>> ax.hlines(0, 0, xmax, color='k')
>>> ax.set_xlim(xmin, xmax)
>>> plt.legend()
>>> plt.show()
r �r? r� s rj r<