X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=check%2Fexam_indexed.cpp;h=85730a99f35d630d7e560261cc94613259032ac9;hp=82a2539f9df6a86423a617495c68644a69fdd378;hb=052f124551d2b78104b0de2008db6b8819713625;hpb=1f5afe37b4c079821de9810435fa9fa11e4ea17b diff --git a/check/exam_indexed.cpp b/check/exam_indexed.cpp index 82a2539f..85730a99 100644 --- a/check/exam_indexed.cpp +++ b/check/exam_indexed.cpp @@ -3,7 +3,7 @@ * Here we test manipulations on GiNaC's indexed objects. */ /* - * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2010 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 @@ -17,10 +17,14 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "exams.h" +#include "ginac.h" +using namespace GiNaC; + +#include +using namespace std; static unsigned check_equal(const ex &e1, const ex &e2) { @@ -55,7 +59,7 @@ static unsigned check_equal_simplify(const ex &e1, const ex &e2, const scalar_pr return 0; } -static unsigned delta_check(void) +static unsigned delta_check() { // checks identities of the delta tensor @@ -81,7 +85,7 @@ static unsigned delta_check(void) return result; } -static unsigned metric_check(void) +static unsigned metric_check() { // checks identities of the metric tensor @@ -114,7 +118,7 @@ static unsigned metric_check(void) return result; } -static unsigned epsilon_check(void) +static unsigned epsilon_check() { // checks identities of the epsilon tensor @@ -153,7 +157,7 @@ REGISTER_FUNCTION(symm_fcn, set_symmetry(sy_symm(0, 1))); DECLARE_FUNCTION_2P(anti_fcn) REGISTER_FUNCTION(anti_fcn, set_symmetry(sy_anti(0, 1))); -static unsigned symmetry_check(void) +static unsigned symmetry_check() { // check symmetric/antisymmetric objects @@ -202,7 +206,7 @@ static unsigned symmetry_check(void) return result; } -static unsigned scalar_product_check(void) +static unsigned scalar_product_check() { // check scalar product replacement @@ -225,7 +229,7 @@ static unsigned scalar_product_check(void) return result; } -static unsigned edyn_check(void) +static unsigned edyn_check() { // Relativistic electrodynamics @@ -241,19 +245,17 @@ static unsigned edyn_check(void) // Lorentz transformation matrix (boost along x axis) matrix L(4, 4); - L(0, 0) = gamma; - L(0, 1) = -beta*gamma; - L(1, 0) = -beta*gamma; - L(1, 1) = gamma; - L(2, 2) = 1; L(3, 3) = 1; + L = gamma, -beta*gamma, 0, 0, + -beta*gamma, gamma, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1; // Electromagnetic field tensor - matrix F(4, 4, lst( - 0, -Ex, -Ey, -Ez, + matrix F(4, 4); + F = 0, -Ex, -Ey, -Ez, Ex, 0, -Bz, By, Ey, Bz, 0, -Bx, - Ez, -By, Bx, 0 - )); + Ez, -By, Bx, 0; // Indices symbol s_mu("mu"), s_nu("nu"), s_rho("rho"), s_sigma("sigma"); @@ -312,7 +314,7 @@ static unsigned edyn_check(void) return result; } -static unsigned spinor_check(void) +static unsigned spinor_check() { // check identities of the spinor metric @@ -347,7 +349,7 @@ static unsigned spinor_check(void) return result; } -static unsigned dummy_check(void) +static unsigned dummy_check() { // check dummy index renaming/repositioning @@ -377,15 +379,23 @@ static unsigned dummy_check(void) e = indexed(p, mu.toggle_variance(), mu) - indexed(p, nu, nu.toggle_variance()); result += check_equal_simplify(e, 0); + // GiNaC 1.2.1 had a bug here because p.i*p.i -> (p.i)^2 + e = indexed(p, i) * indexed(p, i) * indexed(p, j) + indexed(p, j); + ex fi = exprseq(e.get_free_indices()); + if (!fi.is_equal(exprseq(j))) { + clog << "get_free_indices(" << e << ") erroneously returned " + << fi << " instead of (.j)" << endl; + ++result; + } + return result; } -unsigned exam_indexed(void) +unsigned exam_indexed() { unsigned result = 0; cout << "examining indexed objects" << flush; - clog << "----------indexed objects:" << endl; result += delta_check(); cout << '.' << flush; result += metric_check(); cout << '.' << flush; @@ -396,12 +406,10 @@ unsigned exam_indexed(void) result += spinor_check(); cout << '.' << flush; result += dummy_check(); cout << '.' << flush; - if (!result) { - cout << " passed " << endl; - clog << "(no output)" << endl; - } else { - cout << " failed " << endl; - } - return result; } + +int main(int argc, char** argv) +{ + return exam_indexed(); +}