mò
è Ec           @   s0   d  k  Z  d k Td „  Z d f  d „  ƒ  YZ d  S(   N(   t   *c         C   s7   |  | j o& d G|  Gd G| Gd GHt i d ƒ n d  S(   Ns   mod_t add: mixed modulis   , t   .i   (   t   m1t   m2t   syst   exit(   R   R   (    (    t   /u5/kerl/src/kbc2/mod_tm.pyt   check_moduli   s    t   mod_tc           B   sk   t  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z RS(   Nc         C   s   | | |  _  | |  _ d  S(   N(   t   residuet   modulust   self(   R   R	   R
   (    (    R   t   __init__   s    c         C   s#   t  |  i | i ƒ |  i | i j S(   N(   R   t   aR
   t   bR	   (   R   R   (    (    R   t   __eq__   s    c         C   s#   t  |  i | i ƒ |  i | i j S(   N(   R   R   R
   R   R	   (   R   R   (    (    R   t   __ne__   s    c         C   s-   t  |  i | i ƒ t |  i | i |  i ƒ S(   N(   R   R   R
   R   R   R	   (   R   R   (    (    R   t   __add__   s    c         C   s-   t  |  i | i ƒ t |  i | i |  i ƒ S(   N(   R   R   R
   R   R   R	   (   R   R   (    (    R   t   __sub__   s    c         C   s   t  |  i |  i ƒ S(   N(   R   R   R	   R
   (   R   (    (    R   t   __neg__    s    c         C   s-   t  |  i | i ƒ t |  i | i |  i ƒ S(   N(   R   R   R
   R   R   R	   (   R   R   (    (    R   t   __mul__#   s    c         C   sx   |  } |  |  } | d j  o | } | | } n x? | d j o1 | d @o | | 9} n | d L} | | 9} q5 W| S(   Ni    i   (   R   t   a2t   apowert   power(   R   R   R   R   (    (    R   t   __pow__'   s    
 
c         C   s    t  |  i |  i ƒ \ } } } |  i |  i } | | j o d GHt i	 d ƒ n | | | j o( d G|  i Gd G|  i GHt i	 d ƒ n t
 | |  i ƒ } | S(   Ns   mod_t: reciprocation of zero.i   s$   mod_t: reciprocation of zero divisort   mod(   t   ext_gcdR   R	   R
   t   gcdt   residue_coefft   modulus_coefft   zeroR   R   R   t   rv(   R   R   R   R   R   R   (    (    R   t   inv4   s    c         C   s!   t  |  i | i ƒ |  | i ƒ  S(   N(   R   R   R
   R   R    (   R   R   (    (    R   t   __div__C   s    c         C   s   t  |  i ƒ S(   N(   t   strR   R	   (   R   (    (    R   t   __str__G   s    (   t   __name__t
   __module__R   R   R   R   R   R   R   R   R    R!   R#   (    (    (    R   R      s   										(   R   t   kbc2_util_mR   R   (   R   R   R   (    (    R   t   ?   s   		