From 6ba910273b7555cc2790013fdec2ae033e4bd766 Mon Sep 17 00:00:00 2001 From: welzel Date: Mon, 10 Jan 2000 19:02:27 +0000 Subject: [PATCH] - added simple checks of manipulations with lortensor objects. --- check/Makefile.am | 9 ++-- check/Makefile.in | 13 ++--- check/check.h | 1 + check/lortensor_check.cpp | 111 ++++++++++++++++++++++++++++++++++++++ check/main.cpp | 1 + check/result.ref | 2 + 6 files changed, 127 insertions(+), 10 deletions(-) create mode 100644 check/lortensor_check.cpp diff --git a/check/Makefile.am b/check/Makefile.am index 924de84f..5c251ed2 100644 --- a/check/Makefile.am +++ b/check/Makefile.am @@ -1,10 +1,11 @@ ## Process this file with automake to produce Makefile.in TESTS = run_checks check_PROGRAMS = check_ginac -check_ginac_SOURCES = paranoia_check.cpp numeric_output.cpp numeric_consist.cpp \ - powerlaws.cpp expand_subs.cpp inifcns_consist.cpp differentiation.cpp \ - poly_gcd.cpp normalization.cpp lsolve_onedim.cpp matrix_checks.cpp \ - series_expansion.cpp fcntimer.cpp main.cpp check.h +check_ginac_SOURCES = paranoia_check.cpp numeric_output.cpp \ + numeric_consist.cpp powerlaws.cpp expand_subs.cpp inifcns_consist.cpp \ + differentiation.cpp poly_gcd.cpp normalization.cpp lsolve_onedim.cpp \ + matrix_checks.cpp series_expansion.cpp lortensor_check.cpp \ + fcntimer.cpp main.cpp check.h check_ginac_LDADD = ../ginac/libginac.la CLEANFILES = result.out EXTRA_DIST = result.ref run_checks diff --git a/check/Makefile.in b/check/Makefile.in index f9e5c2cd..f9d3cf45 100644 --- a/check/Makefile.in +++ b/check/Makefile.in @@ -99,7 +99,7 @@ YACC = @YACC@ TESTS = run_checks check_PROGRAMS = check_ginac -check_ginac_SOURCES = paranoia_check.cpp numeric_output.cpp numeric_consist.cpp powerlaws.cpp expand_subs.cpp inifcns_consist.cpp differentiation.cpp poly_gcd.cpp normalization.cpp lsolve_onedim.cpp matrix_checks.cpp series_expansion.cpp fcntimer.cpp main.cpp check.h +check_ginac_SOURCES = paranoia_check.cpp numeric_output.cpp numeric_consist.cpp powerlaws.cpp expand_subs.cpp inifcns_consist.cpp differentiation.cpp poly_gcd.cpp normalization.cpp lsolve_onedim.cpp matrix_checks.cpp series_expansion.cpp lortensor_check.cpp fcntimer.cpp main.cpp check.h check_ginac_LDADD = ../ginac/libginac.la CLEANFILES = result.out @@ -115,7 +115,7 @@ LIBS = @LIBS@ check_ginac_OBJECTS = paranoia_check.o numeric_output.o \ numeric_consist.o powerlaws.o expand_subs.o inifcns_consist.o \ differentiation.o poly_gcd.o normalization.o lsolve_onedim.o \ -matrix_checks.o series_expansion.o fcntimer.o main.o +matrix_checks.o series_expansion.o lortensor_check.o fcntimer.o main.o check_ginac_DEPENDENCIES = ../ginac/libginac.la check_ginac_LDFLAGS = CXXFLAGS = @CXXFLAGS@ @@ -136,10 +136,11 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best DEP_FILES = .deps/differentiation.P .deps/expand_subs.P \ -.deps/fcntimer.P .deps/inifcns_consist.P .deps/lsolve_onedim.P \ -.deps/main.P .deps/matrix_checks.P .deps/normalization.P \ -.deps/numeric_consist.P .deps/numeric_output.P .deps/paranoia_check.P \ -.deps/poly_gcd.P .deps/powerlaws.P .deps/series_expansion.P +.deps/fcntimer.P .deps/inifcns_consist.P .deps/lortensor_check.P \ +.deps/lsolve_onedim.P .deps/main.P .deps/matrix_checks.P \ +.deps/normalization.P .deps/numeric_consist.P .deps/numeric_output.P \ +.deps/paranoia_check.P .deps/poly_gcd.P .deps/powerlaws.P \ +.deps/series_expansion.P SOURCES = $(check_ginac_SOURCES) OBJECTS = $(check_ginac_OBJECTS) diff --git a/check/check.h b/check/check.h index 0474594e..1d149dac 100644 --- a/check/check.h +++ b/check/check.h @@ -40,5 +40,6 @@ unsigned normalization(); unsigned matrix_checks(); unsigned lsolve_onedim(); unsigned series_expansion(); +unsigned lortensor_check(); #endif // ndef CHECK_H diff --git a/check/lortensor_check.cpp b/check/lortensor_check.cpp new file mode 100644 index 00000000..0440abcc --- /dev/null +++ b/check/lortensor_check.cpp @@ -0,0 +1,111 @@ +/** @file lortensor_check.cpp + * + * Here we test manipulations on GiNaC's lortensors. */ + +/* + * GiNaC Copyright (C) 1999 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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 + */ + +#include +#include + +#ifndef NO_GINAC_NAMESPACE +using namespace GiNaC; +#endif // ndef NO_GINAC_NAMESPACE + +static unsigned lortensor_check1(void) +{ + // checks simple identities of the metric tensor! + + unsigned result = 0; + lorentzidx mu("mu"), nu("nu"); + ex e1, e2, e3, e4, e5, e6; + e1 = lortensor_g(mu,nu); + e2 = lortensor_g(nu,mu); + e3 = e1 - e2; // g(~mu,~nu) - g(~nu,~mu) = 0 ! + e4 = lortensor_g(mu,mu.toggle_covariant()); + e5 = lortensor_g(mu.toggle_covariant(),mu); + e6 = e4 - e5; // g(~mu,_mu) - g(_mu,~mu) = 0! + if (!e3.is_zero()) { + clog << e1 << "-" << e2 << " erroneously returned " + << e3 << " instead of 0" << endl; + ++result; + } + if (!e6.is_zero()) { + clog << e4 << "-" << e5 << " erroneously returned " + << e6 << " instead of 0" << endl; + ++result; + } + + return result; +} + +static unsigned lortensor_check2(void) +{ + // checks simple contraction properties of an arbitrary (symmetric!) rankn lortensor! + + unsigned result = 0; + lorentzidx mu("mu"), nu("nu"), rho("rho"); + ex e1, e2, e3, e4, e5, e6, e7, e8, e9, e10; + e1 = lortensor_g(mu,nu); + e2 = lortensor_g(nu,mu); + e3 = lortensor_rank1("p",mu.toggle_covariant()); + e4 = lortensor_rank1("p",nu); + e5 = e3 * e1 - e3 * e2; // p_mu g(~mu,~nu) - p_mu g(~nu,~mu) = 0! + e6 = simplify_lortensor(e3 * e1) - e4; // p~nu - p~nu = 0! + e7 = lortensor_g(nu,rho); + e8 = lortensor_rank2("F",mu.toggle_covariant(),nu.toggle_covariant()); + e9 = lortensor_rank2("F",mu.toggle_covariant(),rho); + 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; + ++result; + } + if (!e6.is_zero()) { + clog << " simplify_lortensor(e3 * e1)" << "-" << e4 << " erroneously returned" + << e6 << " instead of 0" << endl; + ++result; + } + if (!e10.is_zero()) { + clog << " simplify_lortensor(e8 * e7)" << "-" << e9 << " erroneously returned" + << e10 << " instead of 0" << endl; + ++result; + } + + return result; +} + +unsigned lortensor_check(void) +{ + unsigned result = 0; + + cout << "checking manipulations of lortensor objects..." << flush; + clog << "---------manipulations of lortensor objects:" << endl; + + result += lortensor_check1(); + result += lortensor_check2(); + + if (!result) { + cout << " passed "; + clog << "(no output)" << endl; + } else { + cout << " failed "; + } + + return result; +} diff --git a/check/main.cpp b/check/main.cpp index cf363983..b074ec1c 100644 --- a/check/main.cpp +++ b/check/main.cpp @@ -43,6 +43,7 @@ int main() result += fcntimer(matrix_checks); result += fcntimer(lsolve_onedim); result += fcntimer(series_expansion); + result += fcntimer(lortensor_check); } } catch (exception const & e) { cout << "error: caught an exception: " << e.what() << endl; diff --git a/check/result.ref b/check/result.ref index 0e3a9296..b4fa5871 100644 --- a/check/result.ref +++ b/check/result.ref @@ -26,3 +26,5 @@ Complex integers: {(0,0)=0} {(1,0)=1} {(1,1)=1+I} {(0,1)=I} {(-1,1)=-1+I} {(-1,0 (no output) ---------series expansion: (no output) +---------manipulations of lortensor objects: +(no output) -- 2.44.0