- added simple checks of manipulations with lortensor objects.
authorwelzel <welzel>
Mon, 10 Jan 2000 19:02:27 +0000 (19:02 +0000)
committerwelzel <welzel>
Mon, 10 Jan 2000 19:02:27 +0000 (19:02 +0000)
check/Makefile.am
check/Makefile.in
check/check.h
check/lortensor_check.cpp [new file with mode: 0644]
check/main.cpp
check/result.ref

index 924de84f90e800ded20fb8d296f24ce331fd975e..5c251ed2686dec0e6fe7f97ee9a44365ba6c0a83 100644 (file)
@@ -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
index f9e5c2cd51b697a7f73fc74cbf4bd3cdb1b6d7be..f9d3cf4598476019cb1c6e54c096935eeb3cfee8 100644 (file)
@@ -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)
 
index 0474594efb77ebd31c924013c9d8e3068c8bc048..1d149dac9858a95a60ca2e12000e9ad3dc8a9329 100644 (file)
@@ -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 (file)
index 0000000..0440abc
--- /dev/null
@@ -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 <stdexcept>
+#include <ginac/ginac.h>
+
+#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;    
+}
index cf363983f2863802cb917d3e907552336bbde0c8..b074ec1c23f986231b324a02a04fa0eb5d018b51 100644 (file)
@@ -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;
index 0e3a92963ade26a434564b60373319d9b08a8adb..b4fa58717336d99b28c3698593fd5f9712003f6a 100644 (file)
@@ -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)