* No real implementation yet, to be done. */
/*
- * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "debugmsg.h"
#include "utils.h"
-#ifndef NO_NAMESPACE_GINAC
namespace GiNaC {
-#endif // ndef NO_NAMESPACE_GINAC
GINAC_IMPLEMENT_REGISTERED_CLASS(color, indexed)
// public
-color::color() : type(invalid), representation_label(0)
+color::color() : inherited(TINFO_color), type(invalid), representation_label(0)
{
debugmsg("color default constructor",LOGLEVEL_CONSTRUCT);
- tinfo_key=TINFO_color;
-}
-
-color::~color()
-{
- debugmsg("color destructor",LOGLEVEL_DESTRUCT);
- destroy(0);
-}
-
-color::color(const color & other)
-{
- debugmsg("color copy constructor",LOGLEVEL_CONSTRUCT);
- copy (other);
-}
-
-const color & color::operator=(const color & other)
-{
- debugmsg("color operator=",LOGLEVEL_ASSIGNMENT);
- if (this != &other) {
- destroy(1);
- copy(other);
- }
- return *this;
}
// protected
// protected
+/** Construct object without any color index. This constructor is for internal
+ * use only. Use the color_ONE() function instead.
+ * @see color_ONE */
color::color(color_types const t, unsigned rl) : type(t), representation_label(rl)
{
debugmsg("color constructor from color_types,unsigned",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(all_of_type_coloridx());
}
+/** Construct object with one color index. This constructor is for internal
+ * use only. Use the color_T() function instead.
+ * @see color_T */
color::color(color_types const t, const ex & i1, unsigned rl)
- : inherited(i1), type(t), representation_label(rl)
+ : inherited(i1), type(t), representation_label(rl)
{
debugmsg("color constructor from color_types,ex,unsigned",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
GINAC_ASSERT(all_of_type_coloridx());
}
+/** Construct object with two color indices. This constructor is for internal
+ * use only. Use the color_delta8() function instead.
+ * @see color_delta8 */
color::color(color_types const t, const ex & i1, const ex & i2, unsigned rl)
- : inherited(i1,i2), type(t), representation_label(rl)
+ : inherited(i1,i2), type(t), representation_label(rl)
{
debugmsg("color constructor from color_types,ex,ex,unsigned",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
GINAC_ASSERT(all_of_type_coloridx());
}
+/** Construct object with three color indices. This constructor is for internal
+ * use only. Use the color_f(), color_d() and color_h() functions instead.
+ * @see color_f
+ * @see color_d
+ * @see color_h */
color::color(color_types const t, const ex & i1, const ex & i2, const ex & i3,
- unsigned rl) : inherited(i1,i2,i3), type(t), representation_label(rl)
+ unsigned rl) : inherited(i1,i2,i3), type(t), representation_label(rl)
{
debugmsg("color constructor from color_types,ex,ex,ex,unsigned",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
GINAC_ASSERT(all_of_type_coloridx());
}
+/** Construct object with arbitrary number of color indices. This
+ * constructor is for internal use only. */
color::color(color_types const t, const exvector & iv, unsigned rl)
- : inherited(iv), type(t), representation_label(rl)
+ : inherited(iv), type(t), representation_label(rl)
{
debugmsg("color constructor from color_types,exvector,unsigned",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
}
color::color(color_types const t, exvector * ivp, unsigned rl)
- : inherited(ivp), type(t), representation_label(rl)
+ : inherited(ivp), type(t), representation_label(rl)
{
debugmsg("color constructor from color_types,exvector *,unsigned",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
// public
-basic * color::duplicate() const
-{
- debugmsg("color duplicate",LOGLEVEL_DUPLICATE);
- return new color(*this);
-}
-
void color::printraw(std::ostream & os) const
{
debugmsg("color printraw",LOGLEVEL_PRINT);
printindices(os);
}
-void color::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const
-{
- debugmsg("color print csrc",LOGLEVEL_PRINT);
- print(os,upper_precedence);
-}
-
bool color::info(unsigned inf) const
{
return inherited::info(inf);
if (CMPINDICES(1,2,3)) {
return _ex1();
} else if (CMPINDICES(1,4,7)||CMPINDICES(2,4,6)||
- CMPINDICES(2,5,7)||CMPINDICES(3,4,5)) {
+ CMPINDICES(2,5,7)||CMPINDICES(3,4,5)) {
return _ex1_2();
} else if (CMPINDICES(1,5,6)||CMPINDICES(3,6,7)) {
return -_ex1_2();
int color::compare_same_type(const basic & other) const
{
GINAC_ASSERT(other.tinfo() == TINFO_color);
- const color *o = static_cast<const color *>(&other);
- if (type==o->type) {
- if (representation_label==o->representation_label) {
- return inherited::compare_same_type(other);
- }
- return representation_label < o->representation_label ? -1 : 1;
+ const color &o = static_cast<const color &>(other);
+
+ if (type != o.type) {
+ // different type
+ return type < o.type ? -1 : 1;
+ }
+
+ if (representation_label != o.representation_label) {
+ // different representation label
+ return representation_label < o.representation_label ? -1 : 1;
}
- return type < o->type ? -1 : 1;
+
+ return inherited::compare_same_type(other);
}
bool color::is_equal_same_type(const basic & other) const
{
GINAC_ASSERT(other.tinfo() == TINFO_color);
- const color *o = static_cast<const color *>(&other);
- if (type!=o->type) return false;
- if (representation_label!=o->representation_label) return false;
+ const color &o = static_cast<const color &>(other);
+
+ if (type != o.type) return false;
+ if (representation_label != o.representation_label) return false;
return inherited::is_equal_same_type(other);
}
*it1=numeric(40)/numeric(3);
*it2=_ex1();
} else {
- int sig1, sig2; // unimportant, since symmetric
- ex idx1=permute_free_index_to_front(col1.seq,iv_intersect,false,&sig1);
- ex idx2=permute_free_index_to_front(col2.seq,iv_intersect,false,&sig2);
+ int dummy; // sign unimportant, since symmetric
+ ex idx1=permute_free_index_to_front(col1.seq,iv_intersect,&dummy);
+ ex idx2=permute_free_index_to_front(col2.seq,iv_intersect,&dummy);
*it1=numeric(5)/numeric(3)*color(color_delta8,idx1,idx2);
*it2=_ex1();
}
*it2=_ex1();
} else {
int sig1, sig2;
- ex idx1=permute_free_index_to_front(col1.seq,iv_intersect,true,&sig1);
- ex idx2=permute_free_index_to_front(col2.seq,iv_intersect,true,&sig2);
+ ex idx1=permute_free_index_to_front(col1.seq,iv_intersect,&sig1);
+ ex idx2=permute_free_index_to_front(col2.seq,iv_intersect,&sig2);
*it1=numeric(sig1*sig2*5)/numeric(3)*color(color_delta8,idx1,idx2);
*it2=_ex1();
}
const color & dref=ex_to_color(*it2);
exvector iv_intersect=idx_intersect(dref.seq,iv);
if (iv_intersect.size()==2) {
- int sig; // unimportant, since symmetric
- ex free_idx=permute_free_index_to_front(dref.seq,iv,false,&sig);
+ int dummy; // sign unimportant, since symmetric
+ ex free_idx=permute_free_index_to_front(dref.seq,iv,&dummy);
*it1=color(color_T,free_idx,rl);
*(it1+1)=color(color_ONE,rl);
*it2=numeric(5)/numeric(6);
exvector iv_intersect=idx_intersect(fref.seq,iv);
if (iv_intersect.size()==2) {
int sig;
- ex free_idx=permute_free_index_to_front(fref.seq,iv,true,&sig);
+ ex free_idx=permute_free_index_to_front(fref.seq,iv,&sig);
*it1=color(color_T,free_idx,rl);
*(it1+1)=color(color_ONE,rl);
*it2=numeric(sig*3)/numeric(2)*I;
return color(type,vp,representation_label);
}
+/** Check whether all indices are of class coloridx or a subclass. This
+ * function is used internally to make sure that all constructed color
+ * objects really carry color indices and not some other classes. */
bool color::all_of_type_coloridx(void) const
{
- // used only inside of ASSERTs
for (exvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
if (!is_ex_of_type(*cit,coloridx)) return false;
}
return true;
}
-//////////
-// virtual functions which can be overridden by derived classes
-//////////
-
-// none
-
-//////////
-// non-virtual functions in this class
-//////////
-
-//////////
-// static member variables
-//////////
-
-// none
-
-//////////
-// global constants
-//////////
-
-const color some_color;
-const type_info & typeid_color=typeid(some_color);
-
//////////
// friend functions
//////////
+/** Construct an object representing the unity element of su(3).
+ *
+ * @param rl Representation label
+ * @return newly constructed object */
color color_ONE(unsigned rl)
{
return color(color::color_ONE,rl);
}
+/** Construct an object representing the generators T_a of SU(3). The index
+ * must be of class coloridx.
+ *
+ * @param a Index
+ * @param rl Representation label
+ * @return newly constructed object */
color color_T(const ex & a, unsigned rl)
{
return color(color::color_T,a,rl);
}
+/** Construct an object representing the antisymmetric structure constants
+ * f_abc of SU(3). The indices must be of class coloridx.
+ *
+ * @param a First index
+ * @param b Second index
+ * @param c Third index
+ * @return newly constructed object */
color color_f(const ex & a, const ex & b, const ex & c)
{
return color(color::color_f,a,b,c);
}
+/** Construct an object representing the symmetric structure constants d_abc
+ * of SU(3). The indices must be of class coloridx.
+ *
+ * @param a First index
+ * @param b Second index
+ * @param c Third index
+ * @return newly constructed object */
color color_d(const ex & a, const ex & b, const ex & c)
{
return color(color::color_d,a,b,c);
}
+/** This returns the linear combination d_abc+I*f_abc.
+ *
+ * @param a First index
+ * @param b Second index
+ * @param c Third index
+ * @return newly constructed object */
ex color_h(const ex & a, const ex & b, const ex & c)
{
return color(color::color_d,a,b,c)+I*color(color::color_f,a,b,c);
}
+/** Construct an object representing the unity matrix delta8_ab in su(3).
+ * The indices must be of class coloridx.
+ *
+ * @param a First index
+ * @param b Second index
+ * @return newly constructed object */
color color_delta8(const ex & a, const ex & b)
{
return color(color::color_delta8,a,b);
}
+/** Given a vector of color (and possible other) objects, split it up
+ * according to the object type (structure constant, generator etc.) and
+ * representation label while preserving the order within each group. If
+ * there are non-color objetcs in the vector, the SU(3) generators T_a get
+ * sorted into the "unknown" group together with the non-color objects
+ * because we don't know whether these objects commute with the generators.
+ *
+ * @param v Source vector of expressions
+ * @param delta8vec Vector of unity matrices (returned)
+ * @param fvec Vector of antisymmetric structure constants (returned)
+ * @param dvec Vector of symmetric structure constants (returned)
+ * @param Tvecs Vectors of generators, one for each representation label (returned)
+ * @param ONEvecs Vectors of unity elements, one for each representation label (returned)
+ * @param unknownvec Vector of all non-color objects (returned)
+ *
+ * @see color::color_types
+ * @see recombine_color_string */
void split_color_string_in_parts(const exvector & v, exvector & delta8vec,
- exvector & fvec, exvector & dvec,
- exvectorvector & Tvecs,
- exvectorvector & ONEvecs,
- exvector & unknownvec)
+ exvector & fvec, exvector & dvec,
+ exvectorvector & Tvecs,
+ exvectorvector & ONEvecs,
+ exvector & unknownvec)
{
// if not all elements are of type color, put all Ts in unknownvec to
// retain the ordering
}
}
+/** Merge vectors of color objects sorted by object type into one vector,
+ * retaining the order within each group. This is the inverse operation of
+ * split_color_string_in_parts().
+ *
+ * @param delta8vec Vector of unity matrices
+ * @param fvec Vector of antisymmetric structure constants
+ * @param dvec Vector of symmetric structure constants
+ * @param Tvecs Vectors of generators, one for each representation label
+ * @param ONEvecs Vectors of unity elements, one for each representation label
+ * @param unknownvec Vector of all non-color objects
+ * @return merged vector
+ *
+ * @see color::color_types
+ * @see split_color_string_in_parts */
exvector recombine_color_string(exvector & delta8vec, exvector & fvec,
- exvector & dvec, exvectorvector & Tvecs,
- exvectorvector & ONEvecs, exvector & unknownvec)
+ exvector & dvec, exvectorvector & Tvecs,
+ exvectorvector & ONEvecs, exvector & unknownvec)
{
unsigned sz=delta8vec.size()+fvec.size()+dvec.size()+unknownvec.size();
for (unsigned rl=0; rl<MAX_REPRESENTATION_LABELS; ++rl) {
// FIXME: check this formula for SU(N) with N!=3
return numeric(1)/numeric(2*COLOR_THREE)*color_delta8(next_to_last_index,last_index)
- % color_trace_of_one_representation_label(v1)
- +numeric(1)/numeric(2)*color_h(next_to_last_index,last_index,summation_index)
- % color_trace_of_one_representation_label(v2);
+ % color_trace_of_one_representation_label(v1)
+ +numeric(1)/numeric(2)*color_h(next_to_last_index,last_index,summation_index)
+ % color_trace_of_one_representation_label(v2);
/*
ex term1=numeric(1)/numeric(2*COLOR_THREE)*color_delta8(next_to_last_index,last_index)
% color_trace_of_one_representation_label(v1);
*/
}
+/** Calculate the trace over the (hidden) indices of the su(3) Lie algebra
+ * elements (the SU(3) generators and the unity element) of a specified
+ * representation label in a string of color objects.
+ *
+ * @param v Vector of color objects
+ * @param rl Representation label
+ * @return value of the trace */
ex color_trace(const exvector & v, unsigned rl)
{
GINAC_ASSERT(rl<MAX_REPRESENTATION_LABELS);
}
t1=_ex1();
t2=_ex1();
- ex term1=numeric(-1)/numeric(6)*nonsimplified_ncmul(recombine_color_string(
- delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec));
+ ex term1=numeric(-1)/numeric(6)*nonsimplified_ncmul(recombine_color_string(delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec));
for (unsigned k=i+1; k<j; ++k) {
S.push_back(_ex1());
}
t1=color_trace_of_one_representation_label(S);
- ex term2=numeric(1)/numeric(2)*nonsimplified_ncmul(recombine_color_string(
- delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec));
+ ex term2=numeric(1)/numeric(2)*nonsimplified_ncmul(recombine_color_string(delta8vec,fvec,dvec,Tvecs,ONEvecs,unknownvec));
return simplify_color(term1+term2);
}
}
return e;
}
+/** Perform some simplifications on an expression containing color objects. */
ex simplify_color(const ex & e)
{
// all simplification is done on expanded objects
return sum;
}
-void append_exvector_to_exvector(exvector & dest, const exvector & source)
-{
- for (exvector::const_iterator cit=source.begin(); cit!=source.end(); ++cit) {
- dest.push_back(*cit);
- }
-}
-
-#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC
-#endif // ndef NO_NAMESPACE_GINAC
-