]> www.ginac.de Git - ginac.git/blobdiff - ginac/power.cpp
- introduced info_flag::algebraic.
[ginac.git] / ginac / power.cpp
index bbac8d07e99975500f9a8bb856f3666eead1cd60..8ec1945f718ea833571b978448ceee7d68469f3f 100644 (file)
@@ -250,17 +250,20 @@ void power::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) co
 
 bool power::info(unsigned inf) const
 {
-    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) {
-        return exponent.info(info_flags::nonnegint);
-    } else if (inf==info_flags::rational_function) {
-        return exponent.info(info_flags::integer);
-    } else {
-        return inherited::info(inf);
+    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:
+            return exponent.info(info_flags::nonnegint);
+        case info_flags::rational_function:
+            return exponent.info(info_flags::integer);
+        case info_flags::algebraic:
+            return (!exponent.info(info_flags::integer) ||
+                    basis.info(inf));
     }
+    return inherited::info(inf);
 }
 
 unsigned power::nops() const
@@ -632,7 +635,10 @@ ex power::expand_add(const add & a, int n) const
             GINAC_ASSERT(!is_ex_exactly_of_type(b,add));
             GINAC_ASSERT(!is_ex_exactly_of_type(b,power)||
                          !is_ex_exactly_of_type(ex_to_power(b).exponent,numeric)||
-                         !ex_to_numeric(ex_to_power(b).exponent).is_pos_integer());
+                         !ex_to_numeric(ex_to_power(b).exponent).is_pos_integer()||
+                         !is_ex_exactly_of_type(ex_to_power(b).basis,add)||
+                         !is_ex_exactly_of_type(ex_to_power(b).basis,mul)||
+                         !is_ex_exactly_of_type(ex_to_power(b).basis,power));
             if (is_ex_exactly_of_type(b,mul)) {
                 term.push_back(expand_mul(ex_to_mul(b),numeric(k[l])));
             } else {
@@ -644,7 +650,10 @@ ex power::expand_add(const add & a, int n) const
         GINAC_ASSERT(!is_ex_exactly_of_type(b,add));
         GINAC_ASSERT(!is_ex_exactly_of_type(b,power)||
                      !is_ex_exactly_of_type(ex_to_power(b).exponent,numeric)||
-                     !ex_to_numeric(ex_to_power(b).exponent).is_pos_integer());
+                     !ex_to_numeric(ex_to_power(b).exponent).is_pos_integer()||
+                     !is_ex_exactly_of_type(ex_to_power(b).basis,add)||
+                     !is_ex_exactly_of_type(ex_to_power(b).basis,mul)||
+                     !is_ex_exactly_of_type(ex_to_power(b).basis,power));
         if (is_ex_exactly_of_type(b,mul)) {
             term.push_back(expand_mul(ex_to_mul(b),numeric(n-k_cum[m-2])));
         } else {