X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=check%2Fexam_powerlaws.cpp;h=c6203df1d85aa9cad152bfff2d64a0852763eaee;hp=8513caebfdb68976eb3b068c7dfe99d6c9f4a36b;hb=3d757d6bfa78c9812337e8c5d849fbd2ab75f861;hpb=ae3044935ddf13dd325f6e11770357b99bbe6095 diff --git a/check/exam_powerlaws.cpp b/check/exam_powerlaws.cpp index 8513caeb..c6203df1 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-2000 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2003 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 @@ -32,11 +32,11 @@ static unsigned exam_powerlaws1(void) symbol b("b"); ex e1 = power(power(x,a), b); - if (!(is_ex_exactly_of_type(e1,power) && - is_ex_exactly_of_type(e1.op(0),power) && - is_ex_exactly_of_type(e1.op(0).op(0),symbol) && - is_ex_exactly_of_type(e1.op(0).op(1),symbol) && - is_ex_exactly_of_type(e1.op(1),symbol) && + if (!(is_exactly_a(e1) && + is_exactly_a(e1.op(0)) && + is_exactly_a(e1.op(0).op(0)) && + is_exactly_a(e1.op(0).op(1)) && + is_exactly_a(e1.op(1)) && e1.is_equal(power(power(x,a),b)) )) { clog << "(x^a)^b, x,a,b symbolic wrong" << endl; clog << "returned: " << e1 << endl; @@ -44,9 +44,9 @@ static unsigned exam_powerlaws1(void) } ex e2 = e1.subs(a==1); - if (!(is_ex_exactly_of_type(e2,power) && - is_ex_exactly_of_type(e2.op(0),symbol) && - is_ex_exactly_of_type(e2.op(1),symbol) && + if (!(is_exactly_a(e2) && + is_exactly_a(e2.op(0)) && + is_exactly_a(e2.op(1)) && e2.is_equal(power(x,b)) )) { clog << "(x^a)^b, x,b symbolic, a==1 wrong" << endl; clog << "returned: " << e2 << endl; @@ -54,11 +54,11 @@ static unsigned exam_powerlaws1(void) } ex e3 = e1.subs(a==-1); - if (!(is_ex_exactly_of_type(e3,power) && - is_ex_exactly_of_type(e3.op(0),power) && - is_ex_exactly_of_type(e3.op(0).op(0),symbol) && - is_ex_exactly_of_type(e3.op(0).op(1),numeric) && - is_ex_exactly_of_type(e3.op(1),symbol) && + if (!(is_exactly_a(e3) && + is_exactly_a(e3.op(0)) && + is_exactly_a(e3.op(0).op(0)) && + is_exactly_a(e3.op(0).op(1)) && + is_exactly_a(e3.op(1)) && e3.is_equal(power(power(x,-1),b)) )) { clog << "(x^a)^b, x,b symbolic, a==-1 wrong" << endl; clog << "returned: " << e3 << endl; @@ -66,11 +66,11 @@ static unsigned exam_powerlaws1(void) } ex e4 = e1.subs(lst(a==-1, b==2.5)); - if (!(is_ex_exactly_of_type(e4,power) && - is_ex_exactly_of_type(e4.op(0),power) && - is_ex_exactly_of_type(e4.op(0).op(0),symbol) && - is_ex_exactly_of_type(e4.op(0).op(1),numeric) && - is_ex_exactly_of_type(e4.op(1),numeric) && + 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; clog << "returned: " << e4 << endl; @@ -78,9 +78,9 @@ static unsigned exam_powerlaws1(void) } ex e5 = e1.subs(lst(a==-0.9, b==2.5)); - if (!(is_ex_exactly_of_type(e5,power) && - is_ex_exactly_of_type(e5.op(0),symbol) && - is_ex_exactly_of_type(e5.op(1),numeric) && + if (!(is_exactly_a(e5) && + is_exactly_a(e5.op(0)) && + is_exactly_a(e5.op(1)) && e5.is_equal(power(x,numeric(-0.9)*numeric(2.5))) )) { clog << "(x^a)^b, x symbolic, a==-0.9, b==2.5 wrong" << endl; clog << "returned: " << e5 << endl; @@ -88,9 +88,9 @@ static unsigned exam_powerlaws1(void) } ex e6 = e1.subs(lst(a==numeric(3)+numeric(5.3)*I, b==-5)); - if (!(is_ex_exactly_of_type(e6,power) && - is_ex_exactly_of_type(e6.op(0),symbol) && - is_ex_exactly_of_type(e6.op(1),numeric) && + if (!(is_exactly_a(e6) && + is_exactly_a(e6.op(0)) && + is_exactly_a(e6.op(1)) && e6.is_equal(power(x,numeric(-15)+numeric(5.3)*numeric(-5)*I)) )) { clog << "(x^a)^b, x symbolic, a==3+5.3*I, b==-5 wrong" << endl; clog << "returned: " << e6 << endl; @@ -109,12 +109,12 @@ static unsigned exam_powerlaws2(void) symbol b("b"); ex e1 = power(a*x,b); - if (!(is_ex_exactly_of_type(e1,power) && - is_ex_exactly_of_type(e1.op(0),mul) && + if (!(is_exactly_a(e1) && + is_exactly_a(e1.op(0)) && (e1.op(0).nops()==2) && - is_ex_exactly_of_type(e1.op(0).op(0),symbol) && - is_ex_exactly_of_type(e1.op(0).op(1),symbol) && - is_ex_exactly_of_type(e1.op(1),symbol) && + is_exactly_a(e1.op(0).op(0)) && + is_exactly_a(e1.op(0).op(1)) && + is_exactly_a(e1.op(1)) && e1.is_equal(power(a*x,b)) )) { clog << "(a*x)^b, x,a,b symbolic wrong" << endl; clog << "returned: " << e1 << endl; @@ -122,12 +122,12 @@ static unsigned exam_powerlaws2(void) } ex e2 = e1.subs(a==3); - if (!(is_ex_exactly_of_type(e2,power) && - is_ex_exactly_of_type(e2.op(0),mul) && + if (!(is_exactly_a(e2) && + is_exactly_a(e2.op(0)) && (e2.op(0).nops()==2) && - is_ex_exactly_of_type(e2.op(0).op(0),symbol) && - is_ex_exactly_of_type(e2.op(0).op(1),numeric) && - is_ex_exactly_of_type(e2.op(1),symbol) && + is_exactly_a(e2.op(0).op(0)) && + is_exactly_a(e2.op(0).op(1)) && + is_exactly_a(e2.op(1)) && e2.is_equal(power(3*x,b)) )) { clog << "(a*x)^b, x,b symbolic, a==3 wrong" << endl; clog << "returned: " << e2 << endl; @@ -135,10 +135,10 @@ static unsigned exam_powerlaws2(void) } ex e3 = e1.subs(b==-3); - if (!(is_ex_exactly_of_type(e3,mul) && + if (!(is_exactly_a(e3) && (e3.nops()==2) && - is_ex_exactly_of_type(e3.op(0),power) && - is_ex_exactly_of_type(e3.op(1),power) && + is_exactly_a(e3.op(0)) && + is_exactly_a(e3.op(1)) && e3.is_equal(power(a,-3)*power(x,-3)) )) { clog << "(a*x)^b, x,a symbolic, b==-3 wrong" << endl; clog << "returned: " << e3 << endl; @@ -146,12 +146,12 @@ static unsigned exam_powerlaws2(void) } ex e4 = e1.subs(b==4.5); - if (!(is_ex_exactly_of_type(e4,power) && - is_ex_exactly_of_type(e4.op(0),mul) && + if (!(is_exactly_a(e4) && + is_exactly_a(e4.op(0)) && (e4.op(0).nops()==2) && - is_ex_exactly_of_type(e4.op(0).op(0),symbol) && - is_ex_exactly_of_type(e4.op(0).op(1),symbol) && - is_ex_exactly_of_type(e4.op(1),numeric) && + 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(a*x,4.5)) )) { clog << "(a*x)^b, x,a symbolic, b==4.5 wrong" << endl; clog << "returned: " << e4 << endl; @@ -159,10 +159,10 @@ static unsigned exam_powerlaws2(void) } ex e5 = e1.subs(lst(a==3.2, b==3+numeric(5)*I)); - if (!(is_ex_exactly_of_type(e5,mul) && + if (!(is_exactly_a(e5) && (e5.nops()==2) && - is_ex_exactly_of_type(e5.op(0),power) && - is_ex_exactly_of_type(e5.op(1),numeric) && + is_exactly_a(e5.op(0)) && + is_exactly_a(e5.op(1)) && e5.is_equal(power(x,3+numeric(5)*I)* power(numeric(3.2),3+numeric(5)*I)) )) { clog << "(a*x)^b, x symbolic, a==3.2, b==3+5*I wrong" << endl; @@ -171,10 +171,10 @@ static unsigned exam_powerlaws2(void) } ex e6 = e1.subs(lst(a==-3.2, b==3+numeric(5)*I)); - if (!(is_ex_exactly_of_type(e6,mul) && + if (!(is_exactly_a(e6) && (e6.nops()==2) && - is_ex_exactly_of_type(e6.op(0),power) && - is_ex_exactly_of_type(e6.op(1),numeric) && + is_exactly_a(e6.op(0)) && + is_exactly_a(e6.op(1)) && e6.is_equal(power(-x,3+numeric(5)*I)* power(numeric(3.2),3+numeric(5)*I)) )) { clog << "(a*x)^b, x symbolic, a==-3.2, b==3+5*I wrong" << endl; @@ -183,12 +183,12 @@ static unsigned exam_powerlaws2(void) } ex e7 = e1.subs(lst(a==3+numeric(5)*I, b==3.2)); - if (!(is_ex_exactly_of_type(e7,power) && - is_ex_exactly_of_type(e7.op(0),mul) && + if (!(is_exactly_a(e7) && + is_exactly_a(e7.op(0)) && (e7.op(0).nops()==2) && - is_ex_exactly_of_type(e7.op(0).op(0),symbol) && - is_ex_exactly_of_type(e7.op(0).op(1),numeric) && - is_ex_exactly_of_type(e7.op(1),numeric) && + is_exactly_a(e7.op(0).op(0)) && + is_exactly_a(e7.op(0).op(1)) && + is_exactly_a(e7.op(1)) && e7.is_equal(power((3+numeric(5)*I)*x,3.2)) )) { clog << "(a*x)^b, x symbolic, a==3+5*I, b==3.2 wrong" << endl; clog << "returned: " << e7 << endl; @@ -215,7 +215,7 @@ static unsigned exam_powerlaws3(void) } ex e3 = power(numeric(5),numeric(1,2)); - if (!(is_ex_exactly_of_type(e3,power) && + if (!(is_exactly_a(e3) && e3.op(0).is_equal(numeric(5)) && e3.op(1).is_equal(numeric(1,2)))) { clog << "5^(1/2) wrongly returned " << e3 << endl; @@ -223,13 +223,13 @@ static unsigned exam_powerlaws3(void) } ex e4 = power(numeric(5),evalf(numeric(1,2))); - if (!(is_ex_exactly_of_type(e4,numeric))) { + if (!(is_exactly_a(e4))) { clog << "5^(0.5) wrongly returned " << e4 << endl; return 1; } ex e5 = power(evalf(numeric(5)),numeric(1,2)); - if (!(is_ex_exactly_of_type(e5,numeric))) { + if (!(is_exactly_a(e5))) { clog << "5.0^(1/2) wrongly returned " << e5 << endl; return 1; } @@ -275,7 +275,7 @@ static unsigned exam_powerlaws5(void) } ex e2 = pow(0,a); - if (!(is_ex_exactly_of_type(e2,power))) { + if (!(is_exactly_a(e2))) { clog << "0^a was evaluated to " << e2 << " though nothing is known about a." << endl; return 1;