1 /** @file lortensor_check.cpp
3 * Here we test manipulations on GiNaC's lortensors. */
6 * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
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.
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.
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
24 #include <ginac/ginac.h>
26 #ifndef NO_NAMESPACE_GINAC
27 using namespace GiNaC;
28 #endif // ndef NO_NAMESPACE_GINAC
30 static unsigned lortensor_check1(void)
32 // checks simple identities of the metric tensor!
35 lorentzidx mu("mu"), nu("nu");
36 ex e1, e2, e3, e4, e5, e6;
37 e1 = lortensor_g(mu,nu);
38 e2 = lortensor_g(nu,mu);
39 e3 = e1 - e2; // g(~mu,~nu) - g(~nu,~mu) = 0 !
40 e4 = lortensor_g(mu,mu.toggle_covariant());
41 e5 = lortensor_g(mu.toggle_covariant(),mu);
42 e6 = e4 - e5; // g(~mu,_mu) - g(_mu,~mu) = 0!
44 clog << e1 << "-" << e2 << " erroneously returned "
45 << e3 << " instead of 0" << endl;
49 clog << e4 << "-" << e5 << " erroneously returned "
50 << e6 << " instead of 0" << endl;
57 static unsigned lortensor_check2(void)
59 // checks simple contraction properties of an arbitrary (symmetric!) rankn lortensor!
62 lorentzidx mu("mu"), nu("nu"), rho("rho");
63 ex e1, e2, e3, e4, e5, e6, e7, e8, e9, e10;
64 e1 = lortensor_g(mu,nu);
65 e2 = lortensor_g(nu,mu);
66 e3 = lortensor_rank1("p",mu.toggle_covariant());
67 e4 = lortensor_rank1("p",nu);
68 e5 = e3 * e1 - e3 * e2; // p_mu g(~mu,~nu) - p_mu g(~nu,~mu) = 0!
69 e6 = simplify_lortensor(e3 * e1) - e4; // p~nu - p~nu = 0!
70 e7 = lortensor_g(nu,rho);
71 e8 = lortensor_rank2("F",mu.toggle_covariant(),nu.toggle_covariant());
72 e9 = lortensor_rank2("F",mu.toggle_covariant(),rho);
73 e10 = simplify_lortensor(e8 * e7) - e9; // F(_mu,_nu) g(~nu,~rho) - F(_mu,~rho) = 0!
75 clog << e3 << "*" << e1 << "-" << e3 << "*" << e2 << " erroneously returned "
76 << e5 << " instead of 0" << endl;
80 clog << " simplify_lortensor(e3 * e1)" << "-" << e4 << " erroneously returned"
81 << e6 << " instead of 0" << endl;
85 clog << " simplify_lortensor(e8 * e7)" << "-" << e9 << " erroneously returned"
86 << e10 << " instead of 0" << endl;
93 unsigned lortensor_check(void)
97 cout << "checking manipulations of lortensor objects..." << flush;
98 clog << "---------manipulations of lortensor objects:" << endl;
100 result += lortensor_check1();
101 result += lortensor_check2();
105 clog << "(no output)" << endl;