]> www.ginac.de Git - ginac.git/blob - ginac/color.h
- check program is not built until you say "make check"
[ginac.git] / ginac / color.h
1 /** @file color.h
2  *
3  *  Interface to GiNaC's color objects.
4  *
5  *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #ifndef __GINAC_COLOR_H__
23 #define __GINAC_COLOR_H__
24
25 #include <string>
26 #include <vector>
27 #include <ginac/indexed.h>
28
29 #define MAX_REPRESENTATION_LABELS 4
30 #define COLOR_EIGHT 8 // N*N-1
31 #define COLOR_THREE 3 // N
32
33 /** Base class for color object */
34 class color : public indexed
35 {
36 // friends
37
38     friend color color_ONE(unsigned const rl);
39     friend color color_T(ex const & a, unsigned const rl);
40     friend color color_f(ex const & a, ex const & b, ex const & c);
41     friend color color_d(ex const & a, ex const & b, ex const & c);
42     friend ex color_h(ex const & a, ex const & b, ex const & c);
43     friend color color_delta8(ex const & a, ex const & b);
44     friend unsigned subs_index_in_exvector(exvector & v, ex const & is, ex const & ir);
45     friend void split_color_string_in_parts(exvector const & v, exvector & delta8vec,
46                                             exvector & fvec, exvector & dvec,
47                                             vector<exvector> & Tvecs,
48                                             vector<exvector> & ONEvecs,
49                                             exvector & unknownvec);
50     friend exvector recombine_color_string(exvector & delta8vec, exvector & fvec,
51                                            exvector & dvec, vector<exvector> & Tvecs,
52                                            vector<exvector> & ONEvecs, exvector & unknownvec);
53     friend ex color_trace_of_one_representation_label(exvector const & v);
54     friend ex color_trace(exvector const & v, unsigned const rl);
55     friend ex simplify_pure_color_string(ex const & e);
56     friend ex simplify_color(ex const & e);
57
58     
59 // types
60
61 public:
62     typedef enum { invalid, // not properly constructed by one of the friend functions
63                    color_T,
64                    color_f,
65                    color_d,
66                    color_delta8,
67                    color_ONE
68     } color_types;
69     
70 // member functions
71
72     // default constructor, destructor, copy constructor assignment operator and helpers
73 public:
74     color();
75     ~color();
76     color(color const & other);
77     color const & operator=(color const & other);
78 protected:
79     void copy(color const & other); 
80     void destroy(bool call_parent);
81
82     // other constructors
83 protected:
84     color(color_types const t, unsigned const rl=0);
85     color(color_types const t, ex const & i1, unsigned const rl=0);
86     color(color_types const t, ex const & i1, ex const & i2, unsigned const rl=0);
87     color(color_types const t, ex const & i1, ex const & i2, ex const & i3,
88           unsigned const rl=0);
89     color(color_types const t, exvector const & iv, unsigned const rl=0);
90     color(color_types const t, exvector * ivp, unsigned const rl=0);
91     
92     // functions overriding virtual functions from base classes
93 public:
94     basic * duplicate() const;
95     void printraw(ostream & os) const;
96     void printtree(ostream & os, unsigned indent) const;
97     void print(ostream & os, unsigned upper_precedence=0) const;
98     void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
99     bool info(unsigned inf) const;
100     ex eval(int level=0) const;
101 protected:
102     int compare_same_type(basic const & other) const;
103     bool is_equal_same_type(basic const & other) const;
104     ex simplify_ncmul(exvector const & v) const;
105     ex thisexprseq(exvector const & v) const;
106     ex thisexprseq(exvector * vp) const;
107
108     // new virtual functions which can be overridden by derived classes
109     // none
110     
111     // non-virtual functions in this class
112 protected:
113     bool all_of_type_coloridx(void) const;
114     
115 // member variables
116
117 protected:
118     color_types type;
119     unsigned representation_label; // to distiguish independent color matrices coming from separated fermion lines
120 };
121
122 // global constants
123
124 extern const color some_color;
125 extern type_info const & typeid_color;
126
127 // macros
128
129 #define ex_to_color(X) static_cast<color const &>(*(X).bp)
130 #define ex_to_nonconst_color(X) static_cast<color &>(*(X).bp)
131
132 color color_ONE(unsigned const rl=0);
133 color color_T(ex const & a, unsigned const rl=0);
134 color color_f(ex const & a, ex const & b, ex const & c);
135 color color_d(ex const & a, ex const & b, ex const & c);
136 ex color_h(ex const & a, ex const & b, ex const & c);
137 color color_delta8(ex const & a, ex const & b);
138 void split_color_string_in_parts(exvector const & v, exvector & delta8vec,
139                                  exvector & fvec, exvector & dvec,
140                                  vector<exvector> & Tvecs,
141                                  vector<exvector> & ONEvecs,
142                                  exvector & unknownvec);
143 exvector recombine_color_string(exvector & delta8vec, exvector & fvec,
144                                 exvector & dvec, vector<exvector> & Tvecs,
145                                 vector<exvector> & ONEvecs, exvector & unknownvec);
146 ex color_trace_of_one_representation_label(exvector const & v);
147 ex color_trace(exvector const & v, unsigned const rl=0);
148 ex simplify_pure_color_string(ex const & e);
149 ex simplify_color(ex const & e);
150
151 ex brute_force_sum_color_indices(ex const & e);
152
153 void append_exvector_to_exvector(exvector & dest, exvector const & source);
154
155 #endif // ndef __GINAC_COLOR_H__
156
157