Пример #1
0
 def __rmul__(s, t):
     cls, new, (prec, rounding) = s._ctxdata
     if isinstance(t, int_types):
         v = new(cls)
         v._mpc_ = mpc_mul_int(s._mpc_, t, prec, rounding)
         return v
     t = s.mpc_convert_lhs(t)
     if t is NotImplemented:
         return t
     return t * s
Пример #2
0
 def __rmul__(s, t):
     cls, new, (prec, rounding) = s._ctxdata
     if isinstance(t, int_types):
         v = new(cls)
         v._mpc_ = mpc_mul_int(s._mpc_, t, prec, rounding)
         return v
     t = s.mpc_convert_lhs(t)
     if t is NotImplemented:
         return t
     return t * s
Пример #3
0
 def __mul__(s, t):
     cls, new, (prec, rounding) = s._ctxdata
     if not hasattr(t, '_mpc_'):
         if isinstance(t, int_types):
             v = new(cls)
             v._mpc_ = mpc_mul_int(s._mpc_, t, prec, rounding)
             return v
         t = s.mpc_convert_lhs(t)
         if t is NotImplemented:
             return t
         if hasattr(t, '_mpf_'):
             v = new(cls)
             v._mpc_ = mpc_mul_mpf(s._mpc_, t._mpf_, prec, rounding)
             return v
         t = s.mpc_convert_lhs(t)
     v = new(cls)
     v._mpc_ = mpc_mul(s._mpc_, t._mpc_, prec, rounding)
     return v
Пример #4
0
 def __mul__(s, t):
     cls, new, (prec, rounding) = s._ctxdata
     if not hasattr(t, '_mpc_'):
         if isinstance(t, int_types):
             v = new(cls)
             v._mpc_ = mpc_mul_int(s._mpc_, t, prec, rounding)
             return v
         t = s.mpc_convert_lhs(t)
         if t is NotImplemented:
             return t
         if hasattr(t, '_mpf_'):
             v = new(cls)
             v._mpc_ = mpc_mul_mpf(s._mpc_, t._mpf_, prec, rounding)
             return v
         t = s.mpc_convert_lhs(t)
     v = new(cls)
     v._mpc_ = mpc_mul(s._mpc_, t._mpc_, prec, rounding)
     return v