o
    GZŽhØ  ã                   @   sR   d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 e	G dd„ deeƒƒZ
dS )	z0Implementation of :class:`FractionField` class. é    )ÚCompositeDomain)ÚField)ÚCoercionFailedÚGeneratorsError)Úpublicc                   @   s.  e Zd ZdZd ZZdZdZdDdd„Zdd„ Z	dd	„ Z
ed
d„ ƒZedd„ ƒZedd„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zd*d+„ Zd,d-„ Zd.d/„ Zd0d1„ Zd2d3„ Z d4d5„ Z!d6d7„ Z"d8d9„ Z#d:d;„ Z$d<d=„ Z%d>d?„ Z&d@dA„ Z'dBdC„ Z(dS )EÚFractionFieldz@A class for representing multivariate rational function fields. TNc                 C   sr   ddl m} t||ƒr|d u r|d u r|}n||||ƒ}|| _|j| _|j| _|j| _|j| _|j| _| j| _	d S )Nr   )Ú	FracField)
Zsympy.polys.fieldsr   Ú
isinstanceÚfieldÚdtypeZgensZngensÚsymbolsÚdomainÚdom)ÚselfZdomain_or_fieldr   Úorderr   r
   © r   úP/var/www/auris/lib/python3.10/site-packages/sympy/polys/domains/fractionfield.pyÚ__init__   s   zFractionField.__init__c                 C   ó   | j  |¡S ©N)r
   Z	field_new©r   Úelementr   r   r   Únew%   s   zFractionField.newc                 C   r   )z%Check if ``a`` is of type ``dtype``. )r
   Z
is_elementr   r   r   r   Úof_type(   ó   zFractionField.of_typec                 C   ó   | j jS r   )r
   Úzero©r   r   r   r   r   ,   ó   zFractionField.zeroc                 C   r   r   )r
   Úoner   r   r   r   r   0   r   zFractionField.onec                 C   r   r   )r
   r   r   r   r   r   r   4   r   zFractionField.orderc                 C   s$   t | jƒd d tt | jƒ¡ d S )Nú(ú,ú))Ústrr   ÚjoinÚmapr   r   r   r   r   Ú__str__8   s   $zFractionField.__str__c                 C   s   t | jj| j| j| jfƒS r   )ÚhashÚ	__class__Ú__name__r
   r   r   r   r   r   r   Ú__hash__;   s   zFractionField.__hash__c                 C   s   t |tƒstS | j|jkS )z0Returns ``True`` if two domains are equivalent. )r	   r   ÚNotImplementedr
   )r   Úotherr   r   r   Ú__eq__>   s   
zFractionField.__eq__c                 C   s   |  ¡ S )z!Convert ``a`` to a SymPy object. )Zas_expr©r   Úar   r   r   Úto_sympyD   r   zFractionField.to_sympyc                 C   r   )z)Convert SymPy's expression to ``dtype``. )r
   Z	from_exprr.   r   r   r   Ú
