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;
}
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;
}
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;
}
}
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;
}
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;
}
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;
}
}
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;
}
}
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;
+ << " failed to satisfy Li2(z^2)==2*(Li2(z)+Li2(-z))" << endl;
errorflag = true;
}
}
}
if (errorflag) {
clog << "Our solve method claims that A*X==B, with matrices" << endl
- << "A == " << A << endl
- << "X == " << sol << endl
- << "B == " << B << endl;
+ << "A == " << A << endl
+ << "X == " << sol << endl
+ << "B == " << B << endl;
return 1;
}
if (errorflag) {
++result;
clog << "solution of the system " << eqns << " for " << vars
- << " erroneously returned " << sol << endl;
+ << " erroneously returned " << sol << endl;
}
}
}
A.set(size-1,c,A(0,c)-A(size-2,c));
if (!A.determinant().is_zero()) {
clog << "Determinant of " << size << "x" << size << " matrix "
- << endl << A << endl
- << "was not found to vanish!" << endl;
+ << endl << A << endl
+ << "was not found to vanish!" << endl;
++result;
}
}
A.set(size-1,co,A(0,co)-A(size-2,co));
if (!A.determinant().is_zero()) {
clog << "Determinant of " << size << "x" << size << " matrix "
- << endl << A << endl
- << "was not found to vanish!" << endl;
+ << endl << A << endl
+ << "was not found to vanish!" << endl;
++result;
}
}
A.set(ro,size-1,A(ro,0)-A(ro,size-2));
if (!A.determinant().is_zero()) {
clog << "Determinant of " << size << "x" << size << " matrix "
- << endl << A << endl
- << "was not found to vanish!" << endl;
+ << endl << A << endl
+ << "was not found to vanish!" << endl;
++result;
}
}
(det_bareiss-det_laplace).normal() != 0 ||
(det_divfree-det_laplace).normal() != 0) {
clog << "Determinant of " << size << "x" << size << " matrix "
- << endl << A << endl
- << "is inconsistent between different algorithms:" << endl
- << "Gauss elimination: " << det_gauss << endl
- << "Minor elimination: " << det_laplace << endl
- << "Division-free elim.: " << det_divfree << endl
- << "Fraction-free elim.: " << det_bareiss << endl;
+ << endl << A << endl
+ << "is inconsistent between different algorithms:" << endl
+ << "Gauss elimination: " << det_gauss << endl
+ << "Minor elimination: " << det_laplace << endl
+ << "Division-free elim.: " << det_divfree << endl
+ << "Fraction-free elim.: " << det_bareiss << endl;
++result;
}
}
ok = false;
if (!ok) {
clog << "Inverse of " << size << "x" << size << " matrix "
- << endl << A << endl
- << "erroneously returned: "
- << endl << B << endl;
+ << endl << A << endl
+ << "erroneously returned: "
+ << endl << B << endl;
++result;
}
}
numeric res = p/q;
if (res != z) {
clog << z << " erroneously transformed into "
- << p << "/" << q << " by numer() and denom()" << endl;
+ << p << "/" << q << " by numer() and denom()" << endl;
errorflag = true;
}
}
// test the result:
if (is_ex_of_type(radical,numeric)) {
clog << "(" << num << "/" << den << ")^(" << nm
- << ") should have been a product, instead it's "
- << radical << endl;
+ << ") should have been a product, instead it's "
+ << radical << endl;
errorflag = true;
}
numeric ratio = ex_to_numeric(evalf(radical))/floating;
if (ratio>1.0001 && ratio<0.9999) {
clog << "(" << num << "/" << den << ")^(" << nm
- << ") erroneously evaluated to " << radical;
+ << ") erroneously evaluated to " << radical;
errorflag = true;
}
}
cout << "(" << result << " individual failures)" << endl;
}
cout << "please check checks.out against check.ref for more details."
- << endl << "happy debugging!" << endl;
+ << endl << "happy debugging!" << endl;
}
return result;
// prototypes for the expression generating functions in:
const ex dense_univariate_poly(const symbol & x, unsigned degree);
-const ex dense_bivariate_poly(const symbol & x1, const symbol & x2, unsigned degree);
+const ex dense_bivariate_poly(const symbol & x1, const symbol & x2,
+ unsigned degree);
const ex sparse_tree(const symbol & x, const symbol & y, const symbol & z,
- int level,
- bool trig = false, bool rational = true, bool complex = false);
+ int level,
+ bool trig = false, bool rational = true, bool complex = false);
// prototypes for all individual checks should be unsigned fcn():
unsigned check_numeric();
clog << nth << "th ";
}
clog << "derivative of " << e << " by " << x << " returned "
- << ed << " instead of " << d << endl;
+ << ed << " instead of " << d << endl;
clog << "returned:" << endl;
ed.printtree(clog);
clog << endl << "instead of" << endl;
result += check_diff(e, x, d);
d = 2*b*pow(cos(e1),2)*pow(2*x*y + a, 2) + 4*b*y*e2*cos(e1)
- - 2*b*pow(e2,2)*pow(2*x*y + a, 2) - y*e2*pow(2*x*y + a, 2)
- + 2*pow(y,2)*cos(e1);
+ - 2*b*pow(e2,2)*pow(2*x*y + a, 2) - y*e2*pow(2*x*y + a, 2)
+ + 2*pow(y,2)*cos(e1);
result += check_diff(e, x, d, 2);
d = 2*b*e2*cos(e1)*pow(x, 2) + e2 + y*cos(e1)*pow(x, 2);
result += check_diff(e, y, d);
d = 2*b*pow(cos(e1),2)*pow(x,4) - 2*b*pow(e2,2)*pow(x,4)
- + 2*cos(e1)*pow(x,2) - y*e2*pow(x,4);
+ + 2*cos(e1)*pow(x,2) - y*e2*pow(x,4);
result += check_diff(e, y, d, 2);
// construct expression e to be diff'ed:
result += check_diff(e, x, d);
d = 2*b*pow(sin(e1),2)*pow(2*y*x + a,2) - 4*b*e2*sin(e1)*y
- - 2*b*pow(e2,2)*pow(2*y*x + a,2) - y*e2*pow(2*y*x + a,2)
- - 2*pow(y,2)*sin(e1);
+ - 2*b*pow(e2,2)*pow(2*y*x + a,2) - y*e2*pow(2*y*x + a,2)
+ - 2*pow(y,2)*sin(e1);
result += check_diff(e, x, d, 2);
d = -2*b*e2*sin(e1)*pow(x,2) + e2 - y*sin(e1)*pow(x, 2);
result += check_diff(e, y, d);
d = -2*b*pow(e2,2)*pow(x,4) + 2*b*pow(sin(e1),2)*pow(x,4)
- - 2*sin(e1)*pow(x,2) - y*e2*pow(x,4);
+ - 2*sin(e1)*pow(x,2) - y*e2*pow(x,4);
result += check_diff(e, y, d, 2);
return result;
result += check_diff(e, x, d);
d = 4*b*pow(e2,2)*pow(2*y*x + a,2) + 4*b*pow(e2,2)*y
- + 2*pow(y,2)*e2 + y*e2*pow(2*y*x + a,2);
+ + 2*pow(y,2)*e2 + y*e2*pow(2*y*x + a,2);
result += check_diff(e, x, d, 2);
d = 2*b*pow(e2,2)*pow(x,2) + e2 + y*e2*pow(x,2);
result += check_diff(e, x, d);
d = 2*b*pow((2*x*y + a),2)*pow(e1,-2) + 4*b*y*e2/e1
- - 2*b*e2*pow(2*x*y + a,2)*pow(e1,-2) + 2*pow(y,2)/e1
- - y*pow(2*x*y + a,2)*pow(e1,-2);
+ - 2*b*e2*pow(2*x*y + a,2)*pow(e1,-2) + 2*pow(y,2)/e1
+ - y*pow(2*x*y + a,2)*pow(e1,-2);
result += check_diff(e, x, d, 2);
d = 2*b*e2*pow(x,2)/e1 + e2 + y*pow(x,2)/e1;
result += check_diff(e, y, d);
d = 2*b*pow(x,4)*pow(e1,-2) - 2*b*e2*pow(e1,-2)*pow(x,4)
- + 2*pow(x,2)/e1 - y*pow(x,4)*pow(e1,-2);
+ + 2*pow(x,2)/e1 - y*pow(x,4)*pow(e1,-2);
result += check_diff(e, y, d, 2);
return result;
e1 = y*pow(x, 2) + a*x + b;
e2 = x*pow(y, 2) + b*y + a;
e = atan2(e1,e2);
- /*
- d = pow(y,2)*(-b-y*pow(x,2)-a*x)/(pow(b+y*pow(x,2)+a*x,2)+pow(x*pow(y,2)+b*y+a,2))
- +(2*y*x+a)/((x*pow(y,2)+b*y+a)*(1+pow(b*y*pow(x,2)+a*x,2)/pow(x*pow(y,2)+b*y+a,2)));
- */
- /*
- d = ((a+2*y*x)*pow(y*b+pow(y,2)*x+a,-1)-(a*x+b+y*pow(x,2))*
- pow(y*b+pow(y,2)*x+a,-2)*pow(y,2))*
- pow(1+pow(a*x+b+y*pow(x,2),2)*pow(y*b+pow(y,2)*x+a,-2),-1);
- */
- /*
- d = pow(1+pow(a*x+b+y*pow(x,2),2)*pow(y*b+pow(y,2)*x+a,-2),-1)
- *pow(y*b+pow(y,2)*x+a,-1)*(a+2*y*x)
- +pow(y,2)*(-a*x-b-y*pow(x,2))*
- pow(pow(y*b+pow(y,2)*x+a,2)+pow(a*x+b+y*pow(x,2),2),-1);
- */
+
d = pow(y,2)*pow(pow(b+y*pow(x,2)+x*a,2)+pow(y*b+pow(y,2)*x+a,2),-1)*
- (-b-y*pow(x,2)-x*a)+
- pow(pow(b+y*pow(x,2)+x*a,2)+pow(y*b+pow(y,2)*x+a,2),-1)*
- (y*b+pow(y,2)*x+a)*(2*y*x+a);
+ (-b-y*pow(x,2)-x*a)
+ +pow(pow(b+y*pow(x,2)+x*a,2)+pow(y*b+pow(y,2)*x+a,2),-1)*
+ (y*b+pow(y,2)*x+a)*(2*y*x+a);
result += check_diff(e, x, d);
return result;
if ((ed - d).compare(ex(0)) != 0) {
clog << "derivative of " << e << " by " << x << " returned "
- << ed << " instead of " << d << ")" << endl;
+ << ed << " instead of " << d << ")" << endl;
return 1;
}
return 0;
ex P = x + pow(x,3);
ex e = (P.diff(x) / P).diff(x, 2);
ex d = 6/P - 18*x/pow(P,2) - 54*pow(x,3)/pow(P,2) + 2/pow(P,3)
- +18*pow(x,2)/pow(P,3) + 54*pow(x,4)/pow(P,3) + 54*pow(x,6)/pow(P,3);
+ +18*pow(x,2)/pow(P,3) + 54*pow(x,4)/pow(P,3) + 54*pow(x,6)/pow(P,3);
if (!(e-d).expand().is_zero()) {
clog << "expanded second derivative of " << (P.diff(x) / P) << " by " << x
- << " returned " << e.expand() << " instead of " << d << endl;
+ << " returned " << e.expand() << " instead of " << d << endl;
return 1;
}
if (e.nops() > 3) {
clog << "second derivative of " << (P.diff(x) / P) << " by " << x
- << " has " << e.nops() << " operands. "
- << "The result is still correct but not optimal: 3 are enough! "
- << "(Hint: maybe the product rule for objects of class mul should be more careful about assembling the result?)" << endl;
+ << " has " << e.nops() << " operands. "
+ << "The result is still correct but not optimal: 3 are enough! "
+ << "(Hint: maybe the product rule for objects of class mul should be more careful about assembling the result?)" << endl;
return 1;
}
return 0;
chk = asin(1)-acos(0);
if (!chk.is_zero()) {
clog << "asin(1)-acos(0) erroneously returned " << chk
- << " instead of 0" << endl;
+ << " instead of 0" << endl;
++result;
}
- (1+pow(x,2))*pow(sin(atan(x)),2);
if (chk != 1-pow(x,2)) {
clog << "sin(acos(x))^2 + sin(asin(x))^2 - (1+x^2)*sin(atan(x))^2 "
- << "erroneously returned " << chk << " instead of 1-x^2" << endl;
+ << "erroneously returned " << chk << " instead of 1-x^2" << endl;
++result;
}
- (1+pow(x,2))*pow(cos(atan(x)),2);
if (!chk.is_zero()) {
clog << "cos(acos(x))^2 + cos(asin(x))^2 - (1+x^2)*cos(atan(x))^2 "
- << "erroneously returned " << chk << " instead of 0" << endl;
+ << "erroneously returned " << chk << " instead of 0" << endl;
++result;
}
chk = tan(acos(x))*tan(asin(x)) - tan(atan(x));
if (chk != 1-x) {
clog << "tan(acos(x))*tan(asin(x)) - tan(atan(x)) "
- << "erroneously returned " << chk << " instead of -x+1" << endl;
+ << "erroneously returned " << chk << " instead of -x+1" << endl;
++result;
}
- pow(sinh(asinh(x)),2);
if (!chk.is_zero()) {
clog << "expand(-(sinh(acosh(x)))^2)*(sinh(atanh(x))^2) - sinh(asinh(x))^2 "
- << "erroneously returned " << chk << " instead of 0" << endl;
+ << "erroneously returned " << chk << " instead of 0" << endl;
++result;
}
* pow(cosh(atanh(x)),2);
if (chk != 1) {
clog << "(cosh(asinh(x))^2 - 2*cosh(acosh(x))^2) * cosh(atanh(x))^2 "
- << "erroneously returned " << chk << " instead of 1" << endl;
+ << "erroneously returned " << chk << " instead of 1" << endl;
++result;
}
* pow(tanh(atanh(x)),2);
if (chk != 2) {
clog << "expand(tanh(acosh(x))^2 - tanh(asinh(x))^(-2)) * tanh(atanh(x))^2 "
- << "erroneously returned " << chk << " instead of 2" << endl;
+ << "erroneously returned " << chk << " instead of 2" << endl;
++result;
}
e += tgamma(ex(i));
if (e != numeric(874)) {
clog << "tgamma(1)+...+tgamma(7) erroneously returned "
- << e << " instead of 874" << endl;
+ << e << " instead of 874" << endl;
++result;
}
e *= tgamma(ex(i));
if (e != numeric(24883200)) {
clog << "tgamma(1)*...*tgamma(7) erroneously returned "
- << e << " instead of 24883200" << endl;
+ << e << " instead of 24883200" << endl;
++result;
}
e = tgamma(ex(numeric(5, 2)))*tgamma(ex(numeric(9, 2)))*64;
if (e != 315*Pi) {
clog << "64*tgamma(5/2)*tgamma(9/2) erroneously returned "
- << e << " instead of 315*Pi" << endl;
+ << e << " instead of 315*Pi" << endl;
++result;
}
e = (e*tgamma(ex(numeric(15, 2)))*numeric(512));
if (e != numeric(633935)*Pi) {
clog << "512*(tgamma(-13/2)+...+tgamma(5/2))*tgamma(15/2) erroneously returned "
- << e << " instead of 633935*Pi" << endl;
+ << e << " instead of 633935*Pi" << endl;
++result;
}
e -= (tgamma(x).diff(x)/tgamma(x)).subs(x==numeric(1,2));
if (e!=2*log(2)) {
clog << "tgamma(1)'/tgamma(1) - tgamma(1/2)'/tgamma(1/2) erroneously returned "
- << e << " instead of 2*log(2)" << endl;
+ << e << " instead of 2*log(2)" << endl;
++result;
}
e += zeta(i)/pow(Pi,i);
if (e!=numeric(-204992279,638512875)) {
clog << "zeta(0) + zeta(2) + ... + zeta(12) erroneously returned "
- << e << " instead of -204992279/638512875" << endl;
+ << e << " instead of -204992279/638512875" << endl;
++result;
}
e += zeta(i);
if (e!=numeric(487871,1633632)) {
clog << "zeta(-1) + zeta(-2) + ... + zeta(-15) erroneously returned "
- << e << " instead of 487871/1633632" << endl;
+ << e << " instead of 487871/1633632" << endl;
++result;
}
if (aux != 1) {
++result;
clog << "solution of 3*x+5==8 erroneously returned "
- << aux << endl;
+ << aux << endl;
}
return result;
!normal(sol_y - (3-a*b)/(a+b)).is_zero()) {
++result;
clog << "solution of the system " << eqns << " for " << vars
- << " erroneously returned " << sol << endl;
+ << " erroneously returned " << sol << endl;
}
return result;
(sol_y != numeric(-10,17))) {
++result;
clog << "solution of the system " << eqns << " for " << vars
- << " erroneously returned " << sol << endl;
+ << " erroneously returned " << sol << endl;
}
return result;
(sol_y != numeric(-1,2))) {
++result;
clog << "solution of the system " << eqns << " for " << vars
- << " erroneously returned " << sol << endl;
+ << " erroneously returned " << sol << endl;
}
return result;
(sol_y != t)) {
++result;
clog << "solution of the system " << eqns << " for " << vars
- << " erroneously returned " << sol << endl;
+ << " erroneously returned " << sol << endl;
}
return result;
(sol_z != (b+c)/2)) {
++result;
clog << "solution of the system " << eqns << " for " << vars
- << " erroneously returned " << sol << endl;
+ << " erroneously returned " << sol << endl;
}
return result;
det = m1.determinant();
if (det != a) {
clog << "determinant of 1x1 matrix " << m1
- << " erroneously returned " << det << endl;
+ << " erroneously returned " << det << endl;
++result;
}
det = m2.determinant();
if (det != (a*d-b*c)) {
clog << "determinant of 2x2 matrix " << m2
- << " erroneously returned " << det << endl;
+ << " erroneously returned " << det << endl;
++result;
}
det = m3.determinant();
if (det != (a*e*i - a*f*h - d*b*i + d*c*h + g*b*f - g*c*e)) {
clog << "determinant of 3x3 matrix " << m3
- << " erroneously returned " << det << endl;
+ << " erroneously returned " << det << endl;
++result;
}
det = m3.determinant();
if (det != 42) {
clog << "determinant of 3x3 matrix " << m3
- << " erroneously returned " << det << endl;
+ << " erroneously returned " << det << endl;
++result;
}
if (det != 1) {
if (det.normal() == 1) // only half wrong
clog << "determinant of 2x2 matrix " << m2
- << " was returned unnormalized as " << det << endl;
+ << " was returned unnormalized as " << det << endl;
else // totally wrong
clog << "determinant of 2x2 matrix " << m2
- << " erroneously returned " << det << endl;
+ << " erroneously returned " << det << endl;
++result;
}
det = m4.determinant();
if (det != a*b*c*d) {
clog << "determinant of 4x4 matrix " << m4
- << " erroneously returned " << det << endl;
+ << " erroneously returned " << det << endl;
++result;
}
ex p = m3.charpoly(a);
if (p != 0) {
clog << "charpoly of 3x3 matrix " << m3
- << " erroneously returned " << p << endl;
+ << " erroneously returned " << p << endl;
++result;
}
if (m_i(0,0) != pow(a,-1)) {
clog << "inversion of 1x1 matrix " << m
- << " erroneously returned " << m_i << endl;
+ << " erroneously returned " << m_i << endl;
++result;
}
(normal(m_i(1,0)*det) != -c) ||
(normal(m_i(1,1)*det) != a)) {
clog << "inversion of 2x2 matrix " << m
- << " erroneously returned " << m_i << endl;
+ << " erroneously returned " << m_i << endl;
++result;
}
ex det = m.determinant();
if ((normal(m_i(0,0)*det) != (e*i-f*h)) ||
- (normal(m_i(0,1)*det) != (c*h-b*i)) ||
- (normal(m_i(0,2)*det) != (b*f-c*e)) ||
- (normal(m_i(1,0)*det) != (f*g-d*i)) ||
- (normal(m_i(1,1)*det) != (a*i-c*g)) ||
- (normal(m_i(1,2)*det) != (c*d-a*f)) ||
- (normal(m_i(2,0)*det) != (d*h-e*g)) ||
- (normal(m_i(2,1)*det) != (b*g-a*h)) ||
- (normal(m_i(2,2)*det) != (a*e-b*d))) {
+ (normal(m_i(0,1)*det) != (c*h-b*i)) ||
+ (normal(m_i(0,2)*det) != (b*f-c*e)) ||
+ (normal(m_i(1,0)*det) != (f*g-d*i)) ||
+ (normal(m_i(1,1)*det) != (a*i-c*g)) ||
+ (normal(m_i(1,2)*det) != (c*d-a*f)) ||
+ (normal(m_i(2,0)*det) != (d*h-e*g)) ||
+ (normal(m_i(2,1)*det) != (b*g-a*h)) ||
+ (normal(m_i(2,2)*det) != (a*e-b*d))) {
clog << "inversion of 3x3 matrix " << m
- << " erroneously returned " << m_i << endl;
+ << " erroneously returned " << m_i << endl;
++result;
}
result = 1;
if (result) {
clog << "Solving " << A << " * " << X << " == " << B << endl
- << "erroneously returned " << sol << endl;
+ << "erroneously returned " << sol << endl;
}
return result;
// check a simple trace
if (tr.compare(a+d)) {
clog << "trace of 2x2 matrix " << m1
- << " erroneously returned " << tr << endl;
+ << " erroneously returned " << tr << endl;
++result;
}
m3.set(2,0,e).set(2,1,f);
if (transpose(transpose(m3)) != m3) {
clog << "transposing 3x2 matrix " << m3 << " twice"
- << " erroneously returned " << transpose(transpose(m3)) << endl;
+ << " erroneously returned " << transpose(transpose(m3)) << endl;
++result;
}
}
if (!caught) {
cerr << "singular 2x2 matrix " << m4
- << " erroneously inverted to " << m5 << endl;
+ << " erroneously inverted to " << m5 << endl;
++result;
}
if (e != pow(a1,2)) {
clog << "Denny Fliegner's quick consistency check erroneously returned "
- << e << "." << endl;
+ << e << "." << endl;
++result;
}
if (f != 0) {
clog << "e = pow(a+b,200).expand(); f = e.subs(a == -b); erroneously returned "
- << f << " instead of simplifying to 0." << endl;
+ << f << " instead of simplifying to 0." << endl;
++result;
}
e6 = e4 - e5; // g(~mu,_mu) - g(_mu,~mu) = 0!
if (!e3.is_zero()) {
clog << e1 << "-" << e2 << " erroneously returned "
- << e3 << " instead of 0" << endl;
+ << e3 << " instead of 0" << endl;
++result;
}
if (!e6.is_zero()) {
clog << e4 << "-" << e5 << " erroneously returned "
- << e6 << " instead of 0" << endl;
+ << e6 << " instead of 0" << endl;
++result;
}
e10 = simplify_lortensor(e8 * e7) - e9; // F(_mu,_nu) g(~nu,~rho) - F(_mu,~rho) = 0!
if (!e5.is_zero()) {
clog << e3 << "*" << e1 << "-" << e3 << "*" << e2 << " erroneously returned "
- << e5 << " instead of 0" << endl;
+ << e5 << " instead of 0" << endl;
++result;
}
if (!e6.is_zero()) {
clog << " simplify_lortensor(e3 * e1)" << "-" << e4 << " erroneously returned"
- << e6 << " instead of 0" << endl;
+ << e6 << " instead of 0" << endl;
++result;
}
if (!e10.is_zero()) {
clog << " simplify_lortensor(e8 * e7)" << "-" << e9 << " erroneously returned"
- << e10 << " instead of 0" << endl;
+ << e10 << " instead of 0" << endl;
++result;
}
ex en = e.normal();
if (en.compare(d) != 0) {
clog << "normal form of " << e << " erroneously returned "
- << en << " (should be " << d << ")" << endl;
+ << en << " (should be " << d << ")" << endl;
return 1;
}
return 0;
if (!test_int1.is_integer()) {
clog << test_int1
- << " erroneously not recognized as integer" << endl;
+ << " erroneously not recognized as integer" << endl;
++result;
}
if (!test_int1.is_rational()) {
clog << test_int1
- << " erroneously not recognized as rational" << endl;
+ << " erroneously not recognized as rational" << endl;
++result;
}
if (!test_rat1.is_rational()) {
clog << test_rat1
- << " erroneously not recognized as rational" << endl;
+ << " erroneously not recognized as rational" << endl;
++result;
}
if (test_rat1.is_integer()) {
if (!test_crat.is_crational()) {
clog << test_crat
- << " erroneously not recognized as complex rational" << endl;
+ << " erroneously not recognized as complex rational" << endl;
++result;
}
int i = numeric(1984).to_int();
if (i-1984) {
clog << "conversion of " << i
- << " from numeric to int failed" << endl;
+ << " from numeric to int failed" << endl;
++result;
}
e1 = test_int1;
if (!e1.info(info_flags::posint)) {
clog << "expression " << e1
- << " erroneously not recognized as positive integer" << endl;
+ << " erroneously not recognized as positive integer" << endl;
++result;
}
e2 = test_int1 + a;
if (ex_to_numeric(e2).is_integer()) {
clog << "expression " << e2
- << " erroneously recognized as integer" << endl;
+ << " erroneously recognized as integer" << endl;
++result;
}
test_rat1 += test_rat1;
if (!test_rat1.is_integer()) {
clog << "3/2 + 3/2 erroneously not integer 3 but instead "
- << test_rat1 << endl;
+ << test_rat1 << endl;
++result;
}
test_rat1 = numeric(3)/numeric(2);
test_rat2 -= test_rat1; // 1
if (!test_rat2.is_integer()) {
clog << "5/2 - 3/2 erroneously not integer 1 but instead "
- << test_rat2 << endl;
+ << test_rat2 << endl;
++result;
}
a = 23; b = 4; calc_rem = irem(a, b);
if (calc_rem != 3) {
clog << "irem(" << a << "," << b << ") erroneously returned "
- << calc_rem << endl;
+ << calc_rem << endl;
++result;
}
a = 23; b = -4; calc_rem = irem(a, b);
a = -23; b = 4; calc_rem = irem(a, b);
if (calc_rem != -3) {
clog << "irem(" << a << "," << b << ") erroneously returned "
- << calc_rem << endl;
+ << calc_rem << endl;
++result;
}
a = -23; b = -4; calc_rem = irem(a, b);
if (calc_rem != -3) {
clog << "irem(" << a << "," << b << ") erroneously returned "
- << calc_rem << endl;
+ << calc_rem << endl;
++result;
}
// and now the overloaded irem(a,b,q):
a = 23; b = 4; calc_rem = irem(a, b, calc_quo);
if (calc_rem != 3 || calc_quo != 5) {
clog << "irem(" << a << "," << b << ",q) erroneously returned "
- << calc_rem << " with q=" << calc_quo << endl;
+ << calc_rem << " with q=" << calc_quo << endl;
++result;
}
a = 23; b = -4; calc_rem = irem(a, b, calc_quo);
if (calc_rem != 3 || calc_quo != -5) {
clog << "irem(" << a << "," << b << ",q) erroneously returned "
- << calc_rem << " with q=" << calc_quo << endl;
+ << calc_rem << " with q=" << calc_quo << endl;
++result;
}
a = -23; b = 4; calc_rem = irem(a, b, calc_quo);
if (calc_rem != -3 || calc_quo != -5) {
clog << "irem(" << a << "," << b << ",q) erroneously returned "
- << calc_rem << " with q=" << calc_quo << endl;
+ << calc_rem << " with q=" << calc_quo << endl;
++result;
}
a = -23; b = -4; calc_rem = irem(a, b, calc_quo);
if (calc_rem != -3 || calc_quo != 5) {
clog << "irem(" << a << "," << b << ",q) erroneously returned "
- << calc_rem << " with q=" << calc_quo << endl;
+ << calc_rem << " with q=" << calc_quo << endl;
++result;
}
// check if iquo(a, b) and iquo(a, b, r) really behave like Maple's
a = 23; b = 4; calc_quo = iquo(a, b);
if (calc_quo != 5) {
clog << "iquo(" << a << "," << b << ") erroneously returned "
- << calc_quo << endl;
+ << calc_quo << endl;
++result;
}
a = 23; b = -4; calc_quo = iquo(a, b);
if (calc_quo != -5) {
clog << "iquo(" << a << "," << b << ") erroneously returned "
- << calc_quo << endl;
+ << calc_quo << endl;
++result;
}
a = -23; b = 4; calc_quo = iquo(a, b);
if (calc_quo != -5) {
clog << "iquo(" << a << "," << b << ") erroneously returned "
- << calc_quo << endl;
+ << calc_quo << endl;
++result;
}
a = -23; b = -4; calc_quo = iquo(a, b);
if (calc_quo != 5) {
clog << "iquo(" << a << "," << b << ") erroneously returned "
- << calc_quo << endl;
+ << calc_quo << endl;
++result;
}
// and now the overloaded iquo(a,b,r):
a = 23; b = 4; calc_quo = iquo(a, b, calc_rem);
if (calc_quo != 5 || calc_rem != 3) {
clog << "iquo(" << a << "," << b << ",r) erroneously returned "
- << calc_quo << " with r=" << calc_rem << endl;
+ << calc_quo << " with r=" << calc_rem << endl;
++result;
}
a = 23; b = -4; calc_quo = iquo(a, b, calc_rem);
if (calc_quo != -5 || calc_rem != 3) {
clog << "iquo(" << a << "," << b << ",r) erroneously returned "
- << calc_quo << " with r=" << calc_rem << endl;
+ << calc_quo << " with r=" << calc_rem << endl;
++result;
}
a = -23; b = 4; calc_quo = iquo(a, b, calc_rem);
if (calc_quo != -5 || calc_rem != -3) {
clog << "iquo(" << a << "," << b << ",r) erroneously returned "
- << calc_quo << " with r=" << calc_rem << endl;
+ << calc_quo << " with r=" << calc_rem << endl;
++result;
}
a = -23; b = -4; calc_quo = iquo(a, b, calc_rem);
if (calc_quo != 5 || calc_rem != -3) {
clog << "iquo(" << a << "," << b << ",r) erroneously returned "
- << calc_quo << " with r=" << calc_rem << endl;
+ << calc_quo << " with r=" << calc_rem << endl;
++result;
}
// square roots of squares of integers:
passed = true;
- for (int i=0; i<42; ++i) {
- if (!sqrt(numeric(i*i)).is_integer()) {
+ for (int i=0; i<42; ++i)
+ if (!sqrt(numeric(i*i)).is_integer())
passed = false;
- }
- }
if (!passed) {
clog << "One or more square roots of squares of integers did not return exact integers" << endl;
++result;
// square roots of squares of rationals:
passed = true;
- for (int num=0; num<41; ++num) {
- for (int den=1; den<42; ++den) {
- if (!sqrt(numeric(num*num)/numeric(den*den)).is_rational()) {
+ for (int num=0; num<41; ++num)
+ for (int den=1; den<42; ++den)
+ if (!sqrt(numeric(num*num)/numeric(den*den)).is_rational())
passed = false;
- }
- }
- }
if (!passed) {
clog << "One or more square roots of squares of rationals did not return exact integers" << endl;
++result;
ex e2 = expand(e1 - 10 + 5*pow(3,numeric(3,5)));
if (!e2.is_zero()) {
clog << "expand((1+3^(1/5)-3^(2/5))^3-10+5*3^(3/5)) returned "
- << e2 << " instead of 0." << endl;
+ << e2 << " instead of 0." << endl;
++result;
}
// In the first one expand did not do any job at all:
if (!g.expand().is_equal(x)) {
clog << "e = x*y*z; f = y*z; expand(e/f) erroneously returned "
- << g.expand() << endl;
+ << g.expand() << endl;
++result;
}
e = pow(x + 1, -1);
if (!e.expand().is_equal(e)) {
clog << "expand(pow(x + 1, -1)) erroneously returned "
- << e.expand() << endl;
+ << e.expand() << endl;
++result;
}
// After .expand(), g should be zero:
if (!g.expand().is_zero()) {
clog << "e = (x + z*x); f = e*y; expand(f - e*y) erroneously returned "
- << g.expand() << endl;
+ << g.expand() << endl;
++result;
}
// After .eval(), g should be zero:
if (!g.eval().is_zero()) {
clog << "e = (x + z*x); f = e*y; eval(f - e*y) erroneously returned "
- << g.eval() << endl;
+ << g.eval() << endl;
++result;
}
// This actually worked already back in April 1999.
// But we are *very* paranoic!
if (!g.expand().eval().is_zero()) {
clog << "e = (x + z*x); f = e*y; eval(expand(f - e*y)) erroneously returned "
- << g.expand().eval() << endl;
+ << g.expand().eval() << endl;
++result;
}
if (!f.is_equal(y)) {
clog << "e = x*y - y; f = e.subs(x == 2) erroneously returned "
- << f << endl;
+ << f << endl;
++result;
}
if (!f.eval().is_equal(y)) {
clog << "e = x*y - y; eval(e.subs(x == 2)) erroneously returned "
- << f.eval() << endl;
+ << f.eval() << endl;
++result;
}
if (!f.expand().is_equal(y)) {
clog << "e = x*y - y; expand(e.subs(x == 2)) erroneously returned "
- << f.expand() << endl;
+ << f.expand() << endl;
++result;
}
if (!g.is_zero()) {
clog << "e = pow(x,2) + x + 1; f = pow(x,2) + x + 1; g = e-f; g erroneously returned "
- << g << endl;
+ << g << endl;
++result;
}
if (!g.is_zero()) {
clog << "e = pow(x,2) + x + 1; f = pow(x,2) + x + 1; g = e-f; g.eval() erroneously returned "
- << g.eval() << endl;
+ << g.eval() << endl;
++result;
}
if (!(e-f).expand().is_zero()) {
clog << "e = pow(x*y+1,2); f = pow(x,2)*pow(y,2) + 2*x*y + 1; (e-f).expand() erroneously returned "
- << (e-f).expand() << endl;
+ << (e-f).expand() << endl;
++result;
}
if (f.nops() > 3) {
clog << "e=y+y*x+2; f=expand(pow(e,2)-(e*y*(x+1))) has "
- << f.nops() << " arguments instead of 3 ( f=="
- << f << " )" << endl;
+ << f.nops() << " arguments instead of 3 ( f=="
+ << f << " )" << endl;
++result;
}
return result;
if (!(f - d).expand().is_zero()) {
clog << "normal(" << e << ") returns " << f
- << " instead of " << d << endl;
+ << " instead of " << d << endl;
++result;
}
return result;
ex f = e.normal();
if (!(f - d).expand().is_zero()) {
clog << "normal(" << e << ") returns " << f
- << " instead of " << d << endl;
+ << " instead of " << d << endl;
++result;
}
} catch (const exception &err) {
result += poly_gcd1(); cout << '.' << flush;
result += poly_gcd2(); cout << '.' << flush;
result += poly_gcd3(); cout << '.' << flush;
- result += poly_gcd3p(); cout << '.' << flush; // takes extremely long (PRS "worst" case)
+ result += poly_gcd3p(); cout << '.' << flush; // PRS "worst" case
result += poly_gcd4(); cout << '.' << flush;
result += poly_gcd5(); cout << '.' << flush;
result += poly_gcd5p(); cout << '.' << flush;
symbol a("a");
symbol b("b");
- ex e1=power(power(x,a),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) &&
- e1.is_equal(power(power(x,a),b)) )) {
+ 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) &&
+ e1.is_equal(power(power(x,a),b)) )) {
clog << "(x^a)^b, x,a,b symbolic wrong" << endl;
clog << "returned: " << e1 << endl;
return 1;
}
- ex e2=e1.subs(a==1);
+ 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) &&
- e2.is_equal(power(x,b)) )) {
+ is_ex_exactly_of_type(e2.op(0),symbol) &&
+ is_ex_exactly_of_type(e2.op(1),symbol) &&
+ e2.is_equal(power(x,b)) )) {
clog << "(x^a)^b, x,b symbolic, a==1 wrong" << endl;
clog << "returned: " << e2 << endl;
return 1;
}
- ex e3=e1.subs(a==-1);
+ 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) &&
- e3.is_equal(power(power(x,-1),b)) )) {
+ 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) &&
+ e3.is_equal(power(power(x,-1),b)) )) {
clog << "(x^a)^b, x,b symbolic, a==-1 wrong" << endl;
clog << "returned: " << e3 << endl;
return 1;
}
- ex e4=e1.subs(lst(a==-1,b==2.5));
+ 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) &&
- e4.is_equal(power(power(x,-1),2.5)) )) {
+ 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) &&
+ 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;
}
- ex e5=e1.subs(lst(a==-0.9,b==2.5));
+ 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) &&
- e5.is_equal(power(x,numeric(-0.9)*numeric(2.5))) )) {
+ is_ex_exactly_of_type(e5.op(0),symbol) &&
+ is_ex_exactly_of_type(e5.op(1),numeric) &&
+ 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;
return 1;
}
- ex e6=e1.subs(lst(a==numeric(3)+numeric(5.3)*I,b==-5));
+ 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) &&
- e6.is_equal(power(x,numeric(-15)+numeric(5.3)*numeric(-5)*I)) )) {
+ is_ex_exactly_of_type(e6.op(0),symbol) &&
+ is_ex_exactly_of_type(e6.op(1),numeric) &&
+ 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;
return 1;
symbol a("a");
symbol b("b");
- ex e1=power(a*x,b);
+ ex e1 = power(a*x,b);
if (!(is_ex_exactly_of_type(e1,power) &&
- is_ex_exactly_of_type(e1.op(0),mul) &&
- (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) &&
- e1.is_equal(power(a*x,b)) )) {
+ is_ex_exactly_of_type(e1.op(0),mul) &&
+ (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) &&
+ e1.is_equal(power(a*x,b)) )) {
clog << "(a*x)^b, x,a,b symbolic wrong" << endl;
clog << "returned: " << e1 << endl;
return 1;
}
- ex e2=e1.subs(a==3);
+ ex e2 = e1.subs(a==3);
if (!(is_ex_exactly_of_type(e2,power) &&
- is_ex_exactly_of_type(e2.op(0),mul) &&
- (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) &&
- e2.is_equal(power(3*x,b)) )) {
+ is_ex_exactly_of_type(e2.op(0),mul) &&
+ (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) &&
+ e2.is_equal(power(3*x,b)) )) {
clog << "(a*x)^b, x,b symbolic, a==3 wrong" << endl;
clog << "returned: " << e2 << endl;
return 1;
}
- ex e3=e1.subs(b==-3);
+ ex e3 = e1.subs(b==-3);
if (!(is_ex_exactly_of_type(e3,mul) &&
- (e3.nops()==2) &&
- is_ex_exactly_of_type(e3.op(0),power) &&
- is_ex_exactly_of_type(e3.op(1),power) &&
- e3.is_equal(power(a,-3)*power(x,-3)) )) {
+ (e3.nops()==2) &&
+ is_ex_exactly_of_type(e3.op(0),power) &&
+ is_ex_exactly_of_type(e3.op(1),power) &&
+ e3.is_equal(power(a,-3)*power(x,-3)) )) {
clog << "(a*x)^b, x,a symbolic, b==-3 wrong" << endl;
clog << "returned: " << e3 << endl;
return 1;
}
- ex e4=e1.subs(b==4.5);
+ ex e4 = e1.subs(b==4.5);
if (!(is_ex_exactly_of_type(e4,power) &&
- is_ex_exactly_of_type(e4.op(0),mul) &&
- (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) &&
- e4.is_equal(power(a*x,4.5)) )) {
+ is_ex_exactly_of_type(e4.op(0),mul) &&
+ (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) &&
+ e4.is_equal(power(a*x,4.5)) )) {
clog << "(a*x)^b, x,a symbolic, b==4.5 wrong" << endl;
clog << "returned: " << e4 << endl;
return 1;
}
- ex e5=e1.subs(lst(a==3.2,b==3+numeric(5)*I));
+ ex e5 = e1.subs(lst(a==3.2, b==3+numeric(5)*I));
if (!(is_ex_exactly_of_type(e5,mul) &&
- (e5.nops()==2) &&
- is_ex_exactly_of_type(e5.op(0),power) &&
- is_ex_exactly_of_type(e5.op(1),numeric) &&
- e5.is_equal(power(x,3+numeric(5)*I)*
+ (e5.nops()==2) &&
+ is_ex_exactly_of_type(e5.op(0),power) &&
+ is_ex_exactly_of_type(e5.op(1),numeric) &&
+ 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;
clog << "returned: " << e5 << endl;
return 1;
}
- ex e6=e1.subs(lst(a==-3.2,b==3+numeric(5)*I));
+ ex e6 = e1.subs(lst(a==-3.2, b==3+numeric(5)*I));
if (!(is_ex_exactly_of_type(e6,mul) &&
- (e6.nops()==2) &&
- is_ex_exactly_of_type(e6.op(0),power) &&
- is_ex_exactly_of_type(e6.op(1),numeric) &&
- e6.is_equal(power(-x,3+numeric(5)*I)*
+ (e6.nops()==2) &&
+ is_ex_exactly_of_type(e6.op(0),power) &&
+ is_ex_exactly_of_type(e6.op(1),numeric) &&
+ 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;
clog << "returned: " << e6 << endl;
return 1;
}
- ex e7=e1.subs(lst(a==3+numeric(5)*I,b==3.2));
+ 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) &&
- (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) &&
- e7.is_equal(power((3+numeric(5)*I)*x,3.2)) )) {
+ is_ex_exactly_of_type(e7.op(0),mul) &&
+ (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) &&
+ 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;
return 1;
ex e3 = power(numeric(5),numeric(1,2));
if (!(is_ex_exactly_of_type(e3,power) &&
- e3.op(0).is_equal(numeric(5)) &&
- e3.op(1).is_equal(numeric(1,2)))) {
+ e3.op(0).is_equal(numeric(5)) &&
+ e3.op(1).is_equal(numeric(1,2)))) {
clog << "5^(1/2) wrongly returned " << e3 << endl;
return 1;
}
ex e2 = pow(0,a);
if (!(is_ex_exactly_of_type(e2,power))) {
clog << "0^a was evaluated to " << e2
- << " though nothing is known about a." << endl;
+ << " though nothing is known about a." << endl;
return 1;
}
ex ep = ex_to_pseries(es).convert_to_poly();
if (!(ep - d).is_zero()) {
clog << "series expansion of " << e << " at " << point
- << " erroneously returned " << ep << " (instead of " << d
- << ")" << endl;
+ << " erroneously returned " << ep << " (instead of " << d
+ << ")" << endl;
(ep-d).printtree(clog);
return 1;
}
{
ex e = tgamma(2*x);
ex d = pow(x+1,-1)*numeric(1,4) +
- pow(x+1,0)*(numeric(3,4) -
- numeric(1,2)*Euler) +
- pow(x+1,1)*(numeric(7,4) -
- numeric(3,2)*Euler +
- numeric(1,2)*pow(Euler,2) +
- numeric(1,12)*pow(Pi,2)) +
- pow(x+1,2)*(numeric(15,4) -
- numeric(7,2)*Euler -
- numeric(1,3)*pow(Euler,3) +
- numeric(1,4)*pow(Pi,2) +
- numeric(3,2)*pow(Euler,2) -
- numeric(1,6)*pow(Pi,2)*Euler -
- numeric(2,3)*zeta(3)) +
- pow(x+1,3)*(numeric(31,4) - pow(Euler,3) -
- numeric(15,2)*Euler +
- numeric(1,6)*pow(Euler,4) +
- numeric(7,2)*pow(Euler,2) +
- numeric(7,12)*pow(Pi,2) -
- numeric(1,2)*pow(Pi,2)*Euler -
- numeric(2)*zeta(3) +
- numeric(1,6)*pow(Euler,2)*pow(Pi,2) +
- numeric(1,40)*pow(Pi,4) +
- numeric(4,3)*zeta(3)*Euler) +
- Order(pow(x+1,4));
+ pow(x+1,0)*(numeric(3,4) -
+ numeric(1,2)*Euler) +
+ pow(x+1,1)*(numeric(7,4) -
+ numeric(3,2)*Euler +
+ numeric(1,2)*pow(Euler,2) +
+ numeric(1,12)*pow(Pi,2)) +
+ pow(x+1,2)*(numeric(15,4) -
+ numeric(7,2)*Euler -
+ numeric(1,3)*pow(Euler,3) +
+ numeric(1,4)*pow(Pi,2) +
+ numeric(3,2)*pow(Euler,2) -
+ numeric(1,6)*pow(Pi,2)*Euler -
+ numeric(2,3)*zeta(3)) +
+ pow(x+1,3)*(numeric(31,4) - pow(Euler,3) -
+ numeric(15,2)*Euler +
+ numeric(1,6)*pow(Euler,4) +
+ numeric(7,2)*pow(Euler,2) +
+ numeric(7,12)*pow(Pi,2) -
+ numeric(1,2)*pow(Pi,2)*Euler -
+ numeric(2)*zeta(3) +
+ numeric(1,6)*pow(Euler,2)*pow(Pi,2) +
+ numeric(1,40)*pow(Pi,4) +
+ numeric(4,3)*zeta(3)*Euler) +
+ Order(pow(x+1,4));
return check_series(e, -1, d, 4);
}
{
ex e = tan(x*Pi/2);
ex d = pow(x-1,-1)/Pi*(-2) + pow(x-1,1)*Pi/6 + pow(x-1,3)*pow(Pi,3)/360
- +pow(x-1,5)*pow(Pi,5)/15120 + pow(x-1,7)*pow(Pi,7)/604800
- +Order(pow(x-1,8));
+ +pow(x-1,5)*pow(Pi,5)/15120 + pow(x-1,7)*pow(Pi,7)/604800
+ +Order(pow(x-1,8));
return check_series(e,1,d,8);
}
{
ex e = log(sin(x));
ex d = log(x) - pow(x,2)/6 - pow(x,4)/180 - pow(x,6)/2835
- +Order(pow(x,8));
+ +Order(pow(x,8));
return check_series(e,0,d,8);
}
{
ex e = Li2(sin(x));
ex d = x + pow(x,2)/4 - pow(x,3)/18 - pow(x,4)/48
- - 13*pow(x,5)/1800 - pow(x,6)/360 - 23*pow(x,7)/21168
- + Order(pow(x,8));
+ - 13*pow(x,5)/1800 - pow(x,6)/360 - 23*pow(x,7)/21168
+ + Order(pow(x,8));
return check_series(e,0,d,8);
}
{
ex e = Li2(pow(x,2));
ex d = Li2(4) + (-log(3) + I*Pi*csgn(I-I*pow(x,2))) * (x-2)
- + (numeric(-2,3) + log(3)/4 - I*Pi/4*csgn(I-I*pow(x,2))) * pow(x-2,2)
- + (numeric(11,27) - log(3)/12 + I*Pi/12*csgn(I-I*pow(x,2))) * pow(x-2,3)
- + (numeric(-155,648) + log(3)/32 - I*Pi/32*csgn(I-I*pow(x,2))) * pow(x-2,4)
- + Order(pow(x-2,5));
+ + (numeric(-2,3) + log(3)/4 - I*Pi/4*csgn(I-I*pow(x,2))) * pow(x-2,2)
+ + (numeric(11,27) - log(3)/12 + I*Pi/12*csgn(I-I*pow(x,2))) * pow(x-2,3)
+ + (numeric(-155,648) + log(3)/32 - I*Pi/32*csgn(I-I*pow(x,2))) * pow(x-2,4)
+ + Order(pow(x-2,5));
return check_series(e,2,d,5);
}
cout << "(" << result << " individual failures)" << endl;
}
cout << "please check exams.out against exams.ref for more details."
- << endl << "happy debugging!" << endl;
+ << endl << "happy debugging!" << endl;
}
return result;
unsigned result = 0;
// create a vector of size symbols named "a0", "a1", ...
vector<symbol> a;
+ ex e;
for (unsigned i=0; i<size; ++i) {
+#if defined(HAVE_SSTREAM)
+ ostringstream buf;
+ buf << "a" << i << ends;
+ a.push_back(symbol(buf.str()));
+#else
char buf[4];
- ostrstream(buf,sizeof(buf)) << i << ends;
- a.push_back(symbol(string("a")+buf));
+ ostrstream(buf,sizeof(buf)) << "a" << i << ends;
+ a.push_back(symbol(buf));
+#endif
+ e += a[i];
}
- ex e, aux;
-
- for (unsigned i=0; i<size; ++i)
- e = e + a[i];
+ ex aux;
// prepare aux so it will swallow anything but a1^2:
aux = -e + a[0] + a[1];
if (e != pow(a[1],2)) {
clog << "Denny Fliegner's quick consistency check erroneously returned "
- << e << "." << endl;
+ << e << "." << endl;
++result;
}
ex bound = evalf(exp(ex(-.57721566490153286*(order-1)))/(order-1));
if (evalf(abs((last_coeff-pow(-1,order))/bound)) > numeric(1)) {
clog << "The " << order-1
- << "th order coefficient in the power series expansion of tgamma(0) was erroneously found to be "
- << last_coeff << ", violating a simple estimate." << endl;
+ << "th order coefficient in the power series expansion of tgamma(0) was erroneously found to be "
+ << last_coeff << ", violating a simple estimate." << endl;
++result;
}
ex lastgcd = gcd(pow(x,300+(200%181)),pow(y,200+(200%183)));
if (lastgcd != numeric("53174994123961114423610399251974962981084780166115806651505844915220196792416194060680805428433601792982500430324916963290494659936522782673704312949880308677990050199363768068005367578752699785180694630122629259539608472261461289805919741933")) {
clog << "gcd(" << x << "^" << 300+(200%181) << ","
- << y << "^" << 200+(200%183) << ") erroneously returned "
- << lastgcd << endl;
+ << y << "^" << 200+(200%183) << ") erroneously returned "
+ << lastgcd << endl;
return 1;
}
return 0;
symbol z("z");
ex p = expand(pow(7*y*pow(x*z,2)-3*x*y*z+11*(x+1)*pow(y,2)+5*z+1,4)
- *pow(3*x-7*y+2*z-3,5));
+ *pow(3*x-7*y+2*z-3,5));
ex q = expand(pow(7*y*pow(x*z,2)-3*x*y*z+11*(x+1)*pow(y,2)+5*z+1,3)
- *pow(3*x-7*y+2*z+3,6));
+ *pow(3*x-7*y+2*z+3,6));
ex result = gcd(p,q);
if (result.expand()!=expand(pow(7*y*pow(x*z,2)-3*x*y*z+11*(x+1)*pow(y,2)+5*z+1,3))) {
clog << "gcd(expand((7*y*x^2*z^2-3*x*y*z+11*(x+1)*y^2+5*z+1)^4*(3*x-7*y+2*z-3)^5),expand((7*y*x^2*z^2-3*x*y*z+11*(x+1)*y^2+5*z+1)^3*(3*x-7*y+2*z+3)^6)) erroneously returned " << result << endl;
char name = (n==40?'I':(n==70?'K':'?'));
cout << "timing Lewis-Wester test " << name
- << " (invert rank " << n << " Hilbert)" << flush;
+ << " (invert rank " << n << " Hilbert)" << flush;
clog << "-------Lewis-Wester test " << name
- << " (invert rank " << n << " Hilbert)" << endl;
+ << " (invert rank " << n << " Hilbert)" << endl;
// Create a rank n Hilbert matrix:
matrix H(n,n);
name = (n==40?'J':(n==70?'L':'?'));
cout << "timing Lewis-Wester test " << name
- << " (check rank " << n << " Hilbert)" << flush;
+ << " (check rank " << n << " Hilbert)" << flush;
clog << "-------Lewis-Wester test " << name
- << " (check rank " << n << " Hilbert)" << endl;
+ << " (check rank " << n << " Hilbert)" << endl;
cartier.reset();
matrix identity = H.mul(Hinv);
for (unsigned r=0; r<26; ++r) {
for (unsigned c=0; c<5; ++c) {
m.set(r,
- unsigned(ex_to_numeric(w[r][2*c+1]).to_int()-1),
- w[r][2*c+2]);
+ unsigned(ex_to_numeric(w[r][2*c+1]).to_int()-1),
+ w[r][2*c+2]);
}
}
ex det = m.determinant();
unsigned result = 0;
symbol a("a"), b("b");
ex p[8] = {a,
- b,
- a+b,
- pow(a,2) + a*b + pow(b,2),
- pow(a,3) + pow(a,2)*b - a*pow(b,2) + pow(b,3),
- pow(a,4) + pow(a,3)*b + pow(a*b,2) + a*pow(b,3) + pow(b,4),
- pow(a,5) + pow(a,4)*b + pow(a,3)*pow(b,2) - pow(a,2)*pow(b,3) + a*pow(b,4) + pow(b,5),
- pow(a,6) + pow(a,5)*b + pow(a,4)*pow(b,2) + pow(a*b,3) + pow(a,2)*pow(b,4) + a*pow(b,5) + pow(b,6)
+ b,
+ a+b,
+ pow(a,2) + a*b + pow(b,2),
+ pow(a,3) + pow(a,2)*b - a*pow(b,2) + pow(b,3),
+ pow(a,4) + pow(a,3)*b + pow(a*b,2) + a*pow(b,3) + pow(b,4),
+ pow(a,5) + pow(a,4)*b + pow(a,3)*pow(b,2) - pow(a,2)*pow(b,3) + a*pow(b,4) + pow(b,5),
+ pow(a,6) + pow(a,5)*b + pow(a,4)*pow(b,2) + pow(a*b,3) + pow(a,2)*pow(b,4) + a*pow(b,5) + pow(b,6)
};
// construct Toeplitz matrix:
// dirty consistency check of result:
if (!tdet.subs(a==0).subs(b==0).is_zero()) {
clog << "Determaint of Toeplitz matrix " << endl
- << "M==" << M << endl
- << "was miscalculated: det(M)==" << tdet << endl;
+ << "M==" << M << endl
+ << "was miscalculated: det(M)==" << tdet << endl;
++result;
}
// dirty consistency check of result:
if (!vdet.subs(a==1).is_zero()) {
clog << "Determaint of Vandermonde matrix " << endl
- << "M==" << M << endl
- << "was miscalculated: det(M)==" << vdet << endl;
+ << "M==" << M << endl
+ << "was miscalculated: det(M)==" << vdet << endl;
++result;
}
cout << "(" << result << " individual failures)" << endl;
}
cout << "please check times.out against times.ref for more details."
- << endl << "happy debugging!" << endl;
+ << endl << "happy debugging!" << endl;
}
return result;