X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fpower.cpp;h=15fed248b889d73b24fd3954ed01c6f659152c3e;hp=d4c12c17d8da76dfc2b599148fc9ecc585d5f286;hb=71e787d41185b5def2c4dde6809c8420843fca9f;hpb=b9cd4b49ffbfbf3e1c36a2b594ec3148a5baca64 diff --git a/ginac/power.cpp b/ginac/power.cpp index d4c12c17..15fed248 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -144,7 +144,7 @@ void power::print(const print_context & c, unsigned level) const && (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)) @@ -153,7 +153,7 @@ void power::print(const print_context & c, unsigned level) const c.s << "1.0/("; } print_sym_pow(c, ex_to_symbol(basis), exp); - c.s << ")"; + c.s << ')'; // ^-1 is printed as "1.0/" or with the recip() function of CLN } else if (exponent.compare(_num_1()) == 0) { @@ -162,7 +162,7 @@ void power::print(const print_context & c, unsigned level) const else c.s << "1.0/("; basis.print(c); - c.s << ")"; + c.s << ')'; // Otherwise, use the pow() or expt() (CLN) functions } else { @@ -171,9 +171,9 @@ void power::print(const print_context & c, unsigned level) const else c.s << "pow("; basis.print(c); - c.s << ","; + c.s << ','; exponent.print(c); - c.s << ")"; + c.s << ')'; } } else { @@ -185,9 +185,9 @@ void power::print(const print_context & c, unsigned level) const 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 (is_of_type(c, print_latex)) @@ -196,13 +196,17 @@ void power::print(const print_context & c, unsigned level) const c.s << "("; } basis.print(c, precedence()); - c.s << "^"; + 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 << ')'; } } }