]> www.ginac.de Git - ginac.git/blob - check/exam_noncommut.cpp
disabled the exam because the lortensor API is going to change soon
[ginac.git] / check / exam_noncommut.cpp
1 /** @file exam_noncommut.cpp
2  *
3  *  Here we test manipulations on GiNaC's lortensors. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #include "exams.h"
24
25 #if 0 // this will change
26
27 static unsigned lortensor_check1(void)
28 {
29         // checks simple identities of the metric tensor!
30         
31         unsigned result = 0;
32         lorentzidx mu("mu"), nu("nu");
33         ex e1, e2, e3, e4, e5, e6;
34         e1 = lortensor_g(mu,nu);
35         e2 = lortensor_g(nu,mu);
36         e3 = e1 - e2; // g(~mu,~nu) - g(~nu,~mu) = 0 !
37         e4 = lortensor_g(mu,mu.toggle_covariant());
38         e5 = lortensor_g(mu.toggle_covariant(),mu);
39         e6 = e4 - e5; // g(~mu,_mu) - g(_mu,~mu) = 0!
40         if (!e3.is_zero()) {
41                 clog << e1 << "-" << e2 << " erroneously returned "
42                      << e3 << " instead of 0" << endl;
43                 ++result;
44         }
45         if (!e6.is_zero()) {
46                 clog << e4 << "-" << e5 << " erroneously returned "
47                      << e6 << " instead of 0" << endl;
48                 ++result;
49         }
50
51         return result;
52 }
53
54 static unsigned lortensor_check2(void)
55 {
56         // checks simple contraction properties of an arbitrary (symmetric!) rankn lortensor!
57         
58         unsigned result = 0;
59         lorentzidx mu("mu"), nu("nu"), rho("rho");
60         ex e1, e2, e3, e4, e5, e6, e7, e8, e9, e10;
61         e1 = lortensor_g(mu,nu);
62         e2 = lortensor_g(nu,mu);
63         e3 = lortensor_rank1("p",mu.toggle_covariant());
64         e4 = lortensor_rank1("p",nu);
65         e5 = e3 * e1 - e3 * e2; // p_mu g(~mu,~nu) - p_mu g(~nu,~mu) = 0!
66         e6 = simplify_lortensor(e3 * e1) - e4; // p~nu - p~nu = 0!
67         e7 = lortensor_g(nu,rho);
68         e8 = lortensor_rank2("F",mu.toggle_covariant(),nu.toggle_covariant());
69         e9 = lortensor_rank2("F",mu.toggle_covariant(),rho);
70         e10 = simplify_lortensor(e8 * e7) - e9; // F(_mu,_nu) g(~nu,~rho) - F(_mu,~rho) = 0!
71         if (!e5.is_zero()) {
72                 clog << e3 << "*" << e1 << "-" << e3 << "*" << e2 << " erroneously returned "
73                      << e5 << " instead of 0" << endl;
74                 ++result;
75         }
76         if (!e6.is_zero()) {    
77                 clog << " simplify_lortensor(e3 * e1)" << "-" << e4 << " erroneously returned"
78                      << e6 << " instead of 0" << endl;
79                 ++result;
80         }
81         if (!e10.is_zero()) {           
82                 clog << " simplify_lortensor(e8 * e7)" << "-" << e9 << " erroneously returned"
83                      << e10 << " instead of 0" << endl;
84                 ++result;
85         }
86
87         return result;
88 }
89
90 #endif
91
92 unsigned exam_noncommut(void)
93 {
94         unsigned result = 0;
95         
96         cout << "examining behaviour of noncommutative objects" << flush;
97         clog << "----------behaviour of noncommutative objects:" << endl;
98
99 #if 0   
100         result += lortensor_check1();  cout << '.' << flush;
101         result += lortensor_check2();  cout << '.' << flush;
102 #endif
103         
104         if (!result) {
105                 cout << " passed " << endl;
106                 clog << "(no output)" << endl;
107         } else {
108                 cout << " failed " << endl;
109         }
110         
111         return result;
112 }