X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fclifford.cpp;h=a434a882b804207a4c67b058cf776932ea20bfeb;hp=af54d77bbcb665ef7478c6dfd300c2d4aa4dd109;hb=18d403808b2c0fd73f43cbf4e346c5902f052a65;hpb=f303227c240827857e2fb0631c537f553a9845e2 diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index af54d77b..a434a882 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */ /* - * GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2007 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 @@ -265,8 +265,21 @@ void clifford::do_print_dflt(const print_dflt & c, unsigned level) const if (is_dirac_slash(seq[0])) { seq[0].print(c, precedence()); c.s << "\\"; - } else - this->print_dispatch(c, level); + } else { // We do not print representation label if it is 0 + if (representation_label == 0) { + this->print_dispatch(c, level); + } else { // otherwise we put it before indices in square brackets; the code is borrowed from indexed.cpp + if (precedence() <= level) { + c.s << '('; + } + seq[0].print(c, precedence()); + c.s << '[' << int(representation_label) << ']'; + printindices(c, level); + if (precedence() <= level) { + c.s << ')'; + } + } + } } void clifford::do_print_latex(const print_latex & c, unsigned level) const @@ -712,14 +725,14 @@ ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl) exvector indices = metr.get_free_indices(); - if ((indices.size() == 2) && is_a(indices[0]) && is_a(indices[1])) { + if (indices.size() == 2) { return clifford(unit, mu, metr, rl); } else if (is_a(metr)) { matrix M = ex_to(metr); unsigned n = M.rows(); bool symmetric = true; - static varidx xi((new symbol)->setflag(status_flags::dynallocated), n), + static idx xi((new symbol)->setflag(status_flags::dynallocated), n), chi((new symbol)->setflag(status_flags::dynallocated), n); if ((n == M.cols()) && (n == ex_to(mu).get_dim())) { for (unsigned i = 0; i < n; i++) { @@ -734,8 +747,8 @@ ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl) throw(std::invalid_argument("clifford_unit(): metric for Clifford unit must be a square matrix with the same dimensions as index")); } } else if (indices.size() == 0) { // a tensor or other expression without indices - static varidx xi((new symbol)->setflag(status_flags::dynallocated), ex_to(mu).get_dim()), - chi((new symbol)->setflag(status_flags::dynallocated), ex_to(mu).get_dim()); + static varidx xi((new symbol)->setflag(status_flags::dynallocated), ex_to(mu).get_dim()), + chi((new symbol)->setflag(status_flags::dynallocated), ex_to(mu).get_dim()); return clifford(unit, mu, indexed(metr, xi, chi), rl); } else throw(std::invalid_argument("clifford_unit(): metric for Clifford unit must be of type tensor, matrix or an expression with two free indices")); @@ -1292,14 +1305,16 @@ ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, if (is_a(G)) { cu = G; } else { - if (is_a(G)) - D = ex_to(G.op(1)).get_dim(); - else if (is_a(G)) + if (is_a(G)) { + D = ex_to(G.op(1)).get_dim(); + varidx mu((new symbol)->setflag(status_flags::dynallocated), D); + cu = clifford_unit(mu, G, rl); + } else if (is_a(G)) { D = ex_to(G).rows(); - else throw(std::invalid_argument("clifford_moebius_map(): metric should be an indexed object, matrix, or a Clifford unit")); + idx mu((new symbol)->setflag(status_flags::dynallocated), D); + cu = clifford_unit(mu, G, rl); + } else throw(std::invalid_argument("clifford_moebius_map(): metric should be an indexed object, matrix, or a Clifford unit")); - varidx mu((new symbol)->setflag(status_flags::dynallocated), D); - cu = clifford_unit(mu, G, rl); } x = lst_to_clifford(v, cu);