3 * Interface to GiNaC's color objects. */
6 * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifndef __GINAC_COLOR_H__
24 #define __GINAC_COLOR_H__
28 #include <ginac/indexed.h>
31 #ifndef NO_GINAC_NAMESPACE
33 #endif // ndef NO_GINAC_NAMESPACE
35 const unsigned MAX_REPRESENTATION_LABELS = 4;
36 const unsigned COLOR_EIGHT = 8; // N*N-1
37 const unsigned COLOR_THREE = 3; // N
39 typedef vector<exvector,malloc_alloc> exvectorvector;
41 /** Base class for color object */
42 class color : public indexed
46 friend color color_ONE(unsigned rl);
47 friend color color_T(const ex & a, unsigned rl);
48 friend color color_f(const ex & a, const ex & b, const ex & c);
49 friend color color_d(const ex & a, const ex & b, const ex & c);
50 friend ex color_h(const ex & a, const ex & b, const ex & c);
51 friend color color_delta8(const ex & a, const ex & b);
52 friend unsigned subs_index_in_exvector(exvector & v, const ex & is, const ex & ir);
53 friend void split_color_string_in_parts(const exvector & v, exvector & delta8vec,
54 exvector & fvec, exvector & dvec,
55 exvectorvector & Tvecs,
56 exvectorvector & ONEvecs,
57 exvector & unknownvec);
58 friend exvector recombine_color_string(exvector & delta8vec, exvector & fvec,
59 exvector & dvec, exvectorvector & Tvecs,
60 exvectorvector & ONEvecs, exvector & unknownvec);
61 friend ex color_trace_of_one_representation_label(const exvector & v);
62 friend ex color_trace(const exvector & v, unsigned rl);
63 friend ex simplify_pure_color_string(const ex & e);
64 friend ex simplify_color(const ex & e);
70 typedef enum { invalid, // not properly constructed by one of the friend functions
80 // default constructor, destructor, copy constructor assignment operator and helpers
84 color(const color & other);
85 const color & operator=(const color & other);
87 void copy(const color & other);
88 void destroy(bool call_parent);
92 color(color_types const t, unsigned rl=0);
93 color(color_types const t, const ex & i1, unsigned rl=0);
94 color(color_types const t, const ex & i1, const ex & i2, unsigned rl=0);
95 color(color_types const t, const ex & i1, const ex & i2, const ex & i3,
97 color(color_types const t, const exvector & iv, unsigned rl=0);
98 color(color_types const t, exvector * ivp, unsigned rl=0);
100 // functions overriding virtual functions from base classes
102 basic * duplicate() const;
103 void printraw(ostream & os) const;
104 void printtree(ostream & os, unsigned indent) const;
105 void print(ostream & os, unsigned upper_precedence=0) const;
106 void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
107 bool info(unsigned inf) const;
108 ex eval(int level=0) const;
110 int compare_same_type(const basic & other) const;
111 bool is_equal_same_type(const basic & other) const;
112 ex simplify_ncmul(const exvector & v) const;
113 ex thisexprseq(const exvector & v) const;
114 ex thisexprseq(exvector * vp) const;
116 // new virtual functions which can be overridden by derived classes
119 // non-virtual functions in this class
121 bool all_of_type_coloridx(void) const;
127 unsigned representation_label; // to distiguish independent color matrices coming from separated fermion lines
132 extern const color some_color;
133 extern const type_info & typeid_color;
136 inline const color &ex_to_color(const ex &e)
138 return static_cast<const color &>(*e.bp);
141 inline color &ex_to_nonconst_color(const ex &e)
143 return static_cast<color &>(*e.bp);
146 color color_ONE(unsigned rl=0);
147 color color_T(const ex & a, unsigned rl=0);
148 color color_f(const ex & a, const ex & b, const ex & c);
149 color color_d(const ex & a, const ex & b, const ex & c);
150 ex color_h(const ex & a, const ex & b, const ex & c);
151 color color_delta8(const ex & a, const ex & b);
152 void split_color_string_in_parts(const exvector & v, exvector & delta8vec,
153 exvector & fvec, exvector & dvec,
154 exvectorvector & Tvecs,
155 exvectorvector & ONEvecs,
156 exvector & unknownvec);
157 exvector recombine_color_string(exvector & delta8vec, exvector & fvec,
158 exvector & dvec, exvectorvector & Tvecs,
159 exvectorvector & ONEvecs, exvector & unknownvec);
160 ex color_trace_of_one_representation_label(const exvector & v);
161 ex color_trace(const exvector & v, unsigned rl=0);
162 ex simplify_pure_color_string(const ex & e);
163 ex simplify_color(const ex & e);
165 ex brute_force_sum_color_indices(const ex & e);
167 void append_exvector_to_exvector(exvector & dest, const exvector & source);
169 #ifndef NO_GINAC_NAMESPACE
171 #endif // ndef NO_GINAC_NAMESPACE
173 #endif // ndef __GINAC_COLOR_H__