From: Chris Dams Date: Thu, 17 Aug 2006 15:28:16 +0000 (+0000) Subject: Vladimirs patch for removing the "anti-commuting" branches from Clifford X-Git-Tag: release_1-4-0~67 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=f303227c240827857e2fb0631c537f553a9845e2 Vladimirs patch for removing the "anti-commuting" branches from Clifford objects. --- diff --git a/check/exam_clifford.cpp b/check/exam_clifford.cpp index b9c1c175..e43708f2 100644 --- a/check/exam_clifford.cpp +++ b/check/exam_clifford.cpp @@ -318,7 +318,6 @@ static unsigned clifford_check6(const matrix & A) A2 = A_symm.mul(A_symm); ex e, e1; - bool anticommuting = ex_to(clifford_unit(nu, A)).is_anticommuting(); int result = 0; // checks general identities and contractions for clifford_unit @@ -343,8 +342,6 @@ static unsigned clifford_check6(const matrix & A) result += check_equal_simplify(e, A.trace() * clifford_unit(mu, A)); e = clifford_unit(nu, A) * clifford_unit(mu, A) * clifford_unit(nu.toggle_variance(), A); - if (anticommuting) - result += check_equal_simplify(e, 2*indexed(A_symm, sy_symm(), mu, mu)*clifford_unit(mu, A) - A.trace()*clifford_unit(mu, A)); result += check_equal_simplify_term(e, 2 * indexed(A_symm, sy_symm(), nu.toggle_variance(), mu) *clifford_unit(nu, A)-A.trace()*clifford_unit(mu, A), mu); @@ -358,26 +355,17 @@ static unsigned clifford_check6(const matrix & A) e = clifford_unit(mu, A) * clifford_unit(nu, A) * clifford_unit(mu.toggle_variance(), A) * clifford_unit(nu.toggle_variance(), A); - if (anticommuting) - result += check_equal_simplify(e, 2*A2.trace()*dirac_ONE() - pow(A.trace(), 2)*dirac_ONE()); result += check_equal_simplify_term2(e, 2*indexed(A_symm, sy_symm(), nu.toggle_variance(), mu.toggle_variance()) * clifford_unit(mu, A) * clifford_unit(nu, A) - pow(A.trace(), 2)*dirac_ONE()); e = clifford_unit(mu.toggle_variance(), A) * clifford_unit(nu, A) * clifford_unit(mu, A) * clifford_unit(nu.toggle_variance(), A); - if (anticommuting) { - result += check_equal_simplify(e, 2*A2.trace()*dirac_ONE() - pow(A.trace(), 2)*dirac_ONE()); - e1 = remove_dirac_ONE(simplify_indexed(e)); - result += check_equal(e1, 2*A2.trace() - pow(A.trace(), 2)); - } result += check_equal_simplify_term2(e, 2*indexed(A_symm, nu, mu) * clifford_unit(mu.toggle_variance(), A) * clifford_unit(nu.toggle_variance(), A) - pow(A.trace(), 2)*dirac_ONE()); e = clifford_unit(nu.toggle_variance(), A) * clifford_unit(rho.toggle_variance(), A) * clifford_unit(mu, A) * clifford_unit(rho, A) * clifford_unit(nu, A); e = e.simplify_indexed().collect(clifford_unit(mu, A)); - if (anticommuting) - result += check_equal(e, (4*indexed(A2, sy_symm(), mu, mu) - 4 * indexed(A_symm, sy_symm(), mu, mu)*A.trace() +pow(A.trace(), 2)) * clifford_unit(mu, A)); result += check_equal_simplify_term(e, 4* indexed(A_symm, sy_symm(), nu.toggle_variance(), rho)*indexed(A_symm, sy_symm(), rho.toggle_variance(), mu) *clifford_unit(nu, A) - 2*A.trace() * (clifford_unit(rho, A) * indexed(A_symm, sy_symm(), rho.toggle_variance(), mu) @@ -386,8 +374,6 @@ static unsigned clifford_check6(const matrix & A) e = clifford_unit(nu.toggle_variance(), A) * clifford_unit(rho, A) * clifford_unit(mu, A) * clifford_unit(rho.toggle_variance(), A) * clifford_unit(nu, A); e = e.simplify_indexed().collect(clifford_unit(mu, A)); - if (anticommuting) - result += check_equal(e, (4*indexed(A2, sy_symm(), mu, mu) - 4*indexed(A_symm, sy_symm(), mu, mu)*A.trace() +pow(A.trace(), 2))* clifford_unit(mu, A)); result += check_equal_simplify_term(e, 4* indexed(A_symm, sy_symm(), nu.toggle_variance(), rho)*indexed(A_symm, sy_symm(), rho.toggle_variance(), mu) *clifford_unit(nu, A) - 2*A.trace() * (clifford_unit(rho, A) * indexed(A_symm, sy_symm(), rho.toggle_variance(), mu) @@ -532,7 +518,6 @@ unsigned exam_clifford() result += clifford_check4(); cout << '.' << flush; result += clifford_check5(); cout << '.' << flush; -/* // anticommuting, symmetric examples result += clifford_check6(ex_to(diag_matrix(lst(-1, 1, 1, 1)))); cout << '.' << flush; result += clifford_check6(ex_to(diag_matrix(lst(-1, -1, -1, -1)))); cout << '.' << flush; @@ -573,7 +558,6 @@ unsigned exam_clifford() 0, 0, 1, 1, 0, 0, 0, 1; result += clifford_check6(A); cout << '.' << flush; -*/ symbol dim("D"); result += clifford_check7(minkmetric(), dim); cout << '.' << flush; diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index d0b12a76..4195678e 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -3299,13 +3299,11 @@ and contain symbolic entries. Such generators are created by the function @example - ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl = 0, - bool anticommuting = false); + ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl = 0); @end example -where @code{mu} should be a @code{varidx} class object indexing the -generators, an index @code{mu} with a numeric value may be of type -@code{idx} as well. +where @code{mu} should be a @code{idx} (or descendant) class object +indexing the generators. Parameter @code{metr} defines the metric @math{M(i, j)} and can be represented by a square @code{matrix}, @code{tensormetric} or @code{indexed} class object. In fact, any expression either with two free indices or without @@ -3313,20 +3311,7 @@ indices at all is admitted as @code{metr}. In the later case an @code{indexed} object with two newly created indices with @code{metr} as its @code{op(0)} will be used. Optional parameter @code{rl} allows to distinguish different -Clifford algebras, which will commute with each other. The last -optional parameter @code{anticommuting} defines if the anticommuting -assumption (i.e. -@tex -$e_i e_j + e_j e_i = 0$) -@end tex -@ifnottex -e~i e~j + e~j e~i = 0) -@end ifnottex -will be used for contraction of Clifford units. If the @code{metric} is -supplied by a @code{matrix} object, then the value of -@code{anticommuting} is calculated automatically and the supplied one -will be ignored. One can overcome this by giving @code{metric} through -matrix wrapped into an @code{indexed} object. +Clifford algebras, which will commute with each other. Note that the call @code{clifford_unit(mu, minkmetric())} creates something very close to @code{dirac_gamma(mu)}, although @@ -3334,9 +3319,6 @@ something very close to @code{dirac_gamma(mu)}, although @cindex @code{clifford::get_metric()} The method @code{clifford::get_metric()} returns a metric defining this Clifford number. -@cindex @code{clifford::is_anticommuting()} -The method @code{clifford::is_anticommuting()} returns the -@code{anticommuting} property of a unit. If the matrix @math{M(i, j)} is in fact symmetric you may prefer to create the Clifford algebra units with a call like that @@ -3355,14 +3337,14 @@ ways. For example @example @{ ... - varidx nu(symbol("nu"), 4); + idx i(symbol("i"), 4); realsymbol s("s"); ex M = diag_matrix(lst(1, -1, 0, s)); - ex e = clifford_unit(nu, M); - ex e0 = e.subs(nu == 0); - ex e1 = e.subs(nu == 1); - ex e2 = e.subs(nu == 2); - ex e3 = e.subs(nu == 3); + ex e = clifford_unit(i, M); + ex e0 = e.subs(i == 0); + ex e1 = e.subs(i == 1); + ex e2 = e.subs(i == 2); + ex e3 = e.subs(i == 3); ... @} @end example @@ -3381,7 +3363,7 @@ A similar effect can be achieved from the function @example ex lst_to_clifford(const ex & v, const ex & mu, const ex & metr, - unsigned char rl = 0, bool anticommuting = false); + unsigned char rl = 0); ex lst_to_clifford(const ex & v, const ex & e); @end example @@ -3403,19 +3385,19 @@ $v^0 e_0 + v^1 e_1 + ... + v^n e_n$ with @samp{e.k} directly supplied in the second form of the procedure. In the first form the Clifford unit @samp{e.k} is generated by the call of -@code{clifford_unit(mu, metr, rl, anticommuting)}. The previous code may be rewritten +@code{clifford_unit(mu, metr, rl)}. The previous code may be rewritten with the help of @code{lst_to_clifford()} as follows @example @{ ... - varidx nu(symbol("nu"), 4); + idx i(symbol("i"), 4); realsymbol s("s"); ex M = diag_matrix(lst(1, -1, 0, s)); - ex e0 = lst_to_clifford(lst(1, 0, 0, 0), nu, M); - ex e1 = lst_to_clifford(lst(0, 1, 0, 0), nu, M); - ex e2 = lst_to_clifford(lst(0, 0, 1, 0), nu, M); - ex e3 = lst_to_clifford(lst(0, 0, 0, 1), nu, M); + ex e0 = lst_to_clifford(lst(1, 0, 0, 0), i, M); + ex e1 = lst_to_clifford(lst(0, 1, 0, 0), i, M); + ex e2 = lst_to_clifford(lst(0, 0, 1, 0), i, M); + ex e3 = lst_to_clifford(lst(0, 0, 0, 1), i, M); ... @} @end example @@ -3546,9 +3528,9 @@ The next provided function is @example ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, const ex & v, const ex & G, - unsigned char rl = 0, bool anticommuting = false); + unsigned char rl = 0); ex clifford_moebius_map(const ex & M, const ex & v, const ex & G, - unsigned char rl = 0, bool anticommuting = false); + unsigned char rl = 0); @end example It takes a list or vector @code{v} and makes the Moebius (conformal or @@ -3556,10 +3538,9 @@ linear-fractional) transformation @samp{v -> (av+b)/(cv+d)} defined by the matrix @samp{M = [[a, b], [c, d]]}. The parameter @code{G} defines the metric of the surrounding (pseudo-)Euclidean space. This can be an indexed object, tensormetric, matrix or a Clifford unit, in the later -case the optional parameters @code{rl} and @code{anticommuting} are -ignored even if supplied. Depending from the type of @code{v} the -returned value of this function is either a vector or a list holding vector's -components. +case the optional parameter @code{rl} is ignored even if supplied. +Depending from the type of @code{v} the returned value of this function +is either a vector or a list holding vector's components. @cindex @code{clifford_max_label()} Finally the function diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 97b503b8..af54d77b 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -76,7 +76,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(diracgammaR, tensor, // default constructors ////////// -clifford::clifford() : representation_label(0), metric(0), anticommuting(true), commutator_sign(-1) +clifford::clifford() : representation_label(0), metric(0), commutator_sign(-1) { tinfo_key = &clifford::tinfo_static; } @@ -95,7 +95,7 @@ DEFAULT_CTOR(diracgammaR) /** Construct object without any indices. This constructor is for internal * use only. Use the dirac_ONE() function instead. * @see dirac_ONE */ -clifford::clifford(const ex & b, unsigned char rl, bool anticommut) : inherited(b), representation_label(rl), metric(0), anticommuting(anticommut), commutator_sign(-1) +clifford::clifford(const ex & b, unsigned char rl) : inherited(b), representation_label(rl), metric(0), commutator_sign(-1) { tinfo_key = &clifford::tinfo_static; } @@ -104,18 +104,18 @@ clifford::clifford(const ex & b, unsigned char rl, bool anticommut) : inherited( * use only. Use the clifford_unit() or dirac_gamma() functions instead. * @see clifford_unit * @see dirac_gamma */ -clifford::clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl, bool anticommut, int comm_sign) : inherited(b, mu), representation_label(rl), metric(metr), anticommuting(anticommut), commutator_sign(comm_sign) +clifford::clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl, int comm_sign) : inherited(b, mu), representation_label(rl), metric(metr), commutator_sign(comm_sign) { GINAC_ASSERT(is_a(mu)); tinfo_key = &clifford::tinfo_static; } -clifford::clifford(unsigned char rl, const ex & metr, bool anticommut, int comm_sign, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl), metric(metr), anticommuting(anticommut), commutator_sign(comm_sign) +clifford::clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl), metric(metr), commutator_sign(comm_sign) { tinfo_key = &clifford::tinfo_static; } -clifford::clifford(unsigned char rl, const ex & metr, bool anticommut, int comm_sign, std::auto_ptr vp) : inherited(not_symmetric(), vp), representation_label(rl), metric(metr), anticommuting(anticommut), commutator_sign(comm_sign) +clifford::clifford(unsigned char rl, const ex & metr, int comm_sign, std::auto_ptr vp) : inherited(not_symmetric(), vp), representation_label(rl), metric(metr), commutator_sign(comm_sign) { tinfo_key = &clifford::tinfo_static; } @@ -130,7 +130,6 @@ clifford::clifford(const archive_node & n, lst & sym_lst) : inherited(n, sym_lst n.find_unsigned("label", rl); representation_label = rl; n.find_ex("metric", metric, sym_lst); - n.find_bool("anticommuting", anticommuting); n.find_unsigned("commutator_sign+1", rl); commutator_sign = rl - 1; } @@ -140,7 +139,6 @@ void clifford::archive(archive_node & n) const inherited::archive(n); n.add_unsigned("label", representation_label); n.add_ex("metric", metric); - n.add_bool("anticommuting", anticommuting); n.add_unsigned("commutator_sign+1", commutator_sign+1); } @@ -436,22 +434,6 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other return false; } -/** An utility function looking for a given metric within an exvector, - * used in cliffordunit::contract_with(). */ -static int find_same_metric(exvector & v, ex & c) -{ - for (size_t i=0; i(v[i]) && !is_a(v[i]) - && ((ex_to(c.op(1)) == ex_to(v[i]).get_indices()[0] - && ex_to(c.op(1)) == ex_to(v[i]).get_indices()[1]) - || (ex_to(c.op(1)).toggle_variance() == ex_to(v[i]).get_indices()[0] - && ex_to(c.op(1)).toggle_variance() == ex_to(v[i]).get_indices()[1]))) { - return i; // the index of the found term - } - } - return -1; //nothing found -} - /** Contraction of a Clifford unit with something else. */ bool cliffordunit::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const { @@ -468,53 +450,25 @@ bool cliffordunit::contract_with(exvector::iterator self, exvector::iterator oth && unit.same_metric(*other)) return false; - // Find if a previous contraction produces the square of self - int prev_square = find_same_metric(v, *self); - const varidx d((new symbol)->setflag(status_flags::dynallocated), ex_to(self->op(1)).get_dim()), - in1((new symbol)->setflag(status_flags::dynallocated), ex_to(self->op(1)).get_dim()), - in2((new symbol)->setflag(status_flags::dynallocated), ex_to(self->op(1)).get_dim()); - ex squared_metric; - if (prev_square > -1) - squared_metric = simplify_indexed(indexed(v[prev_square].op(0), in1, d) - * unit.get_metric(d.toggle_variance(), in2, true)).op(0); - exvector::iterator before_other = other - 1; - const varidx & mu = ex_to(self->op(1)); - const varidx & mu_toggle = ex_to(other->op(1)); - const varidx & alpha = ex_to(before_other->op(1)); + ex mu = self->op(1); + ex mu_toggle = other->op(1); + ex alpha = before_other->op(1); // e~mu e.mu = Tr ONE if (other - self == 1) { - if (prev_square > -1) { - *self = indexed(squared_metric, mu, mu_toggle); - v[prev_square] = _ex1; - } else { - *self = unit.get_metric(mu, mu_toggle, true); - } + *self = unit.get_metric(mu, mu_toggle, true); *other = dirac_ONE(rl); return true; } else if (other - self == 2) { if (is_a(*before_other) && ex_to(*before_other).get_representation_label() == rl) { - if (ex_to(*self).is_anticommuting()) { - // e~mu e~alpha e.mu = (2*pow(e~alpha, 2) -Tr(B)) e~alpha - if (prev_square > -1) { - *self = 2 * indexed(squared_metric, alpha, alpha) - - indexed(squared_metric, mu, mu_toggle); - v[prev_square] = _ex1; - } else { - *self = 2 * unit.get_metric(alpha, alpha, true) - unit.get_metric(mu, mu_toggle, true); - } - *other = _ex1; - return true; - - } else { - // e~mu e~alpha e.mu = 2*e~mu B(alpha, mu.toggle_variance())-Tr(B) e~alpha - *self = 2 * (*self) * unit.get_metric(alpha, mu_toggle, true) - unit.get_metric(mu, mu_toggle, true) * (*before_other); - *before_other = _ex1; - *other = _ex1; - return true; - } + // e~mu e~alpha e.mu = 2*e~mu B(alpha, mu.toggle_variance())-Tr(B) e~alpha + *self = 2 * (*self) * unit.get_metric(alpha, mu_toggle, true) - unit.get_metric(mu, mu_toggle, true) * (*before_other); + *before_other = _ex1; + *other = _ex1; + return true; + } else { // e~mu S e.mu = Tr S ONE *self = unit.get_metric(mu, mu_toggle, true); @@ -532,16 +486,7 @@ bool cliffordunit::contract_with(exvector::iterator self, exvector::iterator oth ex S = ncmul(exvector(self + 1, before_other), true); if (is_a(*before_other) && ex_to(*before_other).get_representation_label() == rl) { - if (ex_to(*self).is_anticommuting()) { - if (prev_square > -1) { - *self = 2 * (*before_other) * S * indexed(squared_metric, alpha, alpha) - - (*self) * S * (*other) * (*before_other); - } else { - *self = 2 * (*before_other) * S * unit.get_metric(alpha, alpha, true) - (*self) * S * (*other) * (*before_other); - } - } else { - *self = 2 * (*self) * S * unit.get_metric(alpha, mu_toggle, true) - (*self) * S * (*other) * (*before_other); - } + *self = 2 * (*self) * S * unit.get_metric(alpha, mu_toggle, true) - (*self) * S * (*other) * (*before_other); } else { // simply commutes *self = (*self) * S * (*other) * (*before_other); @@ -725,12 +670,12 @@ ex clifford::eval_ncmul(const exvector & v) const ex clifford::thiscontainer(const exvector & v) const { - return clifford(representation_label, metric, anticommuting, commutator_sign, v); + return clifford(representation_label, metric, commutator_sign, v); } ex clifford::thiscontainer(std::auto_ptr vp) const { - return clifford(representation_label, metric, anticommuting, commutator_sign, vp); + return clifford(representation_label, metric, commutator_sign, vp); } ex diracgamma5::conjugate() const @@ -755,50 +700,43 @@ ex diracgammaR::conjugate() const ex dirac_ONE(unsigned char rl) { static ex ONE = (new diracone)->setflag(status_flags::dynallocated); - return clifford(ONE, rl, false); + return clifford(ONE, rl); } -ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl, bool anticommuting) +ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl) { static ex unit = (new cliffordunit)->setflag(status_flags::dynallocated); if (!is_a(mu)) throw(std::invalid_argument("clifford_unit(): index of Clifford unit must be of type idx or varidx")); - if (ex_to(mu).is_symbolic() && !is_a(mu)) - throw(std::invalid_argument("clifford_unit(): symbolic index of Clifford unit must be of type varidx (not idx)")); - exvector indices = metr.get_free_indices(); if ((indices.size() == 2) && is_a(indices[0]) && is_a(indices[1])) { - return clifford(unit, mu, metr, rl, anticommuting); + return clifford(unit, mu, metr, rl); } else if (is_a(metr)) { matrix M = ex_to(metr); unsigned n = M.rows(); bool symmetric = true; - anticommuting = true; static varidx 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())) { + if ((n == M.cols()) && (n == ex_to(mu).get_dim())) { for (unsigned i = 0; i < n; i++) { for (unsigned j = i+1; j < n; j++) { if (M(i, j) != M(j, i)) { symmetric = false; } - if (M(i, j) != -M(j, i)) { - anticommuting = false; - } } } - return clifford(unit, mu, indexed(metr, symmetric?symmetric2():not_symmetric(), xi, chi), rl, anticommuting); + return clifford(unit, mu, indexed(metr, symmetric?symmetric2():not_symmetric(), xi, chi), rl); } else { 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()); - return clifford(unit, mu, indexed(metr, xi, chi), rl, anticommuting); + 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")); } @@ -812,7 +750,7 @@ ex dirac_gamma(const ex & mu, unsigned char rl) 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(gamma, mu, indexed((new minkmetric)->setflag(status_flags::dynallocated), symmetric2(), xi, chi), rl, true); + return clifford(gamma, mu, indexed((new minkmetric)->setflag(status_flags::dynallocated), symmetric2(), xi, chi), rl); } ex dirac_gamma5(unsigned char rl) @@ -841,7 +779,7 @@ ex dirac_slash(const ex & e, const ex & dim, unsigned char rl) static varidx xi((new symbol)->setflag(status_flags::dynallocated), dim), chi((new symbol)->setflag(status_flags::dynallocated), dim); - return clifford(e, varidx(0, dim), indexed((new minkmetric)->setflag(status_flags::dynallocated), symmetric2(), xi, chi), rl, true); + return clifford(e, varidx(0, dim), indexed((new minkmetric)->setflag(status_flags::dynallocated), symmetric2(), xi, chi), rl); } /** Check whether a given tinfo key (as returned by return_type_tinfo() @@ -1204,11 +1142,11 @@ ex clifford_inverse(const ex & e) throw(std::invalid_argument("clifford_inverse(): cannot find inverse of Clifford number with zero norm!")); } -ex lst_to_clifford(const ex & v, const ex & mu, const ex & metr, unsigned char rl, bool anticommuting) +ex lst_to_clifford(const ex & v, const ex & mu, const ex & metr, unsigned char rl) { if (!ex_to(mu).is_dim_numeric()) throw(std::invalid_argument("lst_to_clifford(): Index should have a numeric dimension")); - ex e = clifford_unit(mu, metr, rl, anticommuting); + ex e = clifford_unit(mu, metr, rl); return lst_to_clifford(v, e); } @@ -1216,8 +1154,10 @@ ex lst_to_clifford(const ex & v, const ex & e) { unsigned min, max; if (is_a(e)) { - varidx mu = ex_to(e.op(1)); - unsigned dim = (ex_to(mu.get_dim())).to_int(); + ex mu = e.op(1); + ex mu_toggle + = is_a(mu) ? ex_to(mu).toggle_variance() : mu; + unsigned dim = (ex_to(ex_to(mu).get_dim())).to_int(); if (is_a(v)) { if (ex_to(v).cols() > ex_to(v).rows()) { @@ -1229,14 +1169,14 @@ ex lst_to_clifford(const ex & v, const ex & e) { } if (min == 1) { if (dim == max) - return indexed(v, ex_to(mu).toggle_variance()) * e; + return indexed(v, mu_toggle) * e; else throw(std::invalid_argument("lst_to_clifford(): dimensions of vector and clifford unit mismatch")); } else throw(std::invalid_argument("lst_to_clifford(): first argument should be a vector (nx1 or 1xn matrix)")); } else if (v.info(info_flags::list)) { if (dim == ex_to(v).nops()) - return indexed(matrix(dim, 1, ex_to(v)), ex_to(mu).toggle_variance()) * e; + return indexed(matrix(dim, 1, ex_to(v)), mu_toggle) * e; else throw(std::invalid_argument("lst_to_clifford(): list length and dimension of clifford unit mismatch")); } else @@ -1250,7 +1190,7 @@ ex lst_to_clifford(const ex & v, const ex & e) { static ex get_clifford_comp(const ex & e, const ex & c) { pointer_to_map_function_1arg fcn(get_clifford_comp, c); - int ival = ex_to(ex_to(c.op(1)).get_value()).to_int(); + int ival = ex_to(ex_to(c.op(1)).get_value()).to_int(); if (is_a(e) || e.info(info_flags::list) // || is_a(e) || is_a(e) || is_a(e)) @@ -1267,8 +1207,8 @@ static ex get_clifford_comp(const ex & e, const ex & c) if (ind < e.nops()) { ex S = 1; bool same_value_index, found_dummy; - same_value_index = ( ex_to(e.op(ind).op(1)).is_numeric() - && (ival == ex_to(ex_to(e.op(ind).op(1)).get_value()).to_int()) ); + same_value_index = ( ex_to(e.op(ind).op(1)).is_numeric() + && (ival == ex_to(ex_to(e.op(ind).op(1)).get_value()).to_int()) ); found_dummy = same_value_index; for(size_t j=0; j < e.nops(); j++) if (j != ind) @@ -1280,7 +1220,12 @@ static ex get_clifford_comp(const ex & e, const ex & c) found_dummy = true; exvector::const_iterator it = ind_vec.begin(), itend = ind_vec.end(); while (it != itend) { - S = S * e.op(j).subs(lst(ex_to(*it) == ival, ex_to(*it).toggle_variance() == ival), subs_options::no_pattern); + ex curridx = *it; + ex curridx_toggle = is_a(curridx) + ? ex_to(curridx).toggle_variance() + : curridx; + S = S * e.op(j).subs(lst(curridx == ival, + curridx_toggle == ival), subs_options::no_pattern); ++it; } } else @@ -1292,8 +1237,8 @@ static ex get_clifford_comp(const ex & e, const ex & c) } else if (e.is_zero()) return e; else if (is_a(e) && ex_to(e).same_metric(c)) - if ( ex_to(e.op(1)).is_numeric() && - (ival != ex_to(ex_to(e.op(1)).get_value()).to_int()) ) + if ( ex_to(e.op(1)).is_numeric() && + (ival != ex_to(ex_to(e.op(1)).get_value()).to_int()) ) return 0; else return 1; @@ -1305,10 +1250,10 @@ static ex get_clifford_comp(const ex & e, const ex & c) lst clifford_to_lst(const ex & e, const ex & c, bool algebraic) { GINAC_ASSERT(is_a(c)); - varidx mu = ex_to(c.op(1)); - if (! mu.is_dim_numeric()) + ex mu = c.op(1); + if (! ex_to(mu).is_dim_numeric()) throw(std::invalid_argument("clifford_to_lst(): index should have a numeric dimension")); - unsigned int D = ex_to(mu.get_dim()).to_int(); + unsigned int D = ex_to(ex_to(mu).get_dim()).to_int(); if (algebraic) // check if algebraic method is applicable for (unsigned int i = 0; i < D; i++) @@ -1337,7 +1282,7 @@ lst clifford_to_lst(const ex & e, const ex & c, bool algebraic) } -ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, const ex & v, const ex & G, unsigned char rl, bool anticommuting) +ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, const ex & v, const ex & G, unsigned char rl) { ex x, D, cu; @@ -1354,7 +1299,7 @@ ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, 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, anticommuting); + cu = clifford_unit(mu, G, rl); } x = lst_to_clifford(v, cu); @@ -1362,11 +1307,11 @@ ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, return (is_a(v) ? matrix(ex_to(v).rows(), ex_to(v).cols(), ex_to(e)) : e); } -ex clifford_moebius_map(const ex & M, const ex & v, const ex & G, unsigned char rl, bool anticommuting) +ex clifford_moebius_map(const ex & M, const ex & v, const ex & G, unsigned char rl) { if (is_a(M)) return clifford_moebius_map(ex_to(M)(0,0), ex_to(M)(0,1), - ex_to(M)(1,0), ex_to(M)(1,1), v, G, rl, anticommuting); + ex_to(M)(1,0), ex_to(M)(1,1), v, G, rl); else throw(std::invalid_argument("clifford_moebius_map(): parameter M should be a matrix")); } diff --git a/ginac/clifford.h b/ginac/clifford.h index 2d33631d..a380843d 100644 --- a/ginac/clifford.h +++ b/ginac/clifford.h @@ -46,12 +46,12 @@ public: // other constructors public: - clifford(const ex & b, unsigned char rl = 0, bool anticommut = false); - clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl = 0, bool anticommut = false, int comm_sign = -1); + clifford(const ex & b, unsigned char rl = 0); + clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl = 0, int comm_sign = -1); // internal constructors - clifford(unsigned char rl, const ex & metr, bool anticommut, int comm_sign, const exvector & v, bool discardable = false); - clifford(unsigned char rl, const ex & metr, bool anticommut, int comm_sign, std::auto_ptr vp); + clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v, bool discardable = false); + clifford(unsigned char rl, const ex & metr, int comm_sign, std::auto_ptr vp); // functions overriding virtual functions from base classes public: @@ -70,7 +70,6 @@ public: ex get_metric() const { return metric; } virtual ex get_metric(const ex & i, const ex & j, bool symmetrised = false) const; bool same_metric(const ex & other) const; - bool is_anticommuting() const { return anticommuting; } //**< See the member variable anticommuting */ int get_commutator_sign() const { return commutator_sign; } //**< See the member variable commutator_sign */ inline size_t nops() const {return inherited::nops() + 1; } @@ -86,7 +85,6 @@ protected: protected: unsigned char representation_label; /**< Representation label to distinguish independent spin lines */ ex metric; /**< Metric of the space, all constructors make it an indexed object */ - bool anticommuting; /**< Simplifications for anticommuting units is much simpler and we need this info readily available */ int commutator_sign; /**< It is the sign in the definition e~i e~j +/- e~j e~i = B(i, j) + B(j, i)*/ }; @@ -206,7 +204,7 @@ ex dirac_ONE(unsigned char rl = 0); * @param metr Metric (should be indexed, tensmetric or a derived class, or a matrix) * @param rl Representation label * @return newly constructed Clifford unit object */ -ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl = 0, bool anticommuting = false); +ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl = 0); /** Create a Dirac gamma object. * @@ -317,7 +315,7 @@ ex clifford_inverse(const ex & e); * @param rl Representation label * @param e Clifford unit object * @return Clifford vector with given components */ -ex lst_to_clifford(const ex & v, const ex & mu, const ex & metr, unsigned char rl = 0, bool anticommuting = false); +ex lst_to_clifford(const ex & v, const ex & mu, const ex & metr, unsigned char rl = 0); ex lst_to_clifford(const ex & v, const ex & e); /** An inverse function to lst_to_clifford(). For given Clifford vector extracts @@ -345,9 +343,8 @@ lst clifford_to_lst(const ex & e, const ex & c, bool algebraic=true); * @param v Vector to be transformed * @param G Metric of the surrounding space, may be a Clifford unit then the next parameter is ignored * @param rl Representation label - * @param anticommuting indicates if Clifford units anticommutes * @return List of components of the transformed vector*/ -ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, const ex & v, const ex & G, unsigned char rl = 0, bool anticommuting = false); +ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, const ex & v, const ex & G, unsigned char rl = 0); /** The second form of Moebius transformations defined by a 2x2 Clifford matrix M * This function takes the transformation matrix M as a single entity. @@ -356,9 +353,8 @@ ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, * @param v Vector to be transformed * @param G Metric of the surrounding space, may be a Clifford unit then the next parameter is ignored * @param rl Representation label - * @param anticommuting indicates if Clifford units anticommutes * @return List of components of the transformed vector*/ -ex clifford_moebius_map(const ex & M, const ex & v, const ex & G, unsigned char rl = 0, bool anticommuting = false); +ex clifford_moebius_map(const ex & M, const ex & v, const ex & G, unsigned char rl = 0); } // namespace GiNaC