3 * Implementation of GiNaC's color (SU(3) Lie algebra) objects. */
6 * GiNaC Copyright (C) 1999-2001 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
33 GINAC_IMPLEMENT_REGISTERED_CLASS(color, indexed)
34 GINAC_IMPLEMENT_REGISTERED_CLASS(su3one, tensor)
35 GINAC_IMPLEMENT_REGISTERED_CLASS(su3t, tensor)
36 GINAC_IMPLEMENT_REGISTERED_CLASS(su3f, tensor)
37 GINAC_IMPLEMENT_REGISTERED_CLASS(su3d, tensor)
40 // default constructor, destructor, copy constructor assignment operator and helpers
43 color::color() : representation_label(0)
45 debugmsg("color default constructor", LOGLEVEL_CONSTRUCT);
46 tinfo_key = TINFO_color;
49 void color::copy(const color & other)
51 inherited::copy(other);
52 representation_label = other.representation_label;
55 DEFAULT_DESTROY(color)
65 /** Construct object without any color index. This constructor is for
66 * internal use only. Use the color_ONE() function instead.
68 color::color(const ex & b, unsigned rl = 0) : inherited(b), representation_label(rl)
70 debugmsg("color constructor from ex,unsigned", LOGLEVEL_CONSTRUCT);
71 tinfo_key = TINFO_color;
74 /** Construct object with one color index. This constructor is for internal
75 * use only. Use the color_T() function instead.
77 color::color(const ex & b, const ex & i1, unsigned rl = 0) : inherited(b, i1), representation_label(rl)
79 debugmsg("color constructor from ex,ex,unsigned", LOGLEVEL_CONSTRUCT);
80 tinfo_key = TINFO_color;
83 color::color(unsigned rl, const exvector & v, bool discardable) : inherited(indexed::unknown, v, discardable), representation_label(rl)
85 debugmsg("color constructor from unsigned,exvector", LOGLEVEL_CONSTRUCT);
86 tinfo_key = TINFO_color;
89 color::color(unsigned rl, exvector * vp) : inherited(indexed::unknown, vp), representation_label(rl)
91 debugmsg("color constructor from unsigned,exvector *", LOGLEVEL_CONSTRUCT);
92 tinfo_key = TINFO_color;
99 color::color(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
101 debugmsg("color constructor from archive_node", LOGLEVEL_CONSTRUCT);
102 n.find_unsigned("representation", representation_label);
105 void color::archive(archive_node &n) const
107 inherited::archive(n);
108 n.add_unsigned("representation", representation_label);
111 DEFAULT_UNARCHIVE(color)
112 DEFAULT_ARCHIVING(su3one)
113 DEFAULT_ARCHIVING(su3t)
114 DEFAULT_ARCHIVING(su3f)
115 DEFAULT_ARCHIVING(su3d)
118 // functions overriding virtual functions from bases classes
121 int color::compare_same_type(const basic & other) const
123 GINAC_ASSERT(other.tinfo() == TINFO_color);
124 const color &o = static_cast<const color &>(other);
126 if (representation_label != o.representation_label) {
127 // different representation label
128 return representation_label < o.representation_label ? -1 : 1;
131 return inherited::compare_same_type(other);
134 DEFAULT_COMPARE(su3one)
135 DEFAULT_COMPARE(su3t)
136 DEFAULT_COMPARE(su3f)
137 DEFAULT_COMPARE(su3d)
139 DEFAULT_PRINT(su3one, "ONE")
140 DEFAULT_PRINT(su3t, "T")
141 DEFAULT_PRINT(su3f, "f")
142 DEFAULT_PRINT(su3d, "d")
144 /** Perform automatic simplification on noncommutative product of color
145 * objects. This removes superfluous ONEs. */
146 ex color::simplify_ncmul(const exvector & v) const
148 //!! to be implemented
149 return nonsimplified_ncmul(v);
152 ex color::thisexprseq(const exvector & v) const
154 return color(representation_label, v);
157 ex color::thisexprseq(exvector * vp) const
159 return color(representation_label, vp);
166 ex color_ONE(unsigned rl)
168 return color(su3one(), rl);
171 ex color_T(const ex & a, unsigned rl)
173 return color(su3t(), a, rl);
176 ex color_f(const ex & a, const ex & b, const ex & c)
178 return indexed(su3f(), indexed::antisymmetric, a, b, c);
181 ex color_d(const ex & a, const ex & b, const ex & c)
183 return indexed(su3d(), indexed::symmetric, a, b, c);
186 ex color_h(const ex & a, const ex & b, const ex & c)
188 return color_d(a, b, c) + I * color_f(a, b, c);