← Back
Editing: gammainc_data.cpython-311.pyc
� d�c� � � � d Z ddlZddlmZ ddlZddlmZ ddlmZ ddlZ n# e $ r Y nw xY wdd�Zdd �Zd � Z edk r e � � dS dS ) a� Compute gammainc and gammaincc for large arguments and parameters and save the values to data files for use in tests. We can't just compare to mpmath's gammainc in test_mpmath.TestSystematic because it would take too long. Note that mpmath's gammainc is computed using hypercomb, but since it doesn't allow the user to increase the maximum number of terms used in the series it doesn't converge for many arguments. To get around this we copy the mpmath implementation but use more terms. This takes about 17 minutes to run on a 2.3 GHz Macbook Pro with 4GB ram. Sources: [1] Fredrik Johansson and others. mpmath: a Python library for arbitrary-precision floating-point arithmetic (version 0.19), December 2013. http://mpmath.org/. � N)�time)�pi)� mpf2float�2 � �c �l ��� � t j |� � 5 t j | � � t j |� � t j |� � c}} �|g�t j �d�� � � ��� fd�}t j ||g|�� � }t |� � cddd� � S # 1 swxY w Y dS )z�Compute gammainc exactly like mpmath does but allow for more summands in hypercomb. See mpmath/functions/expintegrals.py#L134 in the mpmath github repository. T��exactc �V �� t j �� � �| gd| dgg �dgd| z g�f}|fS )N� �����mp�exp)�z�T1�G�b�negbs ����I/usr/lib/python3/dist-packages/scipy/special/_precompute/gammainc_data.py�hzgammainc.<locals>.h/ s; �� ��&��,�,��1�%��1�b�z�2�q�1�#��!��u�a�G�B��5�L� ��maxtermsN)r �workdps�mpf�fneg� hypercombr ) �a�x�dpsr r r �resr r r s @@@r �gammaincr# ! s ���� � ��C��� � ��&��)�)�R�V�A�Y�Y���q� � ���1�a� �C���w�q��%�%�%�� � � � � � � � �l�1�q�c�H�5�5�5����~�~� � � � � � � � � � � � ���� � � � � � s �BB)�)B-�0B-c �\ � ��� t j |� � 5 � |c}� t j |� � rK t t j |� d�� � � � cddd� � S # t j j $ r Y nw xY wt j � d�� � �|g� �� �fd�}t t j ||gd�� � � � cddd� � S # t j j $ r; �� �fd�}t t j ||g|�� � � � cY cddd� � S w xY w# 1 swxY w Y dS ) z�Compute gammaincc exactly like mpmath does but allow for more terms in hypercomb. See mpmath/functions/expintegrals.py#L187 in the mpmath github repository. T)r �regularizedNr c �Z �� | dz }t j �� � �gd|gg �d| gg d�z fgS )Nr r )r �rr r �negas ���r r zgammaincc.<locals>.hM s? �� ��a�C���&��,�,��*�Q��F�B��A��r�7�B��$��O�P�Pr )�force_seriesc �x �� g d| dz g| g�g g df}t j �� � �| gd| dgg �dgd| z g�f}||fS )Nr r r r )r r �T2r r r( s ���r r zgammaincc.<locals>.hR s] �� ��!�Q�q�S��A�3��2�r�1�4���v�d�|�|�m�Q��*�Q��2�J��A��s�Q�q�S�E�1�L���2�v� r r ) r r �isintr r# �libmp� NoConvergencer r )r r r! r r r r r( s ` @@r � gammainccr/ 7 s* ���� � ��C��� F� F��!���1� �8�A�;�;� � � ���Q�!��!F�!F�!F�G�G� F� F� F� F� F� F� F� F�� �8�)� � � ��� �����w�q��%�%�%�� �C�� F� Q� Q� Q� Q� Q� Q� Q� �R�\�!�a�S�t�D�D�D�E�E�!F� F� F� F� F� F� F� F��"