o
    Rh                     @   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)
sympy.polys.fieldsr   
isinstancefielddtypegensngenssymbolsdomaindom)selfdomain_or_fieldr   orderr   r    r   c/home/air/sanwanet/backup_V2/venv/lib/python3.10/site-packages/sympy/polys/domains/fractionfield.py__init__   s   zFractionField.__init__c                 C      | j |S N)r   	field_newr   elementr   r   r   new%   s   zFractionField.newc                 C   r   )z%Check if ``a`` is of type ``dtype``. )r   
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. )as_exprr   ar   r   r   to_sympyD   r$   zFractionField.to_sympyc                 C   r   )z)Convert SymPy's expression to ``dtype``. )r   	from_exprr5   r   r   r   
from_sympyH   r    zFractionField.from_sympyc                 C      | | j ||S z.Convert a Python ``int`` object to ``dtype``. r   convertK1r6   K0r   r   r   from_ZZL      zFractionField.from_ZZc                 C   r:   r;   r<   r>   r   r   r   from_ZZ_pythonP   rB   zFractionField.from_ZZ_pythonc                 C   sH   | j }|j}|jr| ||||| |||| S | |||S z3Convert a Python ``Fraction`` object to ``dtype``. )r   convert_fromis_ZZnumerdenom)r?   r6   r@   r   convr   r   r   from_QQT   s
   (zFractionField.from_QQc                 C   r:   rD   r<   r>   r   r   r   from_QQ_python]   rB   zFractionField.from_QQ_pythonc                 C   r:   )z,Convert a GMPY ``mpz`` object to ``dtype``. r<   r>   r   r   r   from_ZZ_gmpya   rB   zFractionField.from_ZZ_gmpyc                 C   r:   )z,Convert a GMPY ``mpq`` object to ``dtype``. r<   r>   r   r   r   from_QQ_gmpye   rB   zFractionField.from_QQ_gmpyc                 C   r:   )z4Convert a ``GaussianRational`` object to ``dtype``. r<   r>   r   r   r   from_GaussianRationalFieldi   rB   z(FractionField.from_GaussianRationalFieldc                 C   r:   )z3Convert a ``GaussianInteger`` object to ``dtype``. r<   r>   r   r   r   from_GaussianIntegerRingm   rB   z&FractionField.from_GaussianIntegerRingc                 C   r:   z.Convert a mpmath ``mpf`` object to ``dtype``. r<   r>   r   r   r   from_RealFieldq   rB   zFractionField.from_RealFieldc                 C   r:   rP   r<   r>   r   r   r   from_ComplexFieldu   rB   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   rE   r   r>   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)
	is_groundrE   coeffr   r   set_ringr   ringr   r   r>   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)	set_fieldr   r   r   r>   r   r   r   from_FractionField   s
   z FractionField.from_FractionFieldc                 C   s   | j   S )z*Returns a field associated with ``self``. )r   to_ring	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_positiverG   LCr5   r   r   r   r`         zFractionField.is_positivec                 C   r_   )z'Returns True if ``LC(a)`` is negative. )r   is_negativerG   ra   r5   r   r   r   rc      rb   zFractionField.is_negativec                 C   r_   )z+Returns True if ``LC(a)`` is non-positive. )r   is_nonpositiverG   ra   r5   r   r   r   rd      rb   zFractionField.is_nonpositivec                 C   r_   )z+Returns True if ``LC(a)`` is non-negative. )r   is_nonnegativerG   ra   r5   r   r   r   re      rb   zFractionField.is_nonnegativec                 C      |j S )zReturns numerator of ``a``. )rG   r5   r   r   r   rG         zFractionField.numerc                 C   rf   )zReturns denominator of ``a``. )rH   r5   r   r   r   rH      rg   zFractionField.denomc                 C   s   |  | j|S )zReturns factorial of ``a``. )r   r   	factorialr5   r   r   r   rh      rB   zFractionField.factorial)NN))r/   
__module____qualname____doc__is_FractionFieldis_Frachas_assoc_Ringhas_assoc_Fieldr   r   r   propertyr"   r%   r   r,   r0   r3   r7   r9   rA   rC   rJ   rK   rL   rM   rN   rO   rQ   rR   rS   rY   r[   r^   r`   rc   rd   re   rG   rH   rh   r   r   r   r   r   	   sP    



	r   N)rk   #sympy.polys.domains.compositedomainr   sympy.polys.domains.fieldr   sympy.polys.polyerrorsr   r   sympy.utilitiesr   r   r   r   r   r   <module>   s    