X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Fclifford.cpp;h=f50062695232401a51205eb128c44223956eebae;hb=47295e1e73d54bf6cf8953ecc0ce2a848c1fb5b3;hp=16f83196668bd1161cf9f0b3ea52577842bf2682;hpb=1b8bcb068171ce9d5c8202ae3c76647b65c9a06d;p=ginac.git diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 16f83196..f5006269 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -105,7 +105,7 @@ clifford::clifford(const ex & b, const ex & mu, const ex & metr, unsigned char r GINAC_ASSERT(is_a(mu)); } -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) +clifford::clifford(unsigned char rl, const ex & metr, int comm_sign, const exvector & v) : inherited(not_symmetric(), v), representation_label(rl), metric(metr), commutator_sign(comm_sign) { } @@ -161,15 +161,15 @@ ex clifford::get_metric(const ex & i, const ex & j, bool symmetrised) const return simplify_indexed(indexed(metric.op(0)*_ex1_2, i, j) + indexed(metric.op(0)*_ex1_2, j, i)); } } else { - return metric.subs(lst(metric.op(1) == i, metric.op(2) == j), subs_options::no_pattern); + return metric.subs(lst{metric.op(1) == i, metric.op(2) == j}, subs_options::no_pattern); } } else { exvector indices = metric.get_free_indices(); if (symmetrised) - return _ex1_2*simplify_indexed(metric.subs(lst(indices[0] == i, indices[1] == j), subs_options::no_pattern) - + metric.subs(lst(indices[0] == j, indices[1] == i), subs_options::no_pattern)); + return _ex1_2*simplify_indexed(metric.subs(lst{indices[0] == i, indices[1] == j}, subs_options::no_pattern) + + metric.subs(lst{indices[0] == j, indices[1] == i}, subs_options::no_pattern)); else - return metric.subs(lst(indices[0] == i, indices[1] == j), subs_options::no_pattern); + return metric.subs(lst{indices[0] == i, indices[1] == j}, subs_options::no_pattern); } } @@ -321,7 +321,7 @@ static void base_and_index(const ex & c, ex & b, ex & i) 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()); + varidx ix(dynallocate(), ex_to(c.op(1)).get_dim()); b = indexed(c.op(0), ix.toggle_variance()); i = ix; } @@ -399,7 +399,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other if (std::find_if(self + 1, other, is_not_a_clifford()) != other) return false; - *self = ncmul(exvector(std::reverse_iterator(other), std::reverse_iterator(self + 1)), true); + *self = ncmul(exvector(std::reverse_iterator(other), std::reverse_iterator(self + 1))); std::fill(self + 1, other, _ex1); *other = _ex_2; return true; @@ -412,8 +412,8 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other return false; exvector::iterator next_to_last = other - 1; - ex S = ncmul(exvector(self + 1, next_to_last), true); - ex SR = ncmul(exvector(std::reverse_iterator(next_to_last), std::reverse_iterator(self + 1)), true); + ex S = ncmul(exvector(self + 1, next_to_last)); + ex SR = ncmul(exvector(std::reverse_iterator(next_to_last), std::reverse_iterator(self + 1))); *self = (*next_to_last) * S + SR * (*next_to_last); std::fill(self + 1, other, _ex1); @@ -428,7 +428,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other return false; exvector::iterator next_to_last = other - 1; - ex S = ncmul(exvector(self + 1, next_to_last), true); + ex S = ncmul(exvector(self + 1, next_to_last)); *self = 2 * (*next_to_last) * S - (*self) * S * (*other) * (*next_to_last); std::fill(self + 1, other + 1, _ex1); @@ -495,7 +495,7 @@ bool cliffordunit::contract_with(exvector::iterator self, exvector::iterator oth return false; } - ex S = ncmul(exvector(self + 1, before_other), true); + ex S = ncmul(exvector(self + 1, before_other)); if (is_a(*before_other) && ex_to(*before_other).get_representation_label() == rl) { *self = 2 * (*self) * S * unit.get_metric(alpha, mu_toggle, true) - (*self) * S * (*other) * (*before_other); @@ -661,7 +661,7 @@ ex clifford::eval_ncmul(const exvector & v) const } else if (!a_is_cliffordunit && !b_is_cliffordunit && ag.is_equal(bg)) { // a\ a\ -> a^2 - varidx ix((new symbol)->setflag(status_flags::dynallocated), ex_to(a.op(1)).minimal_dim(ex_to(b.op(1)))); + varidx ix(dynallocate(), ex_to(a.op(1)).minimal_dim(ex_to(b.op(1)))); a = indexed(ag, ix) * indexed(ag, ix.toggle_variance()); b = dirac_ONE(representation_label); @@ -695,12 +695,12 @@ ex diracgamma5::conjugate() const ex diracgammaL::conjugate() const { - return (new diracgammaR)->setflag(status_flags::dynallocated); + return dynallocate(); } ex diracgammaR::conjugate() const { - return (new diracgammaL)->setflag(status_flags::dynallocated); + return dynallocate(); } ////////// @@ -709,7 +709,7 @@ ex diracgammaR::conjugate() const ex dirac_ONE(unsigned char rl) { - static ex ONE = (new diracone)->setflag(status_flags::dynallocated); + static ex ONE = dynallocate(); return clifford(ONE, rl); } @@ -726,8 +726,7 @@ static unsigned get_dim_uint(const ex& e) ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl) { - //static ex unit = (new cliffordunit)->setflag(status_flags::dynallocated); - ex unit = (new cliffordunit)->setflag(status_flags::dynallocated); + ex unit = dynallocate(); if (!is_a(mu)) throw(std::invalid_argument("clifford_unit(): index of Clifford unit must be of type idx or varidx")); @@ -741,10 +740,10 @@ ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl) unsigned n = M.rows(); bool symmetric = true; - //static idx xi((new symbol)->setflag(status_flags::dynallocated), n), - // chi((new symbol)->setflag(status_flags::dynallocated), n); - idx xi((new symbol)->setflag(status_flags::dynallocated), n), - chi((new symbol)->setflag(status_flags::dynallocated), n); + //static idx xi(dynallocate(), n), + // chi(dynallocate(), n); + idx xi(dynallocate(), n), + chi(dynallocate(), n); if ((n == M.cols()) && (n == get_dim_uint(mu))) { for (unsigned i = 0; i < n; i++) { for (unsigned j = i+1; j < n; j++) { @@ -758,10 +757,10 @@ 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()); - 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(dynallocate(), ex_to(mu).get_dim()), + // chi(dynallocate(), ex_to(mu).get_dim()); + varidx xi(dynallocate(), ex_to(mu).get_dim()), + chi(dynallocate(), 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")); @@ -769,31 +768,31 @@ ex clifford_unit(const ex & mu, const ex & metr, unsigned char rl) ex dirac_gamma(const ex & mu, unsigned char rl) { - static ex gamma = (new diracgamma)->setflag(status_flags::dynallocated); + static ex gamma = dynallocate(); if (!is_a(mu)) throw(std::invalid_argument("dirac_gamma(): index of Dirac gamma must be of type varidx")); - 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); + static varidx xi(dynallocate(), ex_to(mu).get_dim()), + chi(dynallocate(), ex_to(mu).get_dim()); + return clifford(gamma, mu, indexed(dynallocate(), symmetric2(), xi, chi), rl); } ex dirac_gamma5(unsigned char rl) { - static ex gamma5 = (new diracgamma5)->setflag(status_flags::dynallocated); + static ex gamma5 = dynallocate(); return clifford(gamma5, rl); } ex dirac_gammaL(unsigned char rl) { - static ex gammaL = (new diracgammaL)->setflag(status_flags::dynallocated); + static ex gammaL = dynallocate(); return clifford(gammaL, rl); } ex dirac_gammaR(unsigned char rl) { - static ex gammaR = (new diracgammaR)->setflag(status_flags::dynallocated); + static ex gammaR = dynallocate(); return clifford(gammaR, rl); } @@ -803,9 +802,9 @@ ex dirac_slash(const ex & e, const ex & dim, unsigned char rl) // vector as its base expression and a (dummy) index that just serves // for storing the space dimensionality - 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); + static varidx xi(dynallocate(), dim), + chi(dynallocate(), dim); + return clifford(e, varidx(0, dim), indexed(dynallocate(), symmetric2(), xi, chi), rl); } /** Extract representation label from tinfo key (as returned by @@ -892,10 +891,10 @@ ex dirac_trace(const ex & e, const std::set & rls, const ex & trO return e; // Substitute gammaL/R and expand product, if necessary - ex e_expanded = e.subs(lst( + ex e_expanded = e.subs(lst{ dirac_gammaL(rl) == (dirac_ONE(rl)-dirac_gamma5(rl))/2, dirac_gammaR(rl) == (dirac_ONE(rl)+dirac_gamma5(rl))/2 - ), subs_options::no_pattern).expand(); + }, subs_options::no_pattern).expand(); if (!is_a(e_expanded)) return dirac_trace(e_expanded, rls, trONE); @@ -1063,7 +1062,7 @@ ex canonicalize_clifford(const ex & e_) ex sum = ncmul(v); it[0] = save1; it[1] = save0; - sum += ex_to(save0).get_commutator_sign() * ncmul(v, true); + sum += ex_to(save0).get_commutator_sign() * ncmul(std::move(v)); i->second = canonicalize_clifford(sum); goto next_sym; } @@ -1255,8 +1254,8 @@ static ex get_clifford_comp(const ex & e, const ex & c) 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); + S = S * e.op(j).subs(lst{curridx == ival, curridx_toggle == ival}, + subs_options::no_pattern); } } else S = S * e.op(j); @@ -1335,11 +1334,11 @@ ex clifford_moebius_map(const ex & a, const ex & b, const ex & c, const ex & d, } else { if (is_a(G)) { D = ex_to(G.op(1)).get_dim(); - varidx mu((new symbol)->setflag(status_flags::dynallocated), D); + varidx mu(dynallocate(), D); cu = clifford_unit(mu, G, rl); } else if (is_a(G)) { D = ex_to(G).rows(); - idx mu((new symbol)->setflag(status_flags::dynallocated), D); + idx mu(dynallocate(), 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"));