]> www.ginac.de Git - ginac.git/blobdiff - check/exam_inifcns.cpp
Make it possible to override info() for functions.
[ginac.git] / check / exam_inifcns.cpp
index c108ada8574c1f8387218c3169ed7607143215f0..30d5b2128bac37df222fa1c8716561818d4dea0c 100644 (file)
@@ -4,7 +4,7 @@
  *  functions. */
 
 /*
- *  GiNaC Copyright (C) 1999-2003 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;
+
+#include <iostream>
+using namespace std;
 
 /* Assorted tests on other transcendental functions. */
 static unsigned inifcns_consist_trans()
 {
        using GiNaC::asin; using GiNaC::acos;
+       using GiNaC::asinh; using GiNaC::acosh; using GiNaC::atanh;
 
        unsigned result = 0;
        symbol x("x");
@@ -120,6 +125,7 @@ static unsigned inifcns_consist_trans()
  * exists in closed form and check if it's ok. */
 static unsigned inifcns_consist_gamma()
 {
+       using GiNaC::tgamma;
        unsigned result = 0;
        ex e;
        
@@ -166,6 +172,7 @@ static unsigned inifcns_consist_gamma()
 static unsigned inifcns_consist_psi()
 {
        using GiNaC::log;
+       using GiNaC::tgamma;
 
        unsigned result = 0;
        symbol x;
@@ -212,24 +219,78 @@ static unsigned inifcns_consist_zeta()
        return result;
 }
 
+static unsigned inifcns_consist_abs()
+{
+       unsigned result = 0;
+       realsymbol a("a"), b("b"), x("x"), y("y");
+       possymbol p("p");
+       symbol z("z");
+
+       if (!abs(exp(x+I*y)).eval().is_equal(exp(x)))
+               ++result;
+
+       if (!abs(pow(p,a+I*b)).eval().is_equal(pow(p,a)))
+               ++result;
+
+       // also checks that abs(p)=p
+       if (!abs(pow(p,a+I*b)).eval().is_equal(pow(p,a)))
+               ++result;
+
+       if (!abs(pow(x+I*y,a)).eval().is_equal(pow(abs(x+I*y),a)))
+               ++result;
+
+       // it is not necessary a simplification if the following is really evaluated
+       if (!abs(pow(x+I*y,a+I*b)).eval().is_equal(abs(pow(x+I*y,a+I*b))))
+               ++result;
+
+       if (!abs(z.conjugate()).eval().is_equal(abs(z)))
+               ++result;
+
+       if (!abs(step(z)).eval().is_equal(step(z)))
+               ++result;
+
+       if (!abs(p).info(info_flags::positive) || !abs(a).info(info_flags::real))
+               ++result;
+
+       if (abs(a).info(info_flags::positive) || !abs(a).info(info_flags::real))
+               ++result;
+
+       if (abs(z).info(info_flags::positive) || !abs(z).info(info_flags::real))
+               ++result;
+
+       return result;
+}
+
+static unsigned inifcns_consist_various()
+{
+       unsigned result = 0;
+       symbol n;
+       
+       if ( binomial(n, 0) != 1 ) {
+               clog << "ERROR: binomial(n,0) != 1" << endl;            
+               ++result;
+       }
+       
+       return result;
+}
+
 unsigned exam_inifcns()
 {
        unsigned result = 0;
        
        cout << "examining consistency of symbolic functions" << flush;
-       clog << "----------consistency of symbolic functions:" << endl;
        
        result += inifcns_consist_trans();  cout << '.' << flush;
        result += inifcns_consist_gamma();  cout << '.' << flush;
        result += inifcns_consist_psi();  cout << '.' << flush;
        result += inifcns_consist_zeta();  cout << '.' << flush;
-       
-       if (!result) {
-               cout << " passed " << endl;
-               clog << "(no output)" << endl;
-       } else {
-               cout << " failed " << endl;
-       }
+       result += inifcns_consist_abs();  cout << '.' << flush;
+       result += inifcns_consist_various();  cout << '.' << flush;
        
        return result;
 }
+
+int main(int argc, char** argv)
+{
+       return exam_inifcns();
+}