]> www.ginac.de Git - ginac.git/blob - ginac/color.h
3237359ed72257df50dd421971e2296964eb75d7
[ginac.git] / ginac / color.h
1 /** @file color.h
2  *
3  *  Interface to GiNaC's color objects. */
4
5 #ifndef _COLOR_H_
6 #define _COLOR_H_
7
8 #include <string>
9 #include <vector>
10
11 class color;
12
13 #include "indexed.h"
14
15 #define MAX_REPRESENTATION_LABELS 4
16 #define COLOR_EIGHT 8 // N*N-1
17 #define COLOR_THREE 3 // N
18
19 /** Base class for color object */
20 class color : public indexed
21 {
22 // friends
23
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);
43
44     
45 // types
46
47 public:
48     typedef enum { invalid, // not properly constructed by one of the friend functions
49                    color_T,
50                    color_f,
51                    color_d,
52                    color_delta8,
53                    color_ONE
54     } color_types;
55     
56 // member functions
57
58     // default constructor, destructor, copy constructor assignment operator and helpers
59 public:
60     color();
61     ~color();
62     color(color const & other);
63     color const & operator=(color const & other);
64 protected:
65     void copy(color const & other); 
66     void destroy(bool call_parent);
67
68     // other constructors
69 protected:
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,
74           unsigned const rl=0);
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);
77     
78     // functions overriding virtual functions from base classes
79 public:
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;
87 protected:
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;
93
94     // new virtual functions which can be overridden by derived classes
95     // none
96     
97     // non-virtual functions in this class
98 protected:
99     bool all_of_type_coloridx(void) const;
100     
101 // member variables
102
103 protected:
104     color_types type;
105     unsigned representation_label; // to distiguish independent color matrices coming from separated fermion lines
106 };
107
108 // global constants
109
110 extern const color some_color;
111 extern type_info const & typeid_color;
112
113 // macros
114
115 #define ex_to_color(X) static_cast<color const &>(*(X).bp)
116 #define ex_to_nonconst_color(X) static_cast<color &>(*(X).bp)
117
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);
136
137 ex brute_force_sum_color_indices(ex const & e);
138
139 void append_exvector_to_exvector(exvector & dest, exvector const & source);
140
141 #endif // ndef _COLOR_H_
142
143