X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=check%2Fexam_pseries.cpp;h=a3fe7d87d496be2e0681c3e364f8a1cbe0af9ffe;hp=040c5e58a047d2e1712109467e95ea2493ca6a87;hb=6f64b39dd25e4d2dcc869995b3d19724fa72afa6;hpb=547db2f0380c03c7d013aa8bda36aa33ff5559e1 diff --git a/check/exam_pseries.cpp b/check/exam_pseries.cpp index 040c5e58..a3fe7d87 100644 --- a/check/exam_pseries.cpp +++ b/check/exam_pseries.cpp @@ -3,7 +3,7 @@ * Series expansion test (Laurent and Taylor series). */ /* - * GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2008 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 @@ -17,10 +17,13 @@ * * 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 +#include "ginac.h" +using namespace std; +using namespace GiNaC; static symbol x("x"); @@ -133,6 +136,10 @@ static unsigned exam_series1() d = log(a*x) + b/a*log(x)*x - pow(b/a, 2)/2*pow(log(x)*x, 2) + Order(pow(x, 3)); result += check_series(e, 0, d, 3); + e = pow((x+a), b); + d = pow(a, b) + (pow(a, b)*b/a)*x + (pow(a, b)*b*b/a/a/2 - pow(a, b)*b/a/a/2)*pow(x, 2) + Order(pow(x, 3)); + result += check_series(e, 0, d, 3); + return result; } @@ -344,13 +351,25 @@ static unsigned exam_series12() return result; } +// Test of the patch of Stefan Weinzierl that prevents an infinite loop if +// a factor in a product is a complicated way of writing zero. +static unsigned exam_series13() +{ + unsigned result = 0; + + ex e = (new mul(pow(2,x), (1/x*(-(1+x)/(1-x)) + (1+x)/x/(1-x))) + )->setflag(status_flags::evaluated); + ex d = Order(x); + result += check_series(e,0,d,1); + + return result; +} unsigned exam_pseries() { unsigned result = 0; cout << "examining series expansion" << flush; - clog << "----------series expansion:" << endl; result += exam_series1(); cout << '.' << flush; result += exam_series2(); cout << '.' << flush; @@ -364,12 +383,12 @@ unsigned exam_pseries() result += exam_series10(); cout << '.' << flush; result += exam_series11(); cout << '.' << flush; result += exam_series12(); cout << '.' << flush; + result += exam_series13(); 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_pseries(); +}