From: Richard Kreckel Date: Sat, 28 Jul 2001 18:50:22 +0000 (+0000) Subject: - Move several comments into doxygen comment blocks. X-Git-Tag: release_0-9-2~12 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=c378e979c7a9b9807941b27adbac690699abe70c - Move several comments into doxygen comment blocks. --- diff --git a/NEWS b/NEWS index 2d618358..fb026231 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ This file records noteworthy changes. 0.9.2 () * Epsilon tensor is more functional. +* Several little bugfixes and consistency enhancements. 0.9.1 (27 June 2001) * Ctors of class numeric are not explicit any more. All built-in callers for diff --git a/ginac/add.cpp b/ginac/add.cpp index b681a4f9..0551dbc4 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -307,11 +307,15 @@ ex add::coeff(const ex & s, int n) const return (new add(coeffseq, n==0 ? overall_coeff : _ex0()))->setflag(status_flags::dynallocated); } +/** Perform automatic term rewriting rules in this class. In the following + * x stands for a symbolic variables of type ex and c stands for such + * an expression that contain a plain number. + * - +(;c) -> c + * - +(x;1) -> x + * + * @param level cut-off in recursive evaluation */ ex add::eval(int level) const { - // simplifications: +(;c) -> c - // +(x;1) -> x - debugmsg("add eval",LOGLEVEL_MEMBER_FUNCTION); epvector *evaled_seqp = evalchildren(level); diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 36ea6419..8baa3536 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -345,7 +345,7 @@ done: delete[] si; return x + (*this - x).expand(); } -/** Perform automatic non-interruptive symbolic evaluation on expression. */ +/** Perform automatic non-interruptive term rewriting rules. */ ex basic::eval(int level) const { // There is nothing to do for basic objects: diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp index d796e4b2..5f3dd290 100644 --- a/ginac/expairseq.cpp +++ b/ginac/expairseq.cpp @@ -317,6 +317,7 @@ ex expairseq::map(map_function & f) const return thisexpairseq(v, f(overall_coeff)); } +/** Perform coefficient-wise automatic term rewriting rules in this class. */ ex expairseq::eval(int level) const { if ((level==1) && (flags &status_flags::evaluated)) diff --git a/ginac/mul.cpp b/ginac/mul.cpp index 3cfb7ff6..cac1ffb7 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -330,13 +330,17 @@ ex mul::coeff(const ex & s, int n) const return _ex0(); } +/** Perform automatic term rewriting rules in this class. In the following + * x, x1, x2,... stand for a symbolic variables of type ex and c, c1, c2... + * stand for such expressions that contain a plain number. + * - *(...,x;0) -> 0 + * - *(+(x1,x2,...);c) -> *(+(*(x1,c),*(x2,c),...)) + * - *(x;1) -> x + * - *(;c) -> c + * + * @param level cut-off in recursive evaluation */ ex mul::eval(int level) const { - // simplifications *(...,x;0) -> 0 - // *(+(x,y,...);c) -> *(+(*(x,c),*(y,c),...)) (c numeric()) - // *(x;1) -> x - // *(;c) -> c - debugmsg("mul eval",LOGLEVEL_MEMBER_FUNCTION); epvector *evaled_seqp = evalchildren(level); diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp index bfc2acdd..eecafef4 100644 --- a/ginac/ncmul.cpp +++ b/ginac/ncmul.cpp @@ -288,18 +288,20 @@ void ncmul::append_factors(exvector & v, const ex & e) const typedef std::vector unsignedvector; typedef std::vector exvectorvector; +/** Perform automatic term rewriting rules in this class. In the following + * x, x1, x2,... stand for a symbolic variables of type ex and c, c1, c2... + * stand for such expressions that contain a plain number. + * - ncmul(...,*(x1,x2),...,ncmul(x3,x4),...) -> ncmul(...,x1,x2,...,x3,x4,...) (associativity) + * - ncmul(x) -> x + * - ncmul() -> 1 + * - ncmul(...,c1,...,c2,...) -> *(c1,c2,ncmul(...)) (pull out commutative elements) + * - ncmul(x1,y1,x2,y2) -> *(ncmul(x1,x2),ncmul(y1,y2)) (collect elements of same type) + * - ncmul(x1,x2,x3,...) -> x::simplify_ncmul(x1,x2,x3,...) + * + * @param level cut-off in recursive evaluation */ ex ncmul::eval(int level) const { - // simplifications: ncmul(...,*(x1,x2),...,ncmul(x3,x4),...) -> - // ncmul(...,x1,x2,...,x3,x4,...) (associativity) - // ncmul(x) -> x - // ncmul() -> 1 - // ncmul(...,c1,...,c2,...) - // *(c1,c2,ncmul(...)) (pull out commutative elements) - // ncmul(x1,y1,x2,y2) -> *(ncmul(x1,x2),ncmul(y1,y2)) - // (collect elements of same type) - // ncmul(x1,x2,x3,...) -> x::simplify_ncmul(x1,x2,x3,...) - // the following rule would be nice, but produces a recursion, + // The following additional rule would be nice, but produces a recursion, // which must be trapped by introducing a flag that the sub-ncmuls() // are already evaluated (maybe later...) // ncmul(x1,x2,...,X,y1,y2,...) -> @@ -313,7 +315,7 @@ ex ncmul::eval(int level) const exvector evaledseq=evalchildren(level); // ncmul(...,*(x1,x2),...,ncmul(x3,x4),...) -> - // ncmul(...,x1,x2,...,x3,x4,...) (associativity) + // ncmul(...,x1,x2,...,x3,x4,...) (associativity) unsigned factors = 0; exvector::const_iterator cit = evaledseq.begin(), citend = evaledseq.end(); while (cit != citend) diff --git a/ginac/power.cpp b/ginac/power.cpp index 3400e6aa..f292ff8b 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -99,7 +99,7 @@ static void print_sym_pow(const print_context & c, const symbol &x, int exp) { // Optimal output of integer powers of symbols to aid compiler CSE. // C.f. ISO/IEC 14882:1998, section 1.9 [intro execution], paragraph 15 - // to learn why such a hack is really necessary. + // to learn why such a parenthisation is really necessary. if (exp == 1) { x.print(c); } else if (exp == 2) { @@ -293,18 +293,22 @@ ex power::coeff(const ex & s, int n) const } } +/** Perform automatic term rewriting rules in this class. In the following + * x, x1, x2,... stand for a symbolic variables of type ex and c, c1, c2... + * stand for such expressions that contain a plain number. + * - ^(x,0) -> 1 (also handles ^(0,0)) + * - ^(x,1) -> x + * - ^(0,c) -> 0 or exception (depending on the real part of c) + * - ^(1,x) -> 1 + * - ^(c1,c2) -> *(c1^n,c1^(c2-n)) (so that 0<(c2-n)<1, try to evaluate roots, possibly in numerator and denominator of c1) + * - ^(^(x,c1),c2) -> ^(x,c1*c2) (c2 integer or -1 < c1 <= 1, case c1=1 should not happen, see below!) + * - ^(*(x,y,z),c) -> *(x^c,y^c,z^c) (if c integer) + * - ^(*(x,c1),c2) -> ^(x,c2)*c1^c2 (c1>0) + * - ^(*(x,c1),c2) -> ^(-x,c2)*c1^c2 (c1<0) + * + * @param level cut-off in recursive evaluation */ ex power::eval(int level) const { - // simplifications: ^(x,0) -> 1 (0^0 handled here) - // ^(x,1) -> x - // ^(0,c1) -> 0 or exception (depending on real value of c1) - // ^(1,x) -> 1 - // ^(c1,c2) -> *(c1^n,c1^(c2-n)) (c1, c2 numeric(), 0<(c2-n)<1 except if c1,c2 are rational, but c1^c2 is not) - // ^(^(x,c1),c2) -> ^(x,c1*c2) (c1, c2 numeric(), c2 integer or -1 < c1 <= 1, case c1=1 should not happen, see below!) - // ^(*(x,y,z),c1) -> *(x^c1,y^c1,z^c1) (c1 integer) - // ^(*(x,c1),c2) -> ^(x,c2)*c1^c2 (c1, c2 numeric(), c1>0) - // ^(*(x,c1),c2) -> ^(-x,c2)*c1^c2 (c1, c2 numeric(), c1<0) - debugmsg("power eval",LOGLEVEL_MEMBER_FUNCTION); if ((level==1) && (flags & status_flags::evaluated)) @@ -329,7 +333,7 @@ ex power::eval(int level) const num_exponent = static_cast(eexponent.bp); } - // ^(x,0) -> 1 (0^0 also handled here) + // ^(x,0) -> 1 (0^0 also handled here) if (eexponent.is_zero()) { if (ebasis.is_zero()) throw (std::domain_error("power::eval(): pow(0,0) is undefined")); @@ -341,7 +345,7 @@ ex power::eval(int level) const if (eexponent.is_equal(_ex1())) return ebasis; - // ^(0,c1) -> 0 or exception (depending on real value of c1) + // ^(0,c1) -> 0 or exception (depending on real value of c1) if (ebasis.is_zero() && exponent_is_numerical) { if ((num_exponent->real()).is_zero()) throw (std::domain_error("power::eval(): pow(0,I) is undefined")); @@ -357,7 +361,7 @@ ex power::eval(int level) const if (exponent_is_numerical) { - // ^(c1,c2) -> c1^c2 (c1, c2 numeric(), + // ^(c1,c2) -> c1^c2 (c1, c2 numeric(), // except if c1,c2 are rational, but c1^c2 is not) if (basis_is_numerical) { const bool basis_is_crational = num_basis->is_crational(); @@ -432,8 +436,8 @@ ex power::eval(int level) const return expand_mul(ex_to(ebasis), *num_exponent); } - // ^(*(...,x;c1),c2) -> ^(*(...,x;1),c2)*c1^c2 (c1, c2 numeric(), c1>0) - // ^(*(...,x,c1),c2) -> ^(*(...,x;-1),c2)*(-c1)^c2 (c1, c2 numeric(), c1<0) + // ^(*(...,x;c1),c2) -> *(^(*(...,x;1),c2),c1^c2) (c1, c2 numeric(), c1>0) + // ^(*(...,x;c1),c2) -> *(^(*(...,x;-1),c2),(-c1)^c2) (c1, c2 numeric(), c1<0) if (is_ex_exactly_of_type(ebasis,mul)) { GINAC_ASSERT(!num_exponent->is_integer()); // should have been handled above const mul & mulref = ex_to(ebasis); diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index 398ca82c..720fb9c7 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -356,7 +356,7 @@ ex pseries::collect(const ex &s, bool distributed) const return *this; } -/** Evaluate coefficients. */ +/** Perform coefficient-wise automatic term rewriting rules in this class. */ ex pseries::eval(int level) const { if (level == 1)