- introduced info_flag::algebraic.
[ginac.git] / ginac / add.cpp
index 717279b57ef65803e76debd4d54be80f7fe4e02a..8a7e9041fff631cfdb78d29bb833cad64e97d950 100644 (file)
@@ -290,21 +290,28 @@ void add::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) cons
 
 bool add::info(unsigned inf) const
 {
-    // TODO: optimize
-    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) {
-        for (epvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
-            if (!(recombine_pair_to_ex(*it).info(inf)))
-                return false;
+    switch (inf) {
+        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: {
+            for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
+                if (!(recombine_pair_to_ex(*i).info(inf)))
+                    return false;
+            }
+            return overall_coeff.info(inf);
+        }
+        case info_flags::algebraic: {
+            for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
+                if ((recombine_pair_to_ex(*i).info(inf)))
+                    return true;
+            }
+            return false;
         }
-        return overall_coeff.info(inf);
-    } else {
-        return inherited::info(inf);
     }
+    return inherited::info(inf);
 }
 
 int add::degree(const symbol & s) const