X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=check%2Fexam_powerlaws.cpp;h=b81760357852be8c8a0abe288228d5df85fcb3a7;hp=d84a0818443a8377e6f70de47a83173c47c38aa0;hb=1fa7d19af08892800dfdb0b700bc0a9362a3fae8;hpb=c3c748381bda4f81b68e50db2eed440c19f24b85 diff --git a/check/exam_powerlaws.cpp b/check/exam_powerlaws.cpp index d84a0818..b8176035 100644 --- a/check/exam_powerlaws.cpp +++ b/check/exam_powerlaws.cpp @@ -4,7 +4,7 @@ * this code, it is a sanity check rather deeply rooted in GiNaC's classes. */ /* - * GiNaC Copyright (C) 1999-2007 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 @@ -21,11 +21,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "ginac.h" -using namespace std; using namespace GiNaC; +#include +using namespace std; + static unsigned exam_powerlaws1() { // (x^a)^b = x^(a*b) @@ -68,14 +69,14 @@ static unsigned exam_powerlaws1() 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(e4) && is_exactly_a(e4.op(0)) && is_exactly_a(e4.op(0).op(0)) && is_exactly_a(e4.op(0).op(1)) && is_exactly_a(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; } @@ -287,6 +288,37 @@ static unsigned exam_powerlaws5() return 0; } +static unsigned exam_powerlaws6() +{ + // check expansion rules for positive symbols + + symbol a("a"); + symbol b("b"); + symbol c("c"); + realsymbol x("x"); + realsymbol y("y"); + possymbol p("p"); + possymbol q("q"); + numeric half=numeric(1,2); + + ex e1 = pow(5*pow(3*a*b*x*y*p*q,2),7*half*c).expand(); + ex e2 = pow(p,7*c)*pow(q,7*c)*pow(pow(a*b*x*y,2),numeric(7,2)*c)*pow(45,numeric(7,2)*c); + if (!e1.is_equal(e2)) { + clog << "Could not expand exponents with positive bases in " << e1 << endl; + return 1; + } + + ex e3 = pow(-pow(-a*x*p,3)*pow(b*y*p,3),half*c).expand().normal(); + ex e4 = pow(p,3*c)*pow(pow(a*b*x*y,3),half*c); + + if (!e3.is_equal(e4)) { + clog << "Could not expand exponents with positive bases in " << e3 << endl; + return 1; + } + + return 0; +} + unsigned exam_powerlaws() { unsigned result = 0; @@ -298,6 +330,7 @@ unsigned exam_powerlaws() result += exam_powerlaws3(); cout << '.' << flush; result += exam_powerlaws4(); cout << '.' << flush; result += exam_powerlaws5(); cout << '.' << flush; + result += exam_powerlaws6(); cout << '.' << flush; return result; }