-// default ctor, dtor, copy ctor assignment operator and helpers
+// default ctor, dtor, copy ctor, assignment operator and helpers
n.find_ex("basis", basis, sym_lst);
n.find_ex("exponent", exponent, sym_lst);
}
n.find_ex("basis", basis, sym_lst);
n.find_ex("exponent", exponent, sym_lst);
}
if (is_a<print_tree>(c)) {
inherited::print(c, level);
if (is_a<print_tree>(c)) {
inherited::print(c, level);
- if (is_exactly_of_type(*exponent.bp,numeric)) {
- if (basis.is_equal(s)) {
- if (ex_to<numeric>(exponent).is_integer())
- return ex_to<numeric>(exponent).to_int();
- else
- return 0;
- } else
+ if (is_ex_exactly_of_type(exponent, numeric) && ex_to<numeric>(exponent).is_integer()) {
+ if (basis.is_equal(s))
+ return ex_to<numeric>(exponent).to_int();
+ else
- if (is_exactly_of_type(*exponent.bp,numeric)) {
- if (basis.is_equal(s)) {
- if (ex_to<numeric>(exponent).is_integer())
- return ex_to<numeric>(exponent).to_int();
- else
- return 0;
- } else
+ if (is_ex_exactly_of_type(exponent, numeric) && ex_to<numeric>(exponent).is_integer()) {
+ if (basis.is_equal(s))
+ return ex_to<numeric>(exponent).to_int();
+ else
else if ((num_exponent->real()).is_negative())
throw (pole_error("power::eval(): division by zero",1));
else
else if ((num_exponent->real()).is_negative())
throw (pole_error("power::eval(): division by zero",1));
else
if (is_ex_exactly_of_type(sub_exponent,numeric)) {
const numeric & num_sub_exponent = ex_to<numeric>(sub_exponent);
GINAC_ASSERT(num_sub_exponent!=numeric(1));
if (is_ex_exactly_of_type(sub_exponent,numeric)) {
const numeric & num_sub_exponent = ex_to<numeric>(sub_exponent);
GINAC_ASSERT(num_sub_exponent!=numeric(1));
if (is_ex_exactly_of_type(ebasis,mul)) {
GINAC_ASSERT(!num_exponent->is_integer()); // should have been handled above
const mul & mulref = ex_to<mul>(ebasis);
if (is_ex_exactly_of_type(ebasis,mul)) {
GINAC_ASSERT(!num_exponent->is_integer()); // should have been handled above
const mul & mulref = ex_to<mul>(ebasis);
const numeric & num_coeff = ex_to<numeric>(mulref.overall_coeff);
if (num_coeff.is_real()) {
if (num_coeff.is_positive()) {
mul *mulp = new mul(mulref);
const numeric & num_coeff = ex_to<numeric>(mulref.overall_coeff);
if (num_coeff.is_real()) {
if (num_coeff.is_positive()) {
mul *mulp = new mul(mulref);
mulp->clearflag(status_flags::evaluated);
mulp->clearflag(status_flags::hash_calculated);
return (new mul(power(*mulp,exponent),
power(num_coeff,*num_exponent)))->setflag(status_flags::dynallocated);
} else {
mulp->clearflag(status_flags::evaluated);
mulp->clearflag(status_flags::hash_calculated);
return (new mul(power(*mulp,exponent),
power(num_coeff,*num_exponent)))->setflag(status_flags::dynallocated);
} else {
mulp->clearflag(status_flags::evaluated);
mulp->clearflag(status_flags::hash_calculated);
return (new mul(power(*mulp,exponent),
mulp->clearflag(status_flags::evaluated);
mulp->clearflag(status_flags::hash_calculated);
return (new mul(power(*mulp,exponent),
&& are_ex_trivially_equal(exponent, subsed_exponent))
return basic::subs(ls, lr, no_pattern);
else
&& are_ex_trivially_equal(exponent, subsed_exponent))
return basic::subs(ls, lr, no_pattern);
else
- return ex(power(subsed_basis, subsed_exponent)).bp->basic::subs(ls, lr, no_pattern);
+ return power(subsed_basis, subsed_exponent).basic::subs(ls, lr, no_pattern);
- newseq.push_back(expair(basis, exponent - _ex1()));
- newseq.push_back(expair(basis.diff(s), _ex1()));
+ newseq.push_back(expair(basis, exponent - _ex1));
+ newseq.push_back(expair(basis.diff(s), _ex1));
return mul(newseq, exponent);
} else {
// D(b^e) = b^e * (D(e)*ln(b) + e*D(b)/b)
return mul(*this,
add(mul(exponent.diff(s), log(basis)),
return mul(newseq, exponent);
} else {
// D(b^e) = b^e * (D(e)*ln(b) + e*D(b)/b)
return mul(*this,
add(mul(exponent.diff(s), log(basis)),
- mul(mul(exponent, basis.diff(s)), power(basis, _ex_1()))));
+ mul(mul(exponent, basis.diff(s)), power(basis, _ex_1))));
- GINAC_ASSERT(!is_ex_exactly_of_type(b,add));
- GINAC_ASSERT(!is_ex_exactly_of_type(b,power) ||
- !is_ex_exactly_of_type(ex_to<power>(b).exponent,numeric) ||
+ GINAC_ASSERT(!is_exactly_a<add>(b));
+ GINAC_ASSERT(!is_exactly_a<power>(b) ||
+ !is_exactly_a<numeric>(ex_to<power>(b).exponent) ||
- !is_ex_exactly_of_type(ex_to<power>(b).basis,add) ||
- !is_ex_exactly_of_type(ex_to<power>(b).basis,mul) ||
- !is_ex_exactly_of_type(ex_to<power>(b).basis,power));
+ !is_exactly_a<add>(ex_to<power>(b).basis) ||
+ !is_exactly_a<mul>(ex_to<power>(b).basis) ||
+ !is_exactly_a<power>(ex_to<power>(b).basis));
if (is_ex_exactly_of_type(b,mul))
term.push_back(expand_mul(ex_to<mul>(b),numeric(k[l])));
else
if (is_ex_exactly_of_type(b,mul))
term.push_back(expand_mul(ex_to<mul>(b),numeric(k[l])));
else
- GINAC_ASSERT(!is_ex_exactly_of_type(b,add));
- GINAC_ASSERT(!is_ex_exactly_of_type(b,power) ||
- !is_ex_exactly_of_type(ex_to<power>(b).exponent,numeric) ||
+ GINAC_ASSERT(!is_exactly_a<add>(b));
+ GINAC_ASSERT(!is_exactly_a<power>(b) ||
+ !is_exactly_a<numeric>(ex_to<power>(b).exponent) ||
- !is_ex_exactly_of_type(ex_to<power>(b).basis,add) ||
- !is_ex_exactly_of_type(ex_to<power>(b).basis,mul) ||
- !is_ex_exactly_of_type(ex_to<power>(b).basis,power));
+ !is_exactly_a<add>(ex_to<power>(b).basis) ||
+ !is_exactly_a<mul>(ex_to<power>(b).basis) ||
+ !is_exactly_a<power>(ex_to<power>(b).basis));
if (is_ex_exactly_of_type(b,mul))
term.push_back(expand_mul(ex_to<mul>(b),numeric(n-k_cum[m-2])));
else
if (is_ex_exactly_of_type(b,mul))
term.push_back(expand_mul(ex_to<mul>(b),numeric(n-k_cum[m-2])));
else
- GINAC_ASSERT(!is_ex_exactly_of_type(r,add));
- GINAC_ASSERT(!is_ex_exactly_of_type(r,power) ||
- !is_ex_exactly_of_type(ex_to<power>(r).exponent,numeric) ||
+ GINAC_ASSERT(!is_exactly_a<add>(r));
+ GINAC_ASSERT(!is_exactly_a<power>(r) ||
+ !is_exactly_a<numeric>(ex_to<power>(r).exponent) ||
- !is_ex_exactly_of_type(ex_to<power>(r).basis,add) ||
- !is_ex_exactly_of_type(ex_to<power>(r).basis,mul) ||
- !is_ex_exactly_of_type(ex_to<power>(r).basis,power));
+ !is_exactly_a<add>(ex_to<power>(r).basis) ||
+ !is_exactly_a<mul>(ex_to<power>(r).basis) ||
+ !is_exactly_a<power>(ex_to<power>(r).basis));
- sum.push_back(expair(expand_mul(ex_to<mul>(r),_num2()),
- ex_to<numeric>(c).power_dyn(_num2())));
+ sum.push_back(expair(expand_mul(ex_to<mul>(r),_num2),
+ ex_to<numeric>(c).power_dyn(_num2)));
- sum.push_back(expair((new power(r,_ex2()))->setflag(status_flags::dynallocated),
- ex_to<numeric>(c).power_dyn(_num2())));
+ sum.push_back(expair((new power(r,_ex2))->setflag(status_flags::dynallocated),
+ ex_to<numeric>(c).power_dyn(_num2)));
const ex & r1 = cit1->rest;
const ex & c1 = cit1->coeff;
sum.push_back(a.combine_ex_with_coeff_to_pair((new mul(r,r1))->setflag(status_flags::dynallocated),
const ex & r1 = cit1->rest;
const ex & c1 = cit1->coeff;
sum.push_back(a.combine_ex_with_coeff_to_pair((new mul(r,r1))->setflag(status_flags::dynallocated),
if (!a.overall_coeff.is_zero()) {
epvector::const_iterator i = a.seq.begin(), end = a.seq.end();
while (i != end) {
if (!a.overall_coeff.is_zero()) {
epvector::const_iterator i = a.seq.begin(), end = a.seq.end();
while (i != end) {