o
    oh&                     @   s  U d dl Z d dlmZmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlmZ ddlmZ dd	lmZmZmZmZmZmZmZmZ m!Z"m#Z$m%Z&m'Z(m)Z*m+Z,m-Z.m/Z0m1Z2m3Z4m5Z6m7Z8m9Z:m;Z<m=Z>m?Z@mAZB g d
ZCg dZDdd ZEdZFdd ZGdd ZHe jIJddK ZLdZMdZNeLdv reGeLZMeMdurdZLndZLeLdv reHeLZNeNdurdZLndZLeLdvred dZLddee d > d ZOee	df ePd< eLdkr6eNdusJ dZQeNZRdZSdZTeUeVeRWd fZXeRjWZYeRjZZ[eRjZeRjZeRjZeRj\ZeRj]ZeRj#Z#eRj^ZeRjZeRjZeRj!Z!eRj%Z%eRj'Z'eRj)Z)eRj+Z+d d! Z-eRj/Z/eRj1Z1eRj3Z3eRj5Z5eRj7Z7eRj9Z9eRj;Z;eRj=Z=eRj?Z?eRjAZAdS eLdkreMdusBJ eMZQdZRd ZSdZTeUeQj_fZXeQj_ZYeQj`Z[eZeZeZeZd"d# Zd$d% Z#d&d' Zd(d) Zd*d+ Ze"Z!e&Z%e(Z'd,d- Z)e,Z+d.d! Z-e0Z/e2Z1e4Z3e6Z5e8Z7e:Z9e<Z;e>Z=e@Z?eBZAdS eLdkrdZQdZRd ZSdZTeUfZXeUZYeZ[eZeZeZeZeZe$Z#eZeZe Ze"Z!e&Z%e(Z'e*Z)e,Z+e.Z-e0Z/e2Z1e4Z3e6Z5e8Z7e:Z9e<Z;e>Z=e@Z?eBZAdS J )/    N)c_longsizeof)reduce)TupleType)warn)import_module   )	PythonMPQ)	bit_scan1	bit_scan0remove	factorialsqrtsqrtremgcdlcmgcdext	is_squareinvertlegendrejacobi	kroneckerirootis_fermat_prpis_euler_prpis_strong_prpis_fibonacci_prpis_lucas_prpis_selfridge_prpis_strong_lucas_prpis_strong_selfridge_prpis_bpsw_prpis_strong_bpsw_prp)GROUND_TYPESHAS_GMPY
SYMPY_INTSMPQMPZr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   )z0.6z0.7z0.8z0.9c                 C   s,   |  dd d \}}| d| }|tv S )N.   )split_PYTHON_FLINT_VERSION_NEEDED)flint_versionmajorminor	flint_ver r1   g/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/external/gmpy.py_flint_version_okayb   s   r3   z2.0.0c                 C   s|   | dvrd S zdd l }ddl m} W n ty$   | dkr!td Y d S w t|r+|S | dkr1d S td| dt d	 |S )
Nautoflintr   )__version__r6   zjSYMPY_GROUND_TYPES was set to flint but python-flint is not installed. Falling back to other ground types.r5   zUsing python-flint zp because SYMPY_GROUND_TYPES is set to flint but this version of SymPy is only tested with python-flint versions r)   )r6   r7   ImportErrorr   r3   r,   )sympy_ground_typesr6   _flint_versionr1   r1   r2   
_get_flintm   s$   

r;   c                 C   s8   | dvrd S t dtddd}| dkr|d u rtd |S )Nr5   gmpygmpy2r>   versionr1   )min_module_versionmodule_version_attrmodule_version_attr_call_argsr5   zBgmpy2 library is not installed, switching to 'python' ground types)r   _GMPY2_MIN_VERSIONr   )r9   r=   r1   r1   r2   
_get_gmpy2   s   rD   SYMPY_GROUND_TYPESr5   r4   r6   r<   r=   python)r6   r=   rF   zmSYMPY_GROUND_TYPES environment variable unrecognised. Should be 'auto', 'flint', 'gmpy', 'gmpy2' or 'python'.   .r&   r*   c                 C   s   |t kr
t| |S t| |S N)LONG_MAXr=   r   python_iroot)xnr1   r1   r2   r      s   
r   c                 C      t |  S rH   )r6   fmpzisqrtrK   r1   r1   r2   r        r   c                 C   s"   | dk rdS t |  d dkS )Nr   Fr	   r6   rN   r   rP   r1   r1   r2   r     s   r   c                 C   rM   rH   rR   rP   r1   r1   r2   r   
  rQ   r   c                  G      t tjj| tdS )Nr   )r   r6   rN   r   argsr1   r1   r2   r        r   c                  G   rS   )Nr	   )r   r6   rN   r   rT   r1   r1   r2   r     rV   r   c                 C   s(   |dks|d st dt| |S )Nr   r*   z#y should be an odd positive integer)
ValueErrorr6   rN   r   )rK   yr1   r1   r2   r     s   r   c                 C   s2   |t krt| |}||| | kfS t| |S rH   )rI   r6   rN   rootrJ   )rK   rL   rX   r1   r1   r2   r     s   
)aosctypesr   r   	functoolsr   typingr   tTupler   warningsr   sympy.externalr   	pythonmpqr
   ntheoryr   python_bit_scan1r   python_bit_scan0r   python_remover   python_factorialr   python_sqrtr   python_sqrtremr   
python_gcdr   
python_lcmr   python_gcdextr   python_is_squarer   python_invertr   python_legendrer   python_jacobir   python_kroneckerr   rJ   r   python_is_fermat_prpr   python_is_euler_prpr   python_is_strong_prpr   python_is_fibonacci_prpr   python_is_lucas_prpr   python_is_selfridge_prpr    python_is_strong_lucas_prpr!   python_is_strong_selfridge_prpr"   python_is_bpsw_prpr#   python_is_strong_bpsw_prp__all__r,   r3   rC   r;   rD   environgetlower_SYMPY_GROUND_TYPES_flint_gmpyrI   __annotations__r6   r=   r%   r$   inttypempzr&   r(   mpqr'   facrO   	isqrt_remrN   fmpqr1   r1   r1   r2   <module>   s  
 l7




