void StrPrinter::bvisit(const Pow &x) { std::ostringstream o; o << parenthesizeLE(x.get_base(), PrecedenceEnum::Pow); o << "**"; o << parenthesizeLE(x.get_exp(), PrecedenceEnum::Pow); str_ = o.str(); }
void bvisit(const Pow &x) { if (is_a<const Integer>(*x.get_exp())) { if (rcp_static_cast<const Integer>(x.get_exp())->is_positive()) { x.get_base()->accept(*this); } else { add_to_gen_set(pow(x.get_base(), minus_one), one); } } else if (is_a<const Rational>(*x.get_exp())) { RCP<const Basic> base = x.get_base(); RCP<const Rational> r = rcp_static_cast<const Rational>(x.get_exp()); if (r->is_negative()) base = pow(base, minus_one); add_to_gen_set(base, divnum(one, r->get_den())); } else { umap_basic_num pow_pairs = _find_gens_poly_pow(x.get_exp(), x.get_base()); for (auto it : pow_pairs) add_to_gen_set(pow(x.get_base(), it.first), it.second); } }
void bvisit(const Pow &x) { if (eq(*x.get_base(), *E)) { apply(result_, *(x.get_exp())); mpfr_exp(result_, result_, rnd_); } else { mpfr_class b(mpfr_get_prec(result_)); apply(b.get_mpfr_t(), *(x.get_base())); apply(result_, *(x.get_exp())); mpfr_pow(result_, b.get_mpfr_t(), result_, rnd_); } }
static RCP<const Basic> diff(const Pow &self, const RCP<const Symbol> &x) { if (is_a_Number(*(self.get_exp()))) return mul(mul(self.get_exp(), pow(self.get_base(), sub(self.get_exp(), one))), self.get_base()->diff(x)); else return mul(pow(self.get_base(), self.get_exp()), mul(self.get_exp(), log(self.get_base()))->diff(x)); }
void bvisit(const Pow &x) { RCP<const Basic> base_, exp_, num, den; base_ = x.get_base(); exp_ = x.get_exp(); as_numer_denom(base_, outArg(num), outArg(den)); // if the exp is a negative numer, or is intuitively 'negative' if (handle_minus(exp_, outArg(exp_))) { *numer_ = pow(den, exp_); *denom_ = pow(num, exp_); } else { *numer_ = pow(num, exp_); *denom_ = pow(den, exp_); } }