76color::
color(const
ex & b,
unsigned char rl) : inherited(b), representation_label(rl)
83color::color(
const ex & b,
const ex & i1,
unsigned char rl) : inherited(b, i1), representation_label(rl)
106 inherited::read_archive(
n, sym_lst);
108 n.find_unsigned(
"label", rl);
114 inherited::archive(
n);
131 const color &o =
static_cast<const color &
>(other);
138 return inherited::compare_same_type(other);
144 const color &o =
static_cast<const color &
>(other);
167 for (
auto & it : v) {
168 if (!is_a<su3one>(it.op(0)))
203#define TEST_PERMUTATION(A,B,C,P) \
204 if (iv3[B].is_equal(iv2[0]) && iv3[C].is_equal(iv2[1])) { \
216 throw(std::logic_error(
"permute_free_index_to_front(): no valid permutation found"));
227 if (!(
static_cast<const indexed &
>(i).get_dummy_indices().empty()))
235 for (
unsigned j=0; j<3; j++)
236 v[j] = ex_to<numeric>(ex_to<idx>(i.
op(j + 1)).get_value()).to_int();
241#define CMPINDICES(A,B,C) ((v[0] == (A)) && (v[1] == (B)) && (v[2] == (C)))
276 for (
unsigned j=0; j<3; j++)
277 v[j] = ex_to<numeric>(ex_to<idx>(i.
op(j + 1)).get_value()).to_int();
279 if (v[0] > v[1]) {
std::swap(v[0], v[1]); sign = -sign; }
280 if (v[0] > v[2]) {
std::swap(v[0], v[2]); sign = -sign; }
281 if (v[1] > v[2]) {
std::swap(v[1], v[2]); sign = -sign; }
309 unsigned char rl = ex_to<color>(*self).get_representation_label();
311 if (is_exactly_a<su3t>(other->op(0))) {
315 if (ex_to<color>(*other).get_representation_label() != rl)
319 if (other - self == 1) {
325 }
else if (other - self == 2
326 && is_a<color>(self[1])) {
334 while (it != other) {
335 if (!is_a<color>(*it)) {
343 while (it != other) {
365 if (is_exactly_a<su3d>(other->op(0))) {
368 exvector self_indices = ex_to<indexed>(*self).get_indices();
369 exvector other_indices = ex_to<indexed>(*other).get_indices();
370 exvector all_indices = self_indices;
371 all_indices.insert(all_indices.end(), other_indices.begin(), other_indices.end());
372 exvector free_indices, dummy_indices;
376 if (dummy_indices.size() == 3) {
382 }
else if (dummy_indices.size() == 2) {
384 std::back_insert_iterator<exvector> ita(a);
385 ita = set_difference(self_indices.begin(), self_indices.end(), dummy_indices.begin(), dummy_indices.end(), ita,
ex_is_less());
386 ita = set_difference(other_indices.begin(), other_indices.end(), dummy_indices.begin(), dummy_indices.end(), ita,
ex_is_less());
393 }
else if (is_exactly_a<su3t>(other->op(0))) {
396 if (other+1 != v.end()
397 && is_exactly_a<su3t>(other[1].op(0))
398 && ex_to<indexed>(*self).has_dummy_index_for(other[1].op(1))) {
400 exvector self_indices = ex_to<indexed>(*self).get_indices();
401 exvector dummy_indices = {other[0].
op(1), other[1].
op(1)};
422 if (is_exactly_a<su3f>(other->op(0))) {
426 dummy_indices = ex_to<indexed>(*self).get_dummy_indices(ex_to<indexed>(*other));
429 if (dummy_indices.size() == 3) {
435 }
else if (dummy_indices.size() == 2) {
444 }
else if (is_exactly_a<su3t>(other->op(0))) {
447 if (other+1 != v.end()
448 && is_exactly_a<su3t>(other[1].op(0))
449 && ex_to<indexed>(*self).has_dummy_index_for(other[1].op(1))) {
451 exvector self_indices = ex_to<indexed>(*self).get_indices();
452 exvector dummy_indices = {other[0].
op(1), other[1].
op(1)};
471 static ex ONE = dynallocate<su3one>();
472 return color(ONE, rl);
477 static ex t = dynallocate<su3t>();
480 throw(std::invalid_argument(
"indices of color_T must be of type idx"));
481 if (!ex_to<idx>(a).get_dim().is_equal(8))
482 throw(std::invalid_argument(
"index dimension for color_T must be 8"));
484 return color(t, a, rl);
489 static ex f = dynallocate<su3f>();
491 if (!is_a<idx>(a) || !is_a<idx>(b) || !is_a<idx>(
c))
492 throw(std::invalid_argument(
"indices of color_f must be of type idx"));
493 if (!ex_to<idx>(a).get_dim().is_equal(8) || !ex_to<idx>(b).get_dim().is_equal(8) || !ex_to<idx>(
c).get_dim().is_equal(8))
494 throw(std::invalid_argument(
"index dimension for color_f must be 8"));
501 static ex d = dynallocate<su3d>();
503 if (!is_a<idx>(a) || !is_a<idx>(b) || !is_a<idx>(
c))
504 throw(std::invalid_argument(
"indices of color_d must be of type idx"));
505 if (!ex_to<idx>(a).get_dim().is_equal(8) || !ex_to<idx>(b).get_dim().is_equal(8) || !ex_to<idx>(
c).get_dim().is_equal(8))
506 throw(std::invalid_argument(
"index dimension for color_d must be 8"));
527 return (
unsigned char)ti.
rl;
532 if (is_a<color>(e)) {
534 unsigned char rl = ex_to<color>(e).get_representation_label();
537 if (rls.find(rl) == rls.end())
541 if (is_a<su3one>(e.
op(0)))
546 }
else if (is_exactly_a<mul>(e)) {
550 for (
size_t i=0; i<e.
nops(); i++) {
551 const ex &o = e.
op(i);
559 }
else if (is_exactly_a<ncmul>(e)) {
564 if (rls.find(rl) == rls.end())
569 if (!is_a<ncmul>(e_expanded))
572 size_t num = e.
nops();
579 }
else if (num == 3) {
590 const ex &last_index = e.
op(num - 1).
op(1);
591 const ex &next_to_last_index = e.
op(num - 2).
op(1);
592 idx summation_index(dynallocate<symbol>(), 8);
596 for (
size_t i=0; i<num-2; i++)
597 v1.push_back(e.
op(i));
600 v2.push_back(
color_T(summation_index, rl));
606 }
else if (e.
nops() > 0) {
619 std::set<unsigned char> rls;
620 for (
auto & it : rll) {
622 rls.insert(ex_to<numeric>(it).to_int());
631 std::set<unsigned char> rls;
Archiving of GiNaC expressions.
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
virtual size_t nops() const
Number of operands/members.
virtual ex op(size_t i) const
Return operand/member at position i.
const basic & hold() const
Stop further evaluation.
virtual int compare_same_type(const basic &other) const
Returns order relation between two objects of same type.
This class holds a generator T_a or the unity element of the Lie algebra of SU(3),...
return_type_t return_type_tinfo() const override
unsigned char representation_label
Representation label to distinguish independent color matrices coming from separated fermion lines.
void read_archive(const archive_node &n, lst &sym_lst) override
Load (deserialize) the object from an archive node.
void archive(archive_node &n) const override
Save (serialize) the object into archive node.
bool match_same_type(const basic &other) const override
Returns true if the attributes of two objects are similar enough for a match.
color(const ex &b, unsigned char rl=0)
Construct object without any color index.
ex thiscontainer(const exvector &v) const override
Wrapper template for making GiNaC classes out of STL containers.
Lightweight wrapper for GiNaC's symbolic objects.
ex map(map_function &f) const
ex expand(unsigned options=0) const
Expand an expression.
return_type_t return_type_tinfo() const
This class holds one index of an indexed object.
This class holds an indexed expression.
Non-commutative product of expressions.
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
Context for default (ginsh-parsable) output.
Context for latex-parsable output.
This class represents the tensor of symmetric su(3) structure constants.
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of indexed symmetric structure constant.
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of an indexed symmetric structure constant with something else.
This class represents the tensor of antisymmetric su(3) structure constants.
ex eval_indexed(const basic &i) const override
Automatic symbolic evaluation of indexed antisymmetric structure constant.
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of an indexed antisymmetric structure constant with something else.
This class represents the su(3) unity element.
This class represents an su(3) generator.
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of generator with something else.
This class holds one of GiNaC's predefined special tensors such as the delta and the metric tensors.
#define TEST_PERMUTATION(A, B, C, P)
#define CMPINDICES(A, B, C)
Interface to GiNaC's color (SU(3) Lie algebra) objects.
Interface to GiNaC's indices.
Interface to GiNaC's products of expressions.
const numeric I
Imaginary unit.
ex hold_ncmul(const exvector &v)
const symmetry & symmetric3()
const symmetry & not_symmetric()
ex color_ONE(unsigned char rl)
Create the su(3) unity element.
const symmetry & antisymmetric3()
static ex permute_free_index_to_front(const exvector &iv3, const exvector &iv2, int &sig)
Given a vector iv3 of three indices and a vector iv2 of two indices that is a subset of iv3,...
const numeric sqrt(const numeric &x)
Numeric square root.
ex color_T(const ex &a, unsigned char rl)
Create an su(3) generator.
ex color_trace(const ex &e, const std::set< unsigned char > &rls)
Calculate color traces over the specified set of representation labels.
ex color_f(const ex &a, const ex &b, const ex &c)
Create an su(3) antisymmetric structure constant.
static bool is_color_tinfo(const return_type_t &ti)
Check whether a given tinfo key (as returned by return_type_tinfo() is that of a color object (with a...
ex delta_tensor(const ex &i1, const ex &i2)
Create a delta tensor with specified indices.
static unsigned char get_representation_label(const return_type_t &ti)
Extract representation label from tinfo key (as returned by return_type_tinfo()).
ex color_h(const ex &a, const ex &b, const ex &c)
This returns the linear combination d.a.b.c+I*f.a.b.c.
ex color_d(const ex &a, const ex &b, const ex &c)
Create an su(3) symmetric structure constant.
GINAC_IMPLEMENT_REGISTERED_CLASS_OPT_T(lst, basic, print_func< print_context >(&lst::do_print). print_func< print_tree >(&lst::do_print_tree)) template<> bool lst GINAC_BIND_UNARCHIVER(lst)
Specialization of container::info() for lst.
void find_free_and_dummy(exvector::const_iterator it, exvector::const_iterator itend, exvector &out_free, exvector &out_dummy)
Given a vector of indices, split them into two vectors, one containing the free indices,...
std::vector< ex > exvector
void swap(GiNaC::ex &a, GiNaC::ex &b)
Specialization of std::swap() for ex objects.
Interface to GiNaC's non-commutative products of expressions.
Makes the interface to the underlying bignum package available.
Interface to GiNaC's overloaded operators.
Interface to GiNaC's symbolic exponentiation (basis^exponent).
#define GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(classname, supername, options)
Macro for inclusion in the implementation of each registered class.
#define GINAC_IMPLEMENT_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the implementation of each registered class.
To distinguish between different kinds of non-commutative objects.
std::type_info const * tinfo
to distinguish between non-commutative objects of different type.
unsigned rl
to distinguish between non-commutative objects of the same type.
Interface to GiNaC's symbolic objects.
Interface to GiNaC's symmetry definitions.
Interface to several small and furry utilities needed within GiNaC but not of any interest to the use...
#define DEFAULT_PRINT_LATEX(classname, text, latex)
#define DEFAULT_PRINT(classname, text)
#define DEFAULT_CTOR(classname)
#define DEFAULT_COMPARE(classname)