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)
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)
def test_isign(): x = Symbol('x', integer=True) assert isign(1, x) == isign(1, x) assert fcode(isign(1, x), standard=95, source_format='free') == 'isign(1, x)'
def test_isign(): x = Symbol('x', integer=True) assert isign(1, x) == isign(1, x) assert fcode(isign(1, x), standard=95, source_format='free') == 'isign(1, x)'