RCP<const Number> Integer::pow_negint(const Integer &other) const { RCP<const Number> tmp = powint(*other.neg()); if (is_a<Integer>(*tmp)) { mpq_class q(sgn(rcp_static_cast<const Integer>(tmp)->i), abs(rcp_static_cast<const Integer>(tmp)->i)); return make_rcp<const Rational>(q); } else { throw std::runtime_error("powint returned non-integer"); } }
RCP<const Number> Integer::pow_negint(const Integer &other) const { RCP<const Number> tmp = powint(*other.neg()); if (is_a<Integer>(*tmp)) { const integer_class &j = down_cast<const Integer &>(*tmp).i; #if SYMENGINE_INTEGER_CLASS == SYMENGINE_BOOSTMP // boost::multiprecision::cpp_rational lacks an (int, cpp_int) // constructor. must use cpp_rational(cpp_int,cpp_int) rational_class q(integer_class(mp_sign(j)), mp_abs(j)); #else rational_class q(mp_sign(j), mp_abs(j)); #endif return Rational::from_mpq(std::move(q)); } else { throw SymEngineException("powint returned non-integer"); } }