X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=check%2Fcheck_inifcns.cpp;h=b0c14411ac884914afd353bfe39eeb5f1ca6fe32;hb=293ff6f6fe89c3e5413c8da57feedf3bd2016cd7;hp=bec2ed97c602eb0bc509fce9b96d82c313d20f31;hpb=af922d5eb36ed70e4a9e3ffaf4c24492cf89a1a6;p=ginac.git diff --git a/check/check_inifcns.cpp b/check/check_inifcns.cpp index bec2ed97..b0c14411 100644 --- a/check/check_inifcns.cpp +++ b/check/check_inifcns.cpp @@ -4,7 +4,7 @@ * functions. */ /* - * GiNaC Copyright (C) 1999-2000 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 @@ -18,13 +18,18 @@ * * 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 "checks.h" +#include "ginac.h" +using namespace GiNaC; + +#include // for rand() +#include +using namespace std; /* Some tests on the sine trigonometric function. */ -static unsigned inifcns_check_sin(void) +static unsigned inifcns_check_sin() { unsigned result = 0; bool errorflag = false; @@ -39,7 +44,7 @@ static unsigned inifcns_check_sin(void) if (errorflag) { // we don't count each of those errors clog << "sin(n*Pi) with integer n does not always return exact 0" - << endl; + << endl; ++result; } @@ -47,13 +52,13 @@ static unsigned inifcns_check_sin(void) errorflag = false; for (int n=-10; n<=10; ++n) { if (!sin((n+numeric(1,2))*Pi).eval().info(info_flags::integer) || - !(sin((n+numeric(1,2))*Pi).eval() == numeric(1) || - sin((n+numeric(1,2))*Pi).eval() == numeric(-1))) + !(sin((n+numeric(1,2))*Pi).eval() == numeric(1) || + sin((n+numeric(1,2))*Pi).eval() == numeric(-1))) errorflag = true; } if (errorflag) { clog << "sin((n+1/2)*Pi) with integer n does not always return exact {+|-}1" - << endl; + << endl; ++result; } @@ -68,7 +73,7 @@ static unsigned inifcns_check_sin(void) argument = n*Pi/60; if (abs(sin(evalf(argument))-evalf(sin(argument)))>epsilon) { clog << "sin(" << argument << ") returns " - << sin(argument) << endl; + << sin(argument) << endl; errorflag = true; } } @@ -79,7 +84,7 @@ static unsigned inifcns_check_sin(void) } /* Simple tests on the cosine trigonometric function. */ -static unsigned inifcns_check_cos(void) +static unsigned inifcns_check_cos() { unsigned result = 0; bool errorflag; @@ -88,12 +93,12 @@ static unsigned inifcns_check_cos(void) errorflag = false; for (int n=-10; n<=10; ++n) { if (cos((n+numeric(1,2))*Pi).eval() != numeric(0) || - !cos((n+numeric(1,2))*Pi).eval().info(info_flags::integer)) + !cos((n+numeric(1,2))*Pi).eval().info(info_flags::integer)) errorflag = true; } if (errorflag) { clog << "cos((n+1/2)*Pi) with integer n does not always return exact 0" - << endl; + << endl; ++result; } @@ -101,13 +106,13 @@ static unsigned inifcns_check_cos(void) errorflag = false; for (int n=-10; n<=10; ++n) { if (!cos(n*Pi).eval().info(info_flags::integer) || - !(cos(n*Pi).eval() == numeric(1) || - cos(n*Pi).eval() == numeric(-1))) + !(cos(n*Pi).eval() == numeric(1) || + cos(n*Pi).eval() == numeric(-1))) errorflag = true; } if (errorflag) { clog << "cos(n*Pi) with integer n does not always return exact {+|-}1" - << endl; + << endl; ++result; } @@ -122,7 +127,7 @@ static unsigned inifcns_check_cos(void) argument = n*Pi/60; if (abs(cos(evalf(argument))-evalf(cos(argument)))>epsilon) { clog << "cos(" << argument << ") returns " - << cos(argument) << endl; + << cos(argument) << endl; errorflag = true; } } @@ -133,7 +138,7 @@ static unsigned inifcns_check_cos(void) } /* Simple tests on the tangent trigonometric function. */ -static unsigned inifcns_check_tan(void) +static unsigned inifcns_check_tan() { unsigned result = 0; bool errorflag; @@ -151,7 +156,7 @@ static unsigned inifcns_check_tan(void) argument = n*Pi/60; if (abs(tan(evalf(argument))-evalf(tan(argument)))>epsilon) { clog << "tan(" << argument << ") returns " - << tan(argument) << endl; + << tan(argument) << endl; errorflag = true; } } @@ -162,7 +167,7 @@ static unsigned inifcns_check_tan(void) } /* Simple tests on the dilogarithm function. */ -static unsigned inifcns_check_Li2(void) +static unsigned inifcns_check_Li2() { // NOTE: this can safely be removed once CLN supports dilogarithms and // checks them itself. @@ -176,10 +181,10 @@ static unsigned inifcns_check_Li2(void) numeric epsilon(double(1e-16)); for (int n=0; n<200; ++n) { argument = numeric(20.0*rand()/(RAND_MAX+1.0)-10.0) - + numeric(20.0*rand()/(RAND_MAX+1.0)-10.0)*I; + + numeric(20.0*rand()/(RAND_MAX+1.0)-10.0)*I; if (abs(Li2(pow(argument,2))-2*Li2(argument)-2*Li2(-argument)) > epsilon) { - cout << "Li2(z) at z==" << argument - << " failed to satisfy Li2(z^2)==2*(Li2(z)+Li2(-z))" << endl; + clog << "Li2(z) at z==" << argument + << " failed to satisfy Li2(z^2)==2*(Li2(z)+Li2(-z))" << endl; errorflag = true; } } @@ -190,24 +195,21 @@ static unsigned inifcns_check_Li2(void) return result; } -unsigned check_inifcns(void) +unsigned check_inifcns() { unsigned result = 0; cout << "checking consistency of symbolic functions" << flush; - clog << "---------consistency of symbolic functions:" << endl; result += inifcns_check_sin(); cout << '.' << flush; result += inifcns_check_cos(); cout << '.' << flush; result += inifcns_check_tan(); cout << '.' << flush; result += inifcns_check_Li2(); cout << '.' << flush; - if (!result) { - cout << " passed " << endl; - clog << "(no output)" << endl; - } else { - cout << " failed " << endl; - } - return result; } + +int main(int argc, char** argv) +{ + return check_inifcns(); +}