From 95759eec164177e0817f9af9e7f3c55d87f19e26 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Wed, 3 Jul 2002 20:51:04 +0000 Subject: [PATCH 1/1] synced to 1.0 --- ginac/clifford.cpp | 7 +++++++ ginac/color.cpp | 5 +++++ ginac/indexed.cpp | 14 ++++++-------- ginac/indexed.h | 1 + ginac/power.cpp | 33 +++++++++++---------------------- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 8412d62f..9533ccd1 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -179,6 +179,9 @@ static void base_and_index(const ex & c, ex & b, ex & i) if (is_a(c.op(0))) { // proper dirac gamma object i = c.op(1); b = _ex1; + } else if (is_a(c.op(0))) { // gamma5 + i = _ex0; + b = _ex1; } else { // slash object, generate new dummy index varidx ix((new symbol)->setflag(status_flags::dynallocated), ex_to(c.op(1)).get_dim()); b = indexed(c.op(0), ix.toggle_variance()); @@ -196,6 +199,10 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other if (is_a(*other)) { + // Contraction only makes sense if the represenation labels are equal + if (ex_to(*other).get_representation_label() != rl) + return false; + ex dim = ex_to(self->op(1)).get_dim(); // gamma~mu gamma.mu = dim ONE diff --git a/ginac/color.cpp b/ginac/color.cpp index 0327b908..7c2b37de 100644 --- a/ginac/color.cpp +++ b/ginac/color.cpp @@ -308,6 +308,11 @@ bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exve if (is_exactly_a(other->op(0))) { + // Contraction only makes sense if the represenation labels are equal + GINAC_ASSERT(is_a(*other)); + if (ex_to(*other).get_representation_label() != rl) + return false; + // T.a T.a = 4/3 ONE if (other - self == 1) { *self = numeric(4, 3); diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp index ce284170..85ef415f 100644 --- a/ginac/indexed.cpp +++ b/ginac/indexed.cpp @@ -192,19 +192,17 @@ void indexed::print(const print_context & c, unsigned level) const bool is_tex = is_a(c); const ex & base = seq[0]; - bool need_parens = is_exactly_a(base) || is_exactly_a(base) - || is_exactly_a(base) || is_exactly_a(base) - || is_a(base); + + if (precedence() <= level) + c.s << (is_tex ? "{(" : "("); if (is_tex) c.s << "{"; - if (need_parens) - c.s << "("; - base.print(c); - if (need_parens) - c.s << ")"; + base.print(c, precedence()); if (is_tex) c.s << "}"; printindices(c, level); + if (precedence() <= level) + c.s << (is_tex ? ")}" : ")"); } } diff --git a/ginac/indexed.h b/ginac/indexed.h index 58c8bbd4..f539444e 100644 --- a/ginac/indexed.h +++ b/ginac/indexed.h @@ -42,6 +42,7 @@ class indexed : public exprseq friend ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indices, const scalar_products & sp); friend ex simplify_indexed_product(const ex & e, exvector & free_indices, exvector & dummy_indices, const scalar_products & sp); + friend bool reposition_dummy_indices(ex & e, exvector & variant_dummy_indices, exvector & moved_indices); // other constructors public: diff --git a/ginac/power.cpp b/ginac/power.cpp index e9b3f839..bbed51fe 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -33,6 +33,7 @@ #include "constant.h" #include "inifcns.h" // for log() in power::derivative() #include "matrix.h" +#include "indexed.h" #include "symbol.h" #include "print.h" #include "archive.h" @@ -169,39 +170,27 @@ void power::print(const print_context & c, unsigned level) const } else { + bool is_tex = is_a(c); + if (exponent.is_equal(_ex1_2)) { - if (is_a(c)) - c.s << "\\sqrt{"; - else - c.s << "sqrt("; + c.s << (is_tex ? "\\sqrt{" : "sqrt("); basis.print(c); - if (is_a(c)) - c.s << '}'; - else - c.s << ')'; + c.s << (is_tex ? '}' : ')'); } else { - if (precedence() <= level) { - if (is_a(c)) - c.s << "{("; - else - c.s << "("; - } + if (precedence() <= level) + c.s << (is_tex ? "{(" : "("); basis.print(c, precedence()); if (is_a(c)) c.s << "**"; else c.s << '^'; - if (is_a(c)) + if (is_tex) c.s << '{'; exponent.print(c, precedence()); - if (is_a(c)) + if (is_tex) c.s << '}'; - if (precedence() <= level) { - if (is_a(c)) - c.s << ")}"; - else - c.s << ')'; - } + if (precedence() <= level) + c.s << (is_tex ? ")}" : ")"); } } } -- 2.45.2