77color::
color(const
ex & b,
unsigned char rl) : inherited(b), representation_label(rl)
84color::color(
const ex & b,
const ex & i1,
unsigned char rl) : inherited(b, i1), representation_label(rl)
107 inherited::read_archive(
n, sym_lst);
109 n.find_unsigned(
"label", rl);
115 inherited::archive(
n);
132 const color &o =
static_cast<const color &
>(other);
139 return inherited::compare_same_type(other);
145 const color &o =
static_cast<const color &
>(other);
168 for (
auto & it : v) {
169 if (!is_a<su3one>(it.op(0)))
204#define TEST_PERMUTATION(A,B,C,P) \
205 if (iv3[B].is_equal(iv2[0]) && iv3[C].is_equal(iv2[1])) { \
217 throw(std::logic_error(
"permute_free_index_to_front(): no valid permutation found"));
228 if (!(
static_cast<const indexed &
>(i).get_dummy_indices().empty()))
236 for (
unsigned j=0; j<3; j++)
237 v[j] = ex_to<numeric>(ex_to<idx>(i.
op(j + 1)).get_value()).to_int();
242#define CMPINDICES(A,B,C) ((v[0] == (A)) && (v[1] == (B)) && (v[2] == (C)))
277 for (
unsigned j=0; j<3; j++)
278 v[j] = ex_to<numeric>(ex_to<idx>(i.
op(j + 1)).get_value()).to_int();
280 if (v[0] > v[1]) {
std::swap(v[0], v[1]); sign = -sign; }
281 if (v[0] > v[2]) {
std::swap(v[0], v[2]); sign = -sign; }
282 if (v[1] > v[2]) {
std::swap(v[1], v[2]); sign = -sign; }
310 unsigned char rl = ex_to<color>(*self).get_representation_label();
312 if (is_exactly_a<su3t>(other->op(0))) {
316 if (ex_to<color>(*other).get_representation_label() != rl)
320 if (other - self == 1) {
326 }
else if (other - self == 2
327 && is_a<color>(self[1])) {
335 while (it != other) {
336 if (!is_a<color>(*it)) {
344 while (it != other) {
366 if (is_exactly_a<su3d>(other->op(0))) {
369 exvector self_indices = ex_to<indexed>(*self).get_indices();
370 exvector other_indices = ex_to<indexed>(*other).get_indices();
371 exvector all_indices = self_indices;
372 all_indices.insert(all_indices.end(), other_indices.begin(), other_indices.end());
373 exvector free_indices, dummy_indices;
377 if (dummy_indices.size() == 3) {
383 }
else if (dummy_indices.size() == 2) {
385 std::back_insert_iterator<exvector> ita(a);
386 ita = set_difference(self_indices.begin(), self_indices.end(), dummy_indices.begin(), dummy_indices.end(), ita,
ex_is_less());
387 ita = set_difference(other_indices.begin(), other_indices.end(), dummy_indices.begin(), dummy_indices.end(), ita,
ex_is_less());
394 }
else if (is_exactly_a<su3t>(other->op(0))) {
397 if (other+1 != v.end()
398 && is_exactly_a<su3t>(other[1].op(0))
399 && ex_to<indexed>(*self).has_dummy_index_for(other[1].op(1))) {
401 exvector self_indices = ex_to<indexed>(*self).get_indices();
402 exvector dummy_indices = {other[0].
op(1), other[1].
op(1)};
423 if (is_exactly_a<su3f>(other->op(0))) {
427 dummy_indices = ex_to<indexed>(*self).get_dummy_indices(ex_to<indexed>(*other));
430 if (dummy_indices.size() == 3) {
436 }
else if (dummy_indices.size() == 2) {
445 }
else if (is_exactly_a<su3t>(other->op(0))) {
448 if (other+1 != v.end()
449 && is_exactly_a<su3t>(other[1].op(0))
450 && ex_to<indexed>(*self).has_dummy_index_for(other[1].op(1))) {
452 exvector self_indices = ex_to<indexed>(*self).get_indices();
453 exvector dummy_indices = {other[0].
op(1), other[1].
op(1)};
472 static ex ONE = dynallocate<su3one>();
473 return color(ONE, rl);
478 static ex t = dynallocate<su3t>();
481 throw(std::invalid_argument(
"indices of color_T must be of type idx"));
482 if (!ex_to<idx>(a).get_dim().is_equal(8))
483 throw(std::invalid_argument(
"index dimension for color_T must be 8"));
485 return color(t, a, rl);
490 static ex f = dynallocate<su3f>();
492 if (!is_a<idx>(a) || !is_a<idx>(b) || !is_a<idx>(
c))
493 throw(std::invalid_argument(
"indices of color_f must be of type idx"));
494 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))
495 throw(std::invalid_argument(
"index dimension for color_f must be 8"));
502 static ex d = dynallocate<su3d>();
504 if (!is_a<idx>(a) || !is_a<idx>(b) || !is_a<idx>(
c))
505 throw(std::invalid_argument(
"indices of color_d must be of type idx"));
506 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))
507 throw(std::invalid_argument(
"index dimension for color_d must be 8"));
528 return (
unsigned char)ti.
rl;
533 if (is_a<color>(e)) {
535 unsigned char rl = ex_to<color>(e).get_representation_label();
538 if (rls.find(rl) == rls.end())
542 if (is_a<su3one>(e.
op(0)))
547 }
else if (is_exactly_a<mul>(e)) {
551 for (
size_t i=0; i<e.
nops(); i++) {
552 const ex &o = e.
op(i);
560 }
else if (is_exactly_a<ncmul>(e)) {
565 if (rls.find(rl) == rls.end())
570 if (!is_a<ncmul>(e_expanded))
573 size_t num = e.
nops();
580 }
else if (num == 3) {
591 const ex &last_index = e.
op(num - 1).
op(1);
592 const ex &next_to_last_index = e.
op(num - 2).
op(1);
593 idx summation_index(dynallocate<symbol>(), 8);
597 for (
size_t i=0; i<num-2; i++)
598 v1.push_back(e.
op(i));
601 v2.push_back(
color_T(summation_index, rl));
607 }
else if (e.
nops() > 0) {
620 std::set<unsigned char> rls;
621 for (
auto & it : rll) {
623 rls.insert(ex_to<numeric>(it).to_int());
632 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)