]> www.ginac.de Git - ginac.git/commitdiff
synced to 1.0
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 3 Jul 2002 20:51:04 +0000 (20:51 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 3 Jul 2002 20:51:04 +0000 (20:51 +0000)
ginac/clifford.cpp
ginac/color.cpp
ginac/indexed.cpp
ginac/indexed.h
ginac/power.cpp

index 8412d62f037ed14991f1e2b77a0fc0c4a0964dd2..9533ccd19f77c17037be3741a39dfc8de25bac9c 100644 (file)
@@ -179,6 +179,9 @@ static void base_and_index(const ex & c, ex & b, ex & i)
        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());
@@ -196,6 +199,10 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other
 
        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
index 0327b908009e8446412b5c07f4e20e951853c881..7c2b37de411762babef2da45425f308142a23461 100644 (file)
@@ -308,6 +308,11 @@ bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exve
 
        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);
index ce284170c62474eb2886001d53c8b598a1caec27..85ef415f1206cffae41031ada051930081b022aa 100644 (file)
@@ -192,19 +192,17 @@ void indexed::print(const print_context & c, unsigned level) const
 
                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 ? ")}" : ")");
        }
 }
 
index 58c8bbd4ce16bda7ad563a7c3fb987610ed11317..f539444e7b29f04b39edf42bbf38d0059ecd1924 100644 (file)
@@ -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:
index e9b3f8393849e2c3674d45519ada50efef114a20..bbed51fec6a5dce866f748fe21964f3da91c1bcf 100644 (file)
@@ -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<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 ? ")}" : ")");
                }
        }
 }