]> www.ginac.de Git - ginac.git/blobdiff - check/exam_matrices.cpp
adapted to changed clifford_unit() API
[ginac.git] / check / exam_matrices.cpp
index 9e8d90c754cce32f2302a9dcb41d6103587be129..67c52be85b841c36f15f86f27e1a48b7b50df61f 100644 (file)
@@ -3,7 +3,7 @@
  *  Here we examine manipulations on GiNaC's symbolic matrices. */
 
 /*
- *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2004 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
@@ -23,7 +23,7 @@
 #include <stdexcept>
 #include "exams.h"
 
-static unsigned matrix_determinants(void)
+static unsigned matrix_determinants()
 {
        unsigned result = 0;
        ex det;
@@ -110,7 +110,7 @@ static unsigned matrix_determinants(void)
        return result;
 }
 
-static unsigned matrix_invert1(void)
+static unsigned matrix_invert1()
 {
        unsigned result = 0;
        matrix m(1,1);
@@ -128,7 +128,7 @@ static unsigned matrix_invert1(void)
        return result;
 }
 
-static unsigned matrix_invert2(void)
+static unsigned matrix_invert2()
 {
        unsigned result = 0;
        matrix m(2,2);
@@ -150,7 +150,7 @@ static unsigned matrix_invert2(void)
        return result;
 }
 
-static unsigned matrix_invert3(void)
+static unsigned matrix_invert3()
 {
        unsigned result = 0;
        matrix m(3,3);
@@ -180,7 +180,7 @@ static unsigned matrix_invert3(void)
        return result;
 }
 
-static unsigned matrix_solve2(void)
+static unsigned matrix_solve2()
 {
        // check the solution of the multiple system A*X = B:
        //       [ 1  2 -1 ] [ x0 y0 ]   [ 4 0 ]
@@ -216,7 +216,32 @@ static unsigned matrix_solve2(void)
        return result;
 }
 
-static unsigned matrix_misc(void)
+static unsigned matrix_evalm()
+{
+       unsigned result = 0;
+
+       matrix S(2, 2, lst(
+               1, 2,
+               3, 4
+       )), T(2, 2, lst(
+               1, 1,
+               2, -1
+       )), R(2, 2, lst(
+               27, 14,
+               36, 26
+       ));
+
+       ex e = ((S + T) * (S + 2*T));
+       ex f = e.evalm();
+       if (!f.is_equal(R)) {
+               clog << "Evaluating " << e << " erroneously returned " << f << " instead of " << R << endl;
+               result++;
+       }
+
+       return result;
+}
+
+static unsigned matrix_misc()
 {
        unsigned result = 0;
        matrix m1(2,2);
@@ -267,7 +292,7 @@ static unsigned matrix_misc(void)
        return result;
 }
 
-unsigned exam_matrices(void)
+unsigned exam_matrices()
 {
        unsigned result = 0;
        
@@ -279,6 +304,7 @@ unsigned exam_matrices(void)
        result += matrix_invert2();  cout << '.' << flush;
        result += matrix_invert3();  cout << '.' << flush;
        result += matrix_solve2();  cout << '.' << flush;
+       result += matrix_evalm();  cout << "." << flush;
        result += matrix_misc();  cout << '.' << flush;
        
        if (!result) {