Exemple #1
0
 def mag(ctx, x):
     x = ctx.convert(x)
     if isinstance(x, ctx.mpc):
         return max(ctx.mag(x.real), ctx.mag(x.imag)) + 1
     a, b = libmp.mpi_abs(x._mpi_)
     sign, man, exp, bc = b
     if man:
         return exp+bc
     if b == fzero:
         return ctx.ninf
     if b == fnan:
         return ctx.nan
     return ctx.inf
Exemple #2
0
 def mag(ctx, x):
     x = ctx.convert(x)
     if isinstance(x, ctx.mpc):
         return max(ctx.mag(x.real), ctx.mag(x.imag)) + 1
     a, b = libmp.mpi_abs(x._mpi_)
     sign, man, exp, bc = b
     if man:
         return exp + bc
     if b == fzero:
         return ctx.ninf
     if b == fnan:
         return ctx.nan
     return ctx.inf
Exemple #3
0
 def __abs__(self):
     return self.ctx.make_mpf(mpi_abs(self._mpi_, self.ctx.prec))
Exemple #4
0
 def __abs__(self):
     return self.context.make_mpi(mpi_abs(self._mpi_, self.context.prec))
Exemple #5
0
 def __abs__(self):
     return self.ctx.make_mpf(mpi_abs(self._mpi_, self.ctx.prec))