mò
Î~ Ec           @   s;   d  k  Z  d „  Z d „  Z d „  Z d f  d „  ƒ  YZ d  S(   Nc         C   s-   d } x  |  o |  d ?}  | d 7} q	 W| S(   Niÿÿÿÿi   (   t   rvt   bits(   R   R    (    (    t   /u5/kerl/src/kbc2/poly2_tm.pyt   find_degree   s     
c   
      C   s  | d j o d GHt i d ƒ n |  d j o d d g Sn t |  ƒ } t | ƒ } | | } | d j  o d |  g Sn | | >}	 |  } d } | } | } x[ | | j oM | d | >@o | |	 N} | d | >O} n |	 d L}	 | d 8} | d 8} q  W| | g S(   Ni    s&   poly2_t.quot_and_rem:  Divide by zero.i   (   t   bbitst   syst   exitt   abitsR   t   dividend_l1_post   divisor_l1_post   l1_difft   shift_divisort   remt   quott	   check_post   quot_pos(
   R   R   R	   R   R   R   R   R   R
   R   (    (    R   t   quot_and_rem   s0    

 


c         C   s   t  t |  d ƒ ƒ S(   Ni   (   t   poly2_tt   intt   s(   R   (    (    R   t   poly2_t_from_string+   s    R   c           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(   R   t   self(   R   R   (    (    R   t   __init__0   s    c         C   s   |  i | i j S(   N(   t   aR   t   b(   R   R   (    (    R   t   __eq__3   s    c         C   s   |  i | i j S(   N(   R   R   R   (   R   R   (    (    R   t   __ne__5   s    c         C   s   t  |  i | i Aƒ S(   N(   R   R   R   R   (   R   R   (    (    R   t   __add__8   s    c         C   s   t  |  i | i Aƒ S(   N(   R   R   R   R   (   R   R   (    (    R   t   __sub__;   s    c         C   s   |  S(   N(   R   (   R   (    (    R   t   __neg__>   s    c         C   sj   d } |  i } | i } | } x9 | o1 | d @o | | N} n | d >} | d ?} q! Wt | ƒ } | S(   Ni    i   (	   t   cbitsR   R   R   R   R   t   bshiftR   R    (   R   R   R    R   R   R   R   (    (    R   t   __mul__A   s    		 
c         C   sX   |  } t d ƒ } x? | d j o1 | d @o | | 9} n | d L} | | 9} q W| S(   Ni   i    (   R   t   a2R   t   apowert   power(   R   R#   R"   R!   (    (    R   t   __pow__P   s     
c         C   s%   t  |  i | i ƒ \ } } t | ƒ S(   N(   R   R   R   R   t	   quot_bitst   rem_bitsR   (   R   R   R%   R&   (    (    R   t   __div__\   s    c         C   s%   t  |  i | i ƒ \ } } t | ƒ S(   N(   R   R   R   R   R%   R&   R   (   R   R   R%   R&   (    (    R   t   __mod__`   s    c         C   s   t  |  i ƒ } | d S(   Ni   (   t   hexR   R   R   (   R   R   (    (    R   t   __str__d   s    (   t   __name__t
   __module__R   R   R   R   R   R   R    R$   R'   R(   R*   (    (    (    R   R   /   s   										(   R   R   R   R   R   (   R   R   R   R   R   (    (    R   t   ?   s   				