X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Ftensor.cpp;h=89fc6a0767898cc9b89c020eee8523ef5446add8;hp=22b3e73040f371c732bc90b1c9ef95e6f24037d3;hb=406f9f2022af2bcc55eea6dac7a5c5a500046f29;hpb=def26469ff96228c66e877bb5594e7d9a24b638f diff --git a/ginac/tensor.cpp b/ginac/tensor.cpp index 22b3e730..89fc6a07 100644 --- a/ginac/tensor.cpp +++ b/ginac/tensor.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's special tensors. */ /* - * GiNaC Copyright (C) 1999-2008 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 @@ -20,10 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include -#include - #include "tensor.h" #include "idx.h" #include "indexed.h" @@ -36,6 +32,10 @@ #include "archive.h" #include "utils.h" +#include +#include +#include + namespace GiNaC { GINAC_IMPLEMENT_REGISTERED_CLASS(tensor, basic) @@ -96,17 +96,12 @@ tensepsilon::tensepsilon(bool mink, bool ps) : minkowski(mink), pos_sig(ps) // archiving ////////// -DEFAULT_ARCHIVING(tensor) -DEFAULT_ARCHIVING(tensdelta) -DEFAULT_ARCHIVING(tensmetric) -DEFAULT_ARCHIVING(spinmetric) -DEFAULT_UNARCHIVE(minkmetric) -DEFAULT_UNARCHIVE(tensepsilon) - -minkmetric::minkmetric(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst) +void minkmetric::read_archive(const archive_node& n, lst& sym_lst) { + inherited::read_archive(n, sym_lst); n.find_bool("pos_sig", pos_sig); } +GINAC_BIND_UNARCHIVER(minkmetric); void minkmetric::archive(archive_node &n) const { @@ -114,11 +109,13 @@ void minkmetric::archive(archive_node &n) const n.add_bool("pos_sig", pos_sig); } -tensepsilon::tensepsilon(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst) +void tensepsilon::read_archive(const archive_node& n, lst& sym_lst) { + inherited::read_archive(n, sym_lst); n.find_bool("minkowski", minkowski); n.find_bool("pos_sig", pos_sig); } +GINAC_BIND_UNARCHIVER(tensepsilon); void tensepsilon::archive(archive_node &n) const { @@ -127,6 +124,10 @@ void tensepsilon::archive(archive_node &n) const n.add_bool("pos_sig", pos_sig); } +GINAC_BIND_UNARCHIVER(tensdelta); +GINAC_BIND_UNARCHIVER(tensmetric); +GINAC_BIND_UNARCHIVER(spinmetric); + ////////// // functions overriding virtual functions from base classes ////////// @@ -363,13 +364,17 @@ ex tensepsilon::eval_indexed(const basic & i) const if (minkowski) { for (size_t j=1; j(x)) + if (!is_a(x)) { throw(std::runtime_error("indices of epsilon tensor in Minkowski space must be of type varidx")); - if (ex_to(x).is_covariant()) - if (ex_to(x).get_value().is_zero()) + } + if (ex_to(x).is_covariant()) { + if (ex_to(x).get_value().is_zero()) { sign = (pos_sig ? -sign : sign); - else + } + else { sign = (pos_sig ? sign : -sign); + } + } } }