]> www.ginac.de Git - ginac.git/blobdiff - ginac/power.cpp
Remove 'level' argument of evalf().
[ginac.git] / ginac / power.cpp
index 8e62af8b5e4f98c6b5e59f786f8ddb05efc0bd36..5cddca8995bd475c6b6f56f5a7c8d5670280fa6a 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's symbolic exponentiation (basis^exponent). */
 
 /*
- *  GiNaC Copyright (C) 1999-2015 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2016 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -229,18 +229,18 @@ bool power::info(unsigned inf) const
                case info_flags::cinteger_polynomial:
                case info_flags::rational_polynomial:
                case info_flags::crational_polynomial:
-                       return exponent.info(info_flags::nonnegint) &&
-                              basis.info(inf);
+                       return basis.info(inf) && exponent.info(info_flags::nonnegint);
                case info_flags::rational_function:
-                       return exponent.info(info_flags::integer) &&
-                              basis.info(inf);
+                       return basis.info(inf) && exponent.info(info_flags::integer);
+               case info_flags::real:
+                       return basis.info(inf) && exponent.info(info_flags::integer);
                case info_flags::expanded:
                        return (flags & status_flags::expanded);
                case info_flags::positive:
                        return basis.info(info_flags::positive) && exponent.info(info_flags::real);
                case info_flags::nonnegative:
                        return (basis.info(info_flags::positive) && exponent.info(info_flags::real)) ||
-                              (basis.info(info_flags::real) && exponent.info(info_flags::integer) && exponent.info(info_flags::even));
+                              (basis.info(info_flags::real) && exponent.info(info_flags::even));
                case info_flags::has_indices: {
                        if (flags & status_flags::has_indices)
                                return true;
@@ -562,23 +562,15 @@ ex power::eval() const
        return this->hold();
 }
 
-ex power::evalf(int level) const
+ex power::evalf() const
 {
-       ex ebasis;
+       ex ebasis = basis.evalf();
        ex eexponent;
        
-       if (level==1) {
-               ebasis = basis;
+       if (!is_exactly_a<numeric>(exponent))
+               eexponent = exponent.evalf();
+       else
                eexponent = exponent;
-       } else if (level == -max_recursion_level) {
-               throw(std::runtime_error("max recursion level reached"));
-       } else {
-               ebasis = basis.evalf(level-1);
-               if (!is_exactly_a<numeric>(exponent))
-                       eexponent = exponent.evalf(level-1);
-               else
-                       eexponent = exponent;
-       }
 
        return dynallocate<power>(ebasis, eexponent);
 }