&& (is_ex_exactly_of_type(basis, symbol) || is_ex_exactly_of_type(basis, constant))) {
int exp = ex_to_numeric(exponent).to_int();
if (exp > 0)
- c.s << "(";
+ c.s << '(';
else {
exp = -exp;
if (is_of_type(c, print_csrc_cl_N))
c.s << "1.0/(";
}
print_sym_pow(c, ex_to_symbol(basis), exp);
- c.s << ")";
+ c.s << ')';
// <expr>^-1 is printed as "1.0/<expr>" or with the recip() function of CLN
} else if (exponent.compare(_num_1()) == 0) {
else
c.s << "1.0/(";
basis.print(c);
- c.s << ")";
+ c.s << ')';
// Otherwise, use the pow() or expt() (CLN) functions
} else {
else
c.s << "pow(";
basis.print(c);
- c.s << ",";
+ c.s << ',';
exponent.print(c);
- c.s << ")";
+ c.s << ')';
}
} else {
c.s << "sqrt(";
basis.print(c);
if (is_of_type(c, print_latex))
- c.s << "}";
+ c.s << '}';
else
- c.s << ")";
+ c.s << ')';
} else {
- if (precedence <= level) {
+ if (precedence() <= level) {
if (is_of_type(c, print_latex))
c.s << "{(";
else
c.s << "(";
}
- basis.print(c, precedence);
- c.s << "^";
- exponent.print(c, precedence);
- if (precedence <= level) {
+ basis.print(c, precedence());
+ c.s << '^';
+ if (is_of_type(c, print_latex))
+ c.s << '{';
+ exponent.print(c, precedence());
+ if (is_of_type(c, print_latex))
+ c.s << '}';
+ if (precedence() <= level) {
if (is_of_type(c, print_latex))
c.s << ")}";
else
- c.s << ")";
+ c.s << ')';
}
}
}
return power(ebasis,eexponent);
}
-ex power::subs(const lst & ls, const lst & lr) const
+ex power::subs(const lst & ls, const lst & lr, bool no_pattern) const
{
- const ex & subsed_basis=basis.subs(ls,lr);
- const ex & subsed_exponent=exponent.subs(ls,lr);
+ const ex &subsed_basis = basis.subs(ls, lr, no_pattern);
+ const ex &subsed_exponent = exponent.subs(ls, lr, no_pattern);
- if (are_ex_trivially_equal(basis,subsed_basis)&&
- are_ex_trivially_equal(exponent,subsed_exponent)) {
- return inherited::subs(ls, lr);
- }
-
- return power(subsed_basis, subsed_exponent);
+ if (are_ex_trivially_equal(basis, subsed_basis)
+ && 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);
}
ex power::simplify_ncmul(const exvector & v) const
cout << "k_cum[" << i << "]=" << k_cum[i] << endl;
cout << "upper_limit[" << i << "]=" << upper_limit[i] << endl;
}
- for (exvector::const_iterator cit=term.begin(); cit!=term.end(); ++cit) {
- cout << *cit << endl;
- }
+ for_each(term.begin(), term.end(), ostream_iterator<ex>(cout, "\n"));
cout << "end term" << endl;
*/
}
*/
-//////////
-// static member variables
-//////////
-
-// protected
-
-unsigned power::precedence = 60;
-
// helper function
ex sqrt(const ex & a)