コード例 #1
0
ファイル: ctx_mp.py プロジェクト: Praveen-Ramanujam/MobRAVE
    def ldexp(ctx, x, n):
        r"""
        Computes `x 2^n` efficiently. No rounding is performed.
        The argument `x` must be a real floating-point number (or
        possible to convert into one) and `n` must be a Python ``int``.

            >>> from mpmath import *
            >>> mp.dps = 15; mp.pretty = False
            >>> ldexp(1, 10)
            mpf('1024.0')
            >>> ldexp(1, -3)
            mpf('0.125')

        """
        x = ctx.convert(x)
        return ctx.make_mpf(libmp.mpf_shift(x._mpf_, n))
コード例 #2
0
ファイル: ctx_mp.py プロジェクト: unix0000/sympy-polys
    def ldexp(ctx, x, n):
        r"""
        Computes `x 2^n` efficiently. No rounding is performed.
        The argument `x` must be a real floating-point number (or
        possible to convert into one) and `n` must be a Python ``int``.

            >>> from mpmath import *
            >>> mp.dps = 15; mp.pretty = False
            >>> ldexp(1, 10)
            mpf('1024.0')
            >>> ldexp(1, -3)
            mpf('0.125')

        """
        x = ctx.convert(x)
        return ctx.make_mpf(libmp.mpf_shift(x._mpf_, n))
コード例 #3
0
ファイル: ctx_iv.py プロジェクト: venkatmi/altanalyze
 def ldexp(ctx, x, n):
     a, b = ctx.convert(x)._mpi_
     a = libmp.mpf_shift(a, n)
     b = libmp.mpf_shift(b, n)
     return ctx.make_mpf((a,b))
コード例 #4
0
ファイル: ctx_iv.py プロジェクト: xflicsu/altanalyze
 def ldexp(ctx, x, n):
     a, b = ctx.convert(x)._mpi_
     a = libmp.mpf_shift(a, n)
     b = libmp.mpf_shift(b, n)
     return ctx.make_mpf((a, b))