X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Ftensor.cpp;h=587a8170c38422c44b5719d5ca6bde2a0c9571a9;hp=0ef65cc8ae66e963874e717384b3376dafacba4f;hb=86403ac639de455166ea58d5c561db7de477fcd8;hpb=0e74ef6ac5071722bd2792ffb4fbaf71a22cb7eb diff --git a/ginac/tensor.cpp b/ginac/tensor.cpp index 0ef65cc8..587a8170 100644 --- a/ginac/tensor.cpp +++ b/ginac/tensor.cpp @@ -566,6 +566,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(i1).get_dim(); + if (!dim.is_equal(ex_to(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 +577,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(i1).get_dim(); + if (!dim.is_equal(ex_to(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); }