]> www.ginac.de Git - ginac.git/blobdiff - check/exam_inifcns_nstdsums.cpp
Fix little missed optimization.
[ginac.git] / check / exam_inifcns_nstdsums.cpp
index d7273bb0fe4f9c2abd0fdc217cd8274537d0920c..c93d0b4a4f08279a979654f34794bf78b434a6e5 100644 (file)
@@ -4,7 +4,7 @@
  *  functions. */
 
 /*
- *  GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2015 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
@@ -313,14 +313,14 @@ static unsigned inifcns_test_legacy()
 
        ex x1 = exp(2*Pi*I/13).evalf();
        ex x2 = exp(24*Pi*I/13).evalf();
-       ex r2 = Li(lst(2),lst(x1)).hold().evalf();
+       ex r2 = Li(lst(2),lst(x1)).hold().evalf();
        ex r3 = Li(lst(2),lst(x2)).hold().evalf();
        if ( abs(r2-conjugate(r3)) > prec ) {
                clog << "Legacy test 2 seems to be wrong." << endl;
                result++;
        }
 
-       ex x3 = exp(5*Pi*I/3).evalf();
+       ex x3 = exp(5*Pi*I/3).evalf();
        ex r4 = Li(lst(3),lst(x3)).hold().evalf();
        if ( abs(r4 - numeric("0.40068563438653142847-0.95698384815740185713*I")) > prec ) {
                clog << "Legacy test 3 seems to be wrong." << endl;
@@ -365,6 +365,33 @@ static unsigned inifcns_test_legacy()
        return result;
 }
 
+static unsigned check_G_y_one_bug()
+{
+       exvector exprs;
+       exprs.push_back(G(lst(-1,-1, 1,-1, 0), 1));
+       exprs.push_back(G(lst(-1, 0, 1,-1, 0), 1));
+       exprs.push_back(G(lst(-1, 1,-1,-1, 0), 1));
+       exprs.push_back(G(lst(-1, 1,-1, 0, 0), 1));
+       exprs.push_back(G(lst(-1, 1,-1, 1, 0), 1));
+       exprs.push_back(G(lst(-1, 1, 0,-1, 0), 1));
+       exprs.push_back(G(lst(-1, 1, 1,-1, 0), 1));
+       exprs.push_back(G(lst( 0,-1, 1,-1, 0), 1));
+       exprs.push_back(G(lst( 0, 1, 1,-1, 0), 1));
+       unsigned err = 0;
+       for (exvector::const_iterator ep = exprs.begin(); ep != exprs.end(); ++ep) {
+               try {
+                       ex val = ep->evalf();
+                       if (!is_a<numeric>(val)) {
+                               clog << "evalf(" << *ep << ") is not a number: " << val << endl;
+                               ++err;
+                       }
+               } catch (std::exception& oops) {
+                       clog << "evalf(" << *ep << "): got an exception" << oops.what() << endl;
+                       ++err;
+               }
+       }
+       return err;
+}
 
 unsigned exam_inifcns_nstdsums(void)
 {
@@ -377,6 +404,7 @@ unsigned exam_inifcns_nstdsums(void)
        result += inifcns_test_HLi();
        result += inifcns_test_LiG();
        result += inifcns_test_legacy();
+       result += check_G_y_one_bug();
        
        return result;
 }