o
    oÇhÂ  ã                   @   s2   d Z ddlmZ ddlmZmZ G dd„ dƒZdS )a(  

Module for the DomainScalar class.

A DomainScalar represents an element which is in a particular
Domain. The idea is that the DomainScalar class provides the
convenience routines for unifying elements with different domains.

It assists in Scalar Multiplication and getitem for DomainMatrix.

é   )Úconstruct_domainé    )ÚDomainÚZZc                       sÈ   e Zd ZdZdd„ Ze‡ fdd„ƒZ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d*d+„ Z‡  ZS ),ÚDomainScalarz
    docstring
    c                 C   s8   t |tƒs	tdƒ‚| |¡std||f ƒ‚|  ||¡S )Nzdomain should be of type Domainz!element %s should be in domain %s)Ú
isinstancer   Ú	TypeErrorÚof_typeÚnew)ÚclsÚelementÚdomain© r   úu/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/sympy/polys/matrices/domainscalar.pyÚ__new__   s
   

zDomainScalar.__new__c                    s   t ƒ  | ¡}||_||_|S ©N)Úsuperr   r   r   )r   r   r   Úobj©Ú	__class__r   r   r
      s   zDomainScalar.newc                 C   ó
   t | jƒS r   )Úreprr   ©Úselfr   r   r   Ú__repr__$   ó   
zDomainScalar.__repr__c                 C   s   t |gƒ\}\}|  ||¡S r   )r   r
   )r   Úexprr   r   r   r   r   Ú
from_sympy'   s   zDomainScalar.from_sympyc                 C   s   | j  | j¡S r   )r   Úto_sympyr   r   r   r   r   r   ,   ó   zDomainScalar.to_sympyc                 C   s   |  | j| j¡}|  ||¡S r   )Úconvert_fromr   r   r
   )r   r   r   r   r   r   Ú	to_domain/   s   zDomainScalar.to_domainc                 C   s
   |   |¡S r   )r!   )r   r   r   r   r   Ú
convert_to3   r   zDomainScalar.convert_toc                 C   s"   | j  |j ¡}|  |¡| |¡fS r   )r   Úunifyr!   )r   Úotherr   r   r   r   r#   6   s   zDomainScalar.unifyc                 C   r   r   )Úboolr   r   r   r   r   Ú__bool__:   r   zDomainScalar.__bool__c                 C   s2   t |tƒstS |  |¡\} }|  | j|j | j¡S r   ©r   r   ÚNotImplementedr#   r
   r   r   ©r   r$   r   r   r   Ú__add__=   ó   
zDomainScalar.__add__c                 C   s2   t |tƒstS |  |¡\} }|  | j|j | j¡S r   r'   r)   r   r   r   Ú__sub__C   r+   zDomainScalar.__sub__c                 C   sL   t |tƒst |tƒrtt|ƒtƒ}ntS |  |¡\} }|  | j|j | j¡S r   )	r   r   Úintr   r(   r#   r
   r   r   r)   r   r   r   Ú__mul__I   s   

zDomainScalar.__mul__c                 C   ó8   t |tƒstS |  |¡\} }|  | j | j|j¡| j¡S r   )r   r   r(   r#   r
   r   Úquor   r)   r   r   r   Ú__floordiv__S   ó   
zDomainScalar.__floordiv__c                 C   r/   r   )r   r   r(   r#   r
   r   Úremr   r)   r   r   r   Ú__mod__Y   r2   zDomainScalar.__mod__c                 C   sN   t |tƒstS |  |¡\} }| j | j|j¡\}}|  || j¡|  || j¡fS r   )r   r   r(   r#   r   Údivr   r
   )r   r$   ÚqÚrr   r   r   Ú
__divmod___   s
   
zDomainScalar.__divmod__c                 C   s"   t |tƒstS |  | j| | j¡S r   )r   r-   r(   r
   r   r   )r   Únr   r   r   Ú__pow__f   s   
zDomainScalar.__pow__c                 C   s   |   | j
 | j¡S r   ©r
   r   r   r   r   r   r   Ú__pos__k   ó   zDomainScalar.__pos__c                 C   s   |   | j | j¡S r   r;   r   r   r   r   Ú__neg__n   r=   zDomainScalar.__neg__c                 C   s&   t |tƒstS | j|jko| j|jkS r   )r   r   r(   r   r   r)   r   r   r   Ú__eq__q   s   
zDomainScalar.__eq__c                 C   ó   | j | jjkS r   )r   r   Úzeror   r   r   r   Úis_zerov   r   zDomainScalar.is_zeroc                 C   r@   r   )r   r   Úoner   r   r   r   Úis_oney   r   zDomainScalar.is_one)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úclassmethodr
   r   r   r   r!   r"   r#   r&   r*   r,   r.   r1   r4   r8   r:   r<   r>   r?   rB   rD   Ú__classcell__r   r   r   r   r      s2    

r   N)rH   Úconstructorr   Úsympy.polys.domainsr   r   r   r   r   r   r   Ú<module>   s    