]> www.ginac.de Git - ginac.git/blobdiff - ginac/tensor.cpp
simplify_indexed() raises/lowers dummy indices to canonicalize their variance
[ginac.git] / ginac / tensor.cpp
index 9db3635b1e8f7bb0ae31e928aef0dbcea21b72d3..ccae243a6481377d36d460a147afed668a47231f 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's special tensors. */
 
 /*
- *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2002 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
@@ -511,9 +511,13 @@ bool tensepsilon::contract_with(exvector::iterator self, exvector::iterator othe
        } else if (other->return_type() == return_types::commutative) {
 
 #if 0
-               // This handles eps.i.j.k * p.j * p.k = 0
-               // Maybe something like this should go to simplify_indexed() because
-               // such relations are true for any antisymmetric tensors...
+               // This handles eps.i.j.k * p.j * p.k = 0 and related cases.
+               // Actually, simplify_indexed() can handle most of them on its own
+               // but one specific case that is not covered there is
+               //   eps~mu.nu~i~j * p.mu * p~nu
+               // because of the difference in variance in the dummy indices mu
+               // and nu. Eventually, simplify_indexed() should be extended to
+               // handle this case, and this hack removed.
                exvector c;
 
                // Handle all indices of the epsilon tensor
@@ -566,6 +570,9 @@ ex metric_tensor(const ex & i1, const ex & i2)
 {
        if (!is_ex_of_type(i1, varidx) || !is_ex_of_type(i2, varidx))
                throw(std::invalid_argument("indices of metric tensor must be of type varidx"));
+       ex dim = ex_to<idx>(i1).get_dim();
+       if (!dim.is_equal(ex_to<idx>(i2).get_dim()))
+               throw(std::invalid_argument("all indices of metric tensor must have the same dimension"));
 
        return indexed(tensmetric(), sy_symm(), i1, i2);
 }
@@ -574,6 +581,9 @@ ex lorentz_g(const ex & i1, const ex & i2, bool pos_sig)
 {
        if (!is_ex_of_type(i1, varidx) || !is_ex_of_type(i2, varidx))
                throw(std::invalid_argument("indices of metric tensor must be of type varidx"));
+       ex dim = ex_to<idx>(i1).get_dim();
+       if (!dim.is_equal(ex_to<idx>(i2).get_dim()))
+               throw(std::invalid_argument("all indices of metric tensor must have the same dimension"));
 
        return indexed(minkmetric(pos_sig), sy_symm(), i1, i2);
 }