o
    i                     @   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   	TypeErrorZof_typenew)clselementdomain r   p/var/www/html/eduruby.in/lip-sync/lip-sync-env/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   )Z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   Z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   r/   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   r8   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,   r.   r1   r5   r7   r9   r;   r<   r?   rA   __classcell__r   r   r   r   r      s2    

r   N)rE   constructorr   Zsympy.polys.domainsr   r   r   r   r   r   r   <module>   s    