]> www.ginac.de Git - ginac.git/blobdiff - check/exam_powerlaws.cpp
Improve abs_eval(): abs(conjugate(z)) => abs(z), ...
[ginac.git] / check / exam_powerlaws.cpp
index 7da5c32d4a2882a14ad516a1bb2d20ed4f0da748..beb4dfb28d6f4da024b543114ff922f713066fc7 100644 (file)
@@ -4,7 +4,7 @@
  *  this code, it is a sanity check rather deeply rooted in GiNaC's classes. */
 
 /*
- *  GiNaC Copyright (C) 1999-2002 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2011 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
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include "exams.h"
+#include "ginac.h"
+using namespace GiNaC;
 
-static unsigned exam_powerlaws1(void)
+#include <iostream>
+using namespace std;
+
+static unsigned exam_powerlaws1()
 {
        // (x^a)^b = x^(a*b)
        
@@ -65,14 +69,14 @@ static unsigned exam_powerlaws1(void)
                return 1;
        }
        
-       ex e4 = e1.subs(lst(a==-1, b==2.5));
+       ex e4 = e1.subs(lst(a==-1, b==-2.5));
        if (!(is_exactly_a<power>(e4) &&
              is_exactly_a<power>(e4.op(0)) &&
              is_exactly_a<symbol>(e4.op(0).op(0)) &&
              is_exactly_a<numeric>(e4.op(0).op(1)) &&
              is_exactly_a<numeric>(e4.op(1)) &&
-             e4.is_equal(power(power(x,-1),2.5)) )) {
-               clog << "(x^a)^b, x symbolic, a==-1, b==2.5 wrong" << endl;
+             e4.is_equal(power(power(x,-1),-2.5)) )) {
+               clog << "(x^a)^b, x symbolic, a==-1, b==-2.5 wrong" << endl;
                clog << "returned: " << e4 << endl;
                return 1;
        }
@@ -100,7 +104,7 @@ static unsigned exam_powerlaws1(void)
        return 0;
 }
 
-static unsigned exam_powerlaws2(void)
+static unsigned exam_powerlaws2()
 {
        // (a*x)^b = a^b * x^b
        
@@ -198,7 +202,7 @@ static unsigned exam_powerlaws2(void)
        return 0;
 }
 
-static unsigned exam_powerlaws3(void)
+static unsigned exam_powerlaws3()
 {
        // numeric evaluation
 
@@ -237,7 +241,7 @@ static unsigned exam_powerlaws3(void)
        return 0;
 }
 
-static unsigned exam_powerlaws4(void)
+static unsigned exam_powerlaws4()
 {
        // test for mul::eval()
        
@@ -262,7 +266,7 @@ static unsigned exam_powerlaws4(void)
        return 0;
 }
 
-static unsigned exam_powerlaws5(void)
+static unsigned exam_powerlaws5()
 {
        // cabinet of slightly pathological cases
        
@@ -284,12 +288,11 @@ static unsigned exam_powerlaws5(void)
        return 0;
 }
 
-unsigned exam_powerlaws(void)
+unsigned exam_powerlaws()
 {
        unsigned result = 0;
        
        cout << "examining power laws" << flush;
-       clog << "----------power laws:" << endl;
        
        result += exam_powerlaws1();  cout << '.' << flush;
        result += exam_powerlaws2();  cout << '.' << flush;
@@ -297,12 +300,10 @@ unsigned exam_powerlaws(void)
        result += exam_powerlaws4();  cout << '.' << flush;
        result += exam_powerlaws5();  cout << '.' << flush;
        
-       if (!result) {
-               cout << " passed " << endl;
-               clog << "(no output)" << endl;
-       } else {
-               cout << " failed " << endl;
-       }
-       
        return result;
 }
+
+int main(int argc, char** argv)
+{
+       return exam_powerlaws();
+}