]> www.ginac.de Git - ginac.git/blobdiff - ginac/basic.cpp
- Make diff() care for evaluating stuff.
[ginac.git] / ginac / basic.cpp
index 43dbf3366cebc54fb98a7b1810a889b9e5c89f97..cf69c42cd2263dcfb722790ff65a7e2bacd4d8f6 100644 (file)
@@ -302,11 +302,16 @@ ex basic::subs(const lst & ls, const lst & lr) const
  *  @see ex::diff */
 ex basic::diff(const symbol & s, unsigned nth) const
 {
-    // FIXME: Check if it is evaluated!
+    // trivial: zeroth derivative
     if (!nth)
         return ex(*this);
+    
+    // evaluate unevalueted *this before differentiating
+    if (!(flags & status_flags::evaluated))
+        return ex(*this).diff(s, nth);
+    
     ex ndiff = derivative(s);
-    while (!ndiff.is_zero() &&    // stop differentiating zeroes
+    while (!ndiff.is_zero() &&    // stop differentiating zeros
            nth>1) {
         ndiff = ndiff.diff(s);
         --nth;