]> www.ginac.de Git - ginac.git/commitdiff
- Move several comments into doxygen comment blocks.
authorRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Sat, 28 Jul 2001 18:50:22 +0000 (18:50 +0000)
committerRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Sat, 28 Jul 2001 18:50:22 +0000 (18:50 +0000)
NEWS
ginac/add.cpp
ginac/basic.cpp
ginac/expairseq.cpp
ginac/mul.cpp
ginac/ncmul.cpp
ginac/power.cpp
ginac/pseries.cpp

diff --git a/NEWS b/NEWS
index 2d61835837ade60ae89b047ae7726ec7f5727912..fb02623172cf538cbe6fb2ea3b121636c3317c6c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ This file records noteworthy changes.
 
 0.9.2 (<insert date here>)
 * Epsilon tensor is more functional.
 
 0.9.2 (<insert date here>)
 * 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
 
 0.9.1 (27 June 2001)
 * Ctors of class numeric are not explicit any more.  All built-in callers for
index b681a4f9f757be97195cbd34117118480540f887..0551dbc485fd8156bcbfc06364034115d2c86101 100644 (file)
@@ -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);
 }
 
        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
 {
 ex add::eval(int level) const
 {
-       // simplifications: +(;c) -> c
-       //                  +(x;1) -> x
-       
        debugmsg("add eval",LOGLEVEL_MEMBER_FUNCTION);
        
        epvector *evaled_seqp = evalchildren(level);
        debugmsg("add eval",LOGLEVEL_MEMBER_FUNCTION);
        
        epvector *evaled_seqp = evalchildren(level);
index 36ea6419e2217ccb9479db681b9e77a446668e86..8baa3536a83d296e78facabc7436d4cdefa46a2e 100644 (file)
@@ -345,7 +345,7 @@ done:               delete[] si;
        return x + (*this - x).expand();
 }
 
        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:
 ex basic::eval(int level) const
 {
        // There is nothing to do for basic objects:
index d796e4b2e8054440a7566634694849fb19a5dc6e..5f3dd2904b2bbb10d1dc596ec3beadedfbb0af51 100644 (file)
@@ -317,6 +317,7 @@ ex expairseq::map(map_function & f) const
                return thisexpairseq(v, f(overall_coeff));
 }
 
                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))
 ex expairseq::eval(int level) const
 {
        if ((level==1) && (flags &status_flags::evaluated))
index 3cfb7ff6c437d4aeb7c82fb87cfc39f436e6588f..cac1ffb7a14e99b2c9a5825d3aac7ac17dd5eb5d 100644 (file)
@@ -330,13 +330,17 @@ ex mul::coeff(const ex & s, int n) const
        return _ex0();
 }
 
        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
 {
 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);
        debugmsg("mul eval",LOGLEVEL_MEMBER_FUNCTION);
        
        epvector *evaled_seqp = evalchildren(level);
index bfc2acdd5cbf2e612b9664ff6d2ff0dfe6559591..eecafef4f3fb5af7661f9a667ce576778ffff0aa 100644 (file)
@@ -288,18 +288,20 @@ void ncmul::append_factors(exvector & v, const ex & e) const
 typedef std::vector<unsigned> unsignedvector;
 typedef std::vector<exvector> exvectorvector;
 
 typedef std::vector<unsigned> unsignedvector;
 typedef std::vector<exvector> 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
 {
 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,...) ->
        // 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),...) ->
        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)
        unsigned factors = 0;
        exvector::const_iterator cit = evaledseq.begin(), citend = evaledseq.end();
        while (cit != citend)
index 3400e6aa0cfeba2757e0c1a8cef9e0f1f0f8d1b4..f292ff8b0daecc4f4d50d710d2358128eb8f2551 100644 (file)
@@ -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
 {
        // 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) {
        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
 {
 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))
        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<const numeric *>(eexponent.bp);
        }
        
                num_exponent = static_cast<const numeric *>(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"));
        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;
 
        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"));
        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) {
 
 
        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();
                // 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<mul>(ebasis), *num_exponent);
                }
        
                        return expand_mul(ex_to<mul>(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<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);
index 398ca82c13c24e0ec02c6e458d09abb4ba47aebd..720fb9c732daef58311ac1b46d296246c2ce8288 100644 (file)
@@ -356,7 +356,7 @@ ex pseries::collect(const ex &s, bool distributed) const
        return *this;
 }
 
        return *this;
 }
 
-/** Evaluate coefficients. */
+/** Perform coefficient-wise automatic term rewriting rules in this class. */
 ex pseries::eval(int level) const
 {
        if (level == 1)
 ex pseries::eval(int level) const
 {
        if (level == 1)