if (is_a<diracgamma>(c.op(0))) { // proper dirac gamma object
i = c.op(1);
b = _ex1;
+ } else if (is_a<diracgamma5>(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<idx>(c.op(1)).get_dim());
b = indexed(c.op(0), ix.toggle_variance());
if (is_a<clifford>(*other)) {
+ // Contraction only makes sense if the represenation labels are equal
+ if (ex_to<clifford>(*other).get_representation_label() != rl)
+ return false;
+
ex dim = ex_to<idx>(self->op(1)).get_dim();
// gamma~mu gamma.mu = dim ONE
if (is_exactly_a<su3t>(other->op(0))) {
+ // Contraction only makes sense if the represenation labels are equal
+ GINAC_ASSERT(is_a<color>(*other));
+ if (ex_to<color>(*other).get_representation_label() != rl)
+ return false;
+
// T.a T.a = 4/3 ONE
if (other - self == 1) {
*self = numeric(4, 3);
bool is_tex = is_a<print_latex>(c);
const ex & base = seq[0];
- bool need_parens = is_exactly_a<add>(base) || is_exactly_a<mul>(base)
- || is_exactly_a<ncmul>(base) || is_exactly_a<power>(base)
- || is_a<indexed>(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 ? ")}" : ")");
}
}
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:
#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"
} else {
+ bool is_tex = is_a<print_latex>(c);
+
if (exponent.is_equal(_ex1_2)) {
- if (is_a<print_latex>(c))
- c.s << "\\sqrt{";
- else
- c.s << "sqrt(";
+ c.s << (is_tex ? "\\sqrt{" : "sqrt(");
basis.print(c);
- if (is_a<print_latex>(c))
- c.s << '}';
- else
- c.s << ')';
+ c.s << (is_tex ? '}' : ')');
} else {
- if (precedence() <= level) {
- if (is_a<print_latex>(c))
- c.s << "{(";
- else
- c.s << "(";
- }
+ if (precedence() <= level)
+ c.s << (is_tex ? "{(" : "(");
basis.print(c, precedence());
if (is_a<print_python>(c))
c.s << "**";
else
c.s << '^';
- if (is_a<print_latex>(c))
+ if (is_tex)
c.s << '{';
exponent.print(c, precedence());
- if (is_a<print_latex>(c))
+ if (is_tex)
c.s << '}';
- if (precedence() <= level) {
- if (is_a<print_latex>(c))
- c.s << ")}";
- else
- c.s << ')';
- }
+ if (precedence() <= level)
+ c.s << (is_tex ? ")}" : ")");
}
}
}