示例#1
0
文件: libmpc.py 项目: vks/sympy
def mpc_ceil(z, prec, rnd=round_fast):
    a, b = z
    return mpf_ceil(a, prec, rnd), mpf_ceil(b, prec, rnd)
示例#2
0
    """Absolute value of a complex number, |a+bi|.
    Returns an mpf value."""
    return mpf_hypot(a, b, prec, rnd)


def mpc_arg((a, b), prec, rnd=round_fast):
    """Argument of a complex number. Returns an mpf value."""
    return mpf_atan2(b, a, prec, rnd)


def mpc_floor((a, b), prec, rnd=round_fast):
    return mpf_floor(a, prec, rnd), mpf_floor(b, prec, rnd)


def mpc_ceil((a, b), prec, rnd=round_fast):
    return mpf_ceil(a, prec, rnd), mpf_ceil(b, prec, rnd)


def mpc_mul((a, b), (c, d), prec, rnd=round_fast):
    """Complex multiplication.

    Returns the real and imaginary part of (a+bi)*(c+di), rounded to
    the specified precision. The rounding mode applies to the real and
    imaginary parts separately."""

    asign, aman, aexp, abc = a
    bsign, bman, bexp, bbc = b
    csign, cman, cexp, cbc = c
    dsign, dman, dexp, dbc = d

    if 0 in (aman, bman, cman, dman):
示例#3
0
    return mpf_shift(a, n), mpf_shift(b, n)

def mpc_abs((a, b), prec, rnd=round_fast):
    """Absolute value of a complex number, |a+bi|.
    Returns an mpf value."""
    return mpf_hypot(a, b, prec, rnd)

def mpc_arg((a, b), prec, rnd=round_fast):
    """Argument of a complex number. Returns an mpf value."""
    return mpf_atan2(b, a, prec, rnd)

def mpc_floor((a, b), prec, rnd=round_fast):
    return mpf_floor(a, prec, rnd), mpf_floor(b, prec, rnd)

def mpc_ceil((a, b), prec, rnd=round_fast):
    return mpf_ceil(a, prec, rnd), mpf_ceil(b, prec, rnd)

def mpc_mul((a, b), (c, d), prec, rnd=round_fast):
    """Complex multiplication.

    Returns the real and imaginary part of (a+bi)*(c+di), rounded to
    the specified precision. The rounding mode applies to the real and
    imaginary parts separately."""

    asign, aman, aexp, abc = a
    bsign, bman, bexp, bbc = b
    csign, cman, cexp, cbc = c
    dsign, dman, dexp, dbc = d

    if 0 in (aman, bman, cman, dman):
        # TODO: use a better strategy for complex infs
示例#4
0
def mpc_ceil(z, prec, rnd=round_fast):
    a, b = z
    return mpf_ceil(a, prec, rnd), mpf_ceil(b, prec, rnd)