3 * Interface to GiNaC's color objects. */
15 #define MAX_REPRESENTATION_LABELS 4
16 #define COLOR_EIGHT 8 // N*N-1
17 #define COLOR_THREE 3 // N
19 /** Base class for color object */
20 class color : public indexed
24 friend color color_ONE(unsigned const rl);
25 friend color color_T(ex const & a, unsigned const rl);
26 friend color color_f(ex const & a, ex const & b, ex const & c);
27 friend color color_d(ex const & a, ex const & b, ex const & c);
28 friend ex color_h(ex const & a, ex const & b, ex const & c);
29 friend color color_delta8(ex const & a, ex const & b);
30 friend unsigned subs_index_in_exvector(exvector & v, ex const & is, ex const & ir);
31 friend void split_color_string_in_parts(exvector const & v, exvector & delta8vec,
32 exvector & fvec, exvector & dvec,
33 vector<exvector> & Tvecs,
34 vector<exvector> & ONEvecs,
35 exvector & unknownvec);
36 friend exvector recombine_color_string(exvector & delta8vec, exvector & fvec,
37 exvector & dvec, vector<exvector> & Tvecs,
38 vector<exvector> & ONEvecs, exvector & unknownvec);
39 friend ex color_trace_of_one_representation_label(exvector const & v);
40 friend ex color_trace(exvector const & v, unsigned const rl);
41 friend ex simplify_pure_color_string(ex const & e);
42 friend ex simplify_color(ex const & e);
48 typedef enum { invalid, // not properly constructed by one of the friend functions
58 // default constructor, destructor, copy constructor assignment operator and helpers
62 color(color const & other);
63 color const & operator=(color const & other);
65 void copy(color const & other);
66 void destroy(bool call_parent);
70 color(color_types const t, unsigned const rl=0);
71 color(color_types const t, ex const & i1, unsigned const rl=0);
72 color(color_types const t, ex const & i1, ex const & i2, unsigned const rl=0);
73 color(color_types const t, ex const & i1, ex const & i2, ex const & i3,
75 color(color_types const t, exvector const & iv, unsigned const rl=0);
76 color(color_types const t, exvector * ivp, unsigned const rl=0);
78 // functions overriding virtual functions from base classes
80 basic * duplicate() const;
81 void printraw(ostream & os) const;
82 void printtree(ostream & os, unsigned indent) const;
83 void print(ostream & os, unsigned upper_precedence=0) const;
84 void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
85 bool info(unsigned inf) const;
86 ex eval(int level=0) const;
88 int compare_same_type(basic const & other) const;
89 bool is_equal_same_type(basic const & other) const;
90 ex simplify_ncmul(exvector const & v) const;
91 ex thisexprseq(exvector const & v) const;
92 ex thisexprseq(exvector * vp) const;
94 // new virtual functions which can be overridden by derived classes
97 // non-virtual functions in this class
99 bool all_of_type_coloridx(void) const;
105 unsigned representation_label; // to distiguish independent color matrices coming from separated fermion lines
110 extern const color some_color;
111 extern type_info const & typeid_color;
115 #define ex_to_color(X) static_cast<color const &>(*(X).bp)
116 #define ex_to_nonconst_color(X) static_cast<color &>(*(X).bp)
118 color color_ONE(unsigned const rl=0);
119 color color_T(ex const & a, unsigned const rl=0);
120 color color_f(ex const & a, ex const & b, ex const & c);
121 color color_d(ex const & a, ex const & b, ex const & c);
122 ex color_h(ex const & a, ex const & b, ex const & c);
123 color color_delta8(ex const & a, ex const & b);
124 void split_color_string_in_parts(exvector const & v, exvector & delta8vec,
125 exvector & fvec, exvector & dvec,
126 vector<exvector> & Tvecs,
127 vector<exvector> & ONEvecs,
128 exvector & unknownvec);
129 exvector recombine_color_string(exvector & delta8vec, exvector & fvec,
130 exvector & dvec, vector<exvector> & Tvecs,
131 vector<exvector> & ONEvecs, exvector & unknownvec);
132 ex color_trace_of_one_representation_label(exvector const & v);
133 ex color_trace(exvector const & v, unsigned const rl=0);
134 ex simplify_pure_color_string(ex const & e);
135 ex simplify_color(ex const & e);
137 ex brute_force_sum_color_indices(ex const & e);
139 void append_exvector_to_exvector(exvector & dest, exvector const & source);
141 #endif // ndef _COLOR_H_