Пример #1
0
 def _print_sign(self, expr):
     from sympy import Abs
     arg, = expr.args
     if arg.is_integer:
         new_expr = merge(0, isign(1, arg), Eq(arg, 0))
     elif arg.is_complex:
         new_expr = merge(cmplx(literal_dp(0), literal_dp(0)), arg/Abs(arg), Eq(Abs(arg), literal_dp(0)))
     else:
         new_expr = merge(literal_dp(0), dsign(literal_dp(1), arg), Eq(arg, literal_dp(0)))
     return self._print(new_expr)
Пример #2
0
 def _print_sign(self, expr):
     from sympy.functions.elementary.complexes import Abs
     arg, = expr.args
     if arg.is_integer:
         new_expr = merge(0, isign(1, arg), Eq(arg, 0))
     elif (arg.is_complex or arg.is_infinite):
         new_expr = merge(cmplx(literal_dp(0), literal_dp(0)),
                          arg / Abs(arg), Eq(Abs(arg), literal_dp(0)))
     else:
         new_expr = merge(literal_dp(0), dsign(literal_dp(1), arg),
                          Eq(arg, literal_dp(0)))
     return self._print(new_expr)