]> www.ginac.de Git - ginac.git/commitdiff
Synced to HEAD:
authorJens Vollinga <vollinga@thep.physik.uni-mainz.de>
Mon, 15 Oct 2007 23:47:27 +0000 (23:47 +0000)
committerJens Vollinga <vollinga@thep.physik.uni-mainz.de>
Mon, 15 Oct 2007 23:47:27 +0000 (23:47 +0000)
- info(info_flags::has_indices) now works for sums and products. It
returns true if the expression has indices (no matter dummy or free),
and false otherwise [Sheplyakov].

ginac/expairseq.cpp
ginac/flags.h
ginac/idx.cpp
ginac/power.cpp
ginac/symbol.cpp

index be8790f00559f73e288398ee80d2a1c7deecfe9d..97cf9611b4e41ce67d2e96cd4b08ed7f75e1fb94 100644 (file)
@@ -24,6 +24,7 @@
 #include <algorithm>
 #include <string>
 #include <stdexcept>
+#include <iterator>
 
 #include "expairseq.h"
 #include "lst.h"
@@ -261,8 +262,26 @@ void expairseq::do_print_tree(const print_tree & c, unsigned level) const
 
 bool expairseq::info(unsigned inf) const
 {
-       if (inf == info_flags::expanded)
-               return (flags & status_flags::expanded);
+       switch(inf) {
+               case info_flags::expanded:
+                       return (flags & status_flags::expanded);
+               case info_flags::has_indices: {
+                       if (flags & status_flags::has_indices)
+                               return true;
+                       else if (flags & status_flags::has_no_indices)
+                               return false;
+                       for (epvector::const_iterator i = seq.begin(); i != seq.end(); ++i) {
+                               if (i->rest.info(info_flags::has_indices)) {
+                                       this->setflag(status_flags::has_indices);
+                                       this->clearflag(status_flags::has_no_indices);
+                                       return true;
+                               }
+                       }
+                       this->clearflag(status_flags::has_indices);
+                       this->setflag(status_flags::has_no_indices);
+                       return false;
+               }
+       }
        return inherited::info(inf);
 }
 
index a42f869d6c69a850db7a2f1a19a904a2ce3ac26c..33622f9b67404d6a2932368a007a407a3091b39d 100644 (file)
@@ -179,7 +179,9 @@ public:
                evaluated       = 0x0002, ///< .eval() has already done its job
                expanded        = 0x0004, ///< .expand(0) has already done its job (other expand() options ignore this flag)
                hash_calculated = 0x0008, ///< .calchash() has already done its job
-               not_shareable   = 0x0010  ///< don't share instances of this object between different expressions unless explicitly asked to (used by ex::compare())
+               not_shareable   = 0x0010, ///< don't share instances of this object between different expressions unless explicitly asked to (used by ex::compare())
+               has_indices     = 0x0020,
+               has_no_indices  = 0x0040  // ! (has_indices || has_no_indices) means "don't know"
        };
 };
 
index 3d363e0c88be96043b5bfa1595153375c2ec88a7..601a77ce02a717235535e2660132da445c790783 100644 (file)
@@ -232,8 +232,11 @@ void spinidx::do_print_tree(const print_tree & c, unsigned level) const
 
 bool idx::info(unsigned inf) const
 {
-       if (inf == info_flags::idx)
-               return true;
+       switch(inf) {
+               case info_flags::idx:
+               case info_flags::has_indices:
+                       return true;
+       }
        return inherited::info(inf);
 }
 
index f243147aa46932836e2077334642068b7171088c..676b862fc9ba4aa71a482aa8f0500048ebb476ad 100644 (file)
@@ -240,6 +240,21 @@ bool power::info(unsigned inf) const
                               basis.info(inf);
                case info_flags::expanded:
                        return (flags & status_flags::expanded);
+               case info_flags::has_indices: {
+                       if (flags & status_flags::has_indices)
+                               return true;
+                       else if (flags & status_flags::has_no_indices)
+                               return false;
+                       else if (basis.info(info_flags::has_indices)) {
+                               setflag(status_flags::has_indices);
+                               clearflag(status_flags::has_no_indices);
+                               return true;
+                       } else {
+                               clearflag(status_flags::has_indices);
+                               setflag(status_flags::has_no_indices);
+                               return false;
+                       }
+               }
        }
        return inherited::info(inf);
 }
index 2edd7149adb1f195a35625d09031013fdd886d4f..0e51f0e588f9a08bd938333c7fdbceae896b416f 100644 (file)
@@ -190,20 +190,22 @@ void symbol::do_print_python_repr(const print_python_repr & c, unsigned level) c
 
 bool symbol::info(unsigned inf) const
 {
-       if (inf == info_flags::symbol)
-               return true;
-       if (inf == info_flags::polynomial ||
-           inf == info_flags::integer_polynomial ||
-           inf == info_flags::cinteger_polynomial ||
-           inf == info_flags::rational_polynomial ||
-           inf == info_flags::crational_polynomial ||
-           inf == info_flags::rational_function ||
-                       inf == info_flags::expanded)
-               return true;
-       if (inf == info_flags::real)
-               return domain == domain::real;
-       else
-               return inherited::info(inf);
+       switch (inf) {
+               case info_flags::symbol:
+               case info_flags::polynomial:
+               case info_flags::integer_polynomial: 
+               case info_flags::cinteger_polynomial: 
+               case info_flags::rational_polynomial: 
+               case info_flags::crational_polynomial: 
+               case info_flags::rational_function: 
+               case info_flags::expanded:
+                       return true;
+               case info_flags::has_indices:
+                       return false;
+               case info_flags::real:
+                       return domain == domain::real;
+       }
+       return inherited::info(inf);
 }
 
 ex symbol::eval(int level) const