Beispiel #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
 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
Beispiel #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
 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