from_sympyH   r   zFractionField.from_sympyc                 C   ó   | | j  ||¡ƒS ©z.Convert a Python ``int`` object to ``dtype``. ©r   Úconvert©ÚK1r/   ÚK0r   r   r   Úfrom_ZZL   ó   zFractionField.from_ZZc                 C   r2   r3   r4   r6   r   r   r   Úfrom_ZZ_pythonP   r:   zFractionField.from_ZZ_pythonc                 C   sH   | j }|j}|jr| || |¡|ƒƒ| || |¡|ƒƒ S | |||ƒƒS ©z3Convert a Python ``Fraction`` object to ``dtype``. )r   Úconvert_fromZis_ZZÚnumerÚdenom)r7   r/   r8   r   Úconvr   r   r   Úfrom_QQT   s
   (zFractionField.from_QQc                 C   r2   r<   r4   r6   r   r   r   Úfrom_QQ_python]   r:   zFractionField.from_QQ_pythonc                 C   r2   )z,Convert a GMPY ``mpz`` object to ``dtype``. r4   r6   r   r   r   Úfrom_ZZ_gmpya   r:   zFractionField.from_ZZ_gmpyc                 C   r2   )z,Convert a GMPY ``mpq`` object to ``dtype``. r4   r6   r   r   r   Úfrom_QQ_gmpye   r:   zFractionField.from_QQ_gmpyc                 C   r2   )z4Convert a ``GaussianRational`` object to ``dtype``. r4   r6   r   r   r   Úfrom_GaussianRationalFieldi   r:   z(FractionField.from_GaussianRationalFieldc                 C   r2   )z3Convert a ``GaussianInteger`` object to ``dtype``. r4   r6   r   r   r   Úfrom_GaussianIntegerRingm   r:   z&FractionField.from_GaussianIntegerRingc                 C   r2   ©z.Convert a mpmath ``mpf`` object to ``dtype``. r4   r6   r   r   r   Úfrom_RealFieldq   r:   zFractionField.from_RealFieldc                 C   r2   rG   r4   r6   r   r   r   Úfrom_ComplexFieldu   r:   zFractionField.from_ComplexFieldc                 C   s.   | j |kr| j  ||¡}|dur|  |¡S dS )z*Convert an algebraic number to ``dtype``. N)r   r=   r   r6   r   r   r   Úfrom_AlgebraicFieldy   s
   

ÿz!FractionField.from_AlgebraicFieldc                 C   sp   |j r|  | d¡|j¡S z|  | | jj¡¡W S  tt	fy7   z|  |¡W  Y S  tt	fy6   Y Y dS w w )z#Convert a polynomial to ``dtype``. é   N)
Z	is_groundr=   Zcoeffr   r   Zset_ringr
   Úringr   r   r6   r   r   r   Úfrom_PolynomialRing€   s   ÿùz!FractionField.from_PolynomialRingc              	   C   s(   z|  | j¡W S  ttfy   Y dS w )z*Convert a rational function to ``dtype``. N)Z	set_fieldr
   r   r   r6   r   r   r   Úfrom_FractionField   s
   ÿz FractionField.from_FractionFieldc                 C   s   | j  ¡  ¡ S )z*Returns a field associated with ``self``. )r
   Zto_ringZ	to_domainr   r   r   r   Úget_ring—   s   zFractionField.get_ringc                 C   ó   | j  |jj¡S )z'Returns True if ``LC(a)`` is positive. )r   Úis_positiver>   ÚLCr.   r   r   r   rQ   ›   ó   zFractionField.is_positivec                 C   rP   )z'Returns True if ``LC(a)`` is negative. )r   Úis_negativer>   rR   r.   r   r   r   rT   Ÿ   rS   zFractionField.is_negativec                 C   rP   )z+Returns True if ``LC(a)`` is non-positive. )r   Úis_nonpositiver>   rR   r.   r   r   r   rU   £   rS   zFractionField.is_nonpositivec                 C   rP   )z+Returns True if ``LC(a)`` is non-negative. )r   Úis_nonnegativer>   rR   r.   r   r   r   rV   §   rS   zFractionField.is_nonnegativec                 C   ó   |j S )zReturns numerator of ``a``. )r>   r.   r   r   r   r>   «   ó   zFractionField.numerc                 C   rW   )zReturns denominator of ``a``. )r?   r.   r   r   r   r?   ¯   rX   zFractionField.denomc                 C   s   |   | j |¡¡S )zReturns factorial of ``a``. )r   r   Ú	factorialr.   r   r   r   rY   ³   r:   zFractionField.factorial)NN))r)   Ú
__module__Ú__qualname__Ú__doc__Zis_FractionFieldZis_FracZhas_assoc_RingZhas_assoc_Fieldr   r   r   Úpropertyr   r   r   r&   r*   r-   r0   r1   r9   r;   rA   rB   rC   rD   rE   rF   rH   rI   rJ   rM   rN   rO   rQ   rT   rU   rV   r>   r?   rY   r   r   r   r   r   	   sP    



	r   N)r\   Z#sympy.polys.domains.compositedomainr   Zsympy.polys.domains.fieldr   Zsympy.polys.polyerrorsr   r   Zsympy.utilitiesr   r   r   r   r   r   Ú<module>   s    