]> www.ginac.de Git - ginac.git/blobdiff - ginac/power.cpp
- Apparently, in ~ 30% of calls to mul::expand the expression is monomial.
[ginac.git] / ginac / power.cpp
index 68bec71c949c4866fd2c949c2c9df0db78ec2112..1b28b509ac4bd35ef4bbcf7777e40069bcf056f2 100644 (file)
@@ -241,6 +241,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);
 }
@@ -757,6 +772,9 @@ tinfo_t power::return_type_tinfo() const
 
 ex power::expand(unsigned options) const
 {
+       if (is_a<symbol>(basis) && exponent.info(info_flags::integer))
+               return (new power(*this))->setflag(status_flags::dynallocated | status_flags::expanded);
+
        if (options == 0 && (flags & status_flags::expanded))
                return *this;