79clifford::
clifford() : representation_label(0), metric(0), commutator_sign(-1)
129 inherited::read_archive(n, sym_lst);
140 inherited::archive(n);
190 return (indices.size() == 2)
205 return inherited::op(i);
217 return inherited::let_op(i);
222 ex subsed = inherited::subs(m, options);
225 ex newmetric = prevmetric.
subs(m, options);
245 return inherited::compare_same_type(other);
292 c.
s <<
"\\hspace{-1.0ex}/}";
301 c.
s << std::string(level,
' ') << class_name() <<
" @" <<
this
302 << std::hex <<
", hash=0x" <<
hashvalue <<
", flags=0x" <<
flags << std::dec
303 <<
", " <<
seq.size()-1 <<
" indices"
304 <<
", symmetry=" <<
symtree << std::endl;
360 if (other->nops() > 1)
369 size_t num = other - self;
391 *self = 4 *
lorentz_g(i1, i2) * b1 * b2 *
dirac_ONE(rl) + (dim - 4) * self[1] * self[2];
402 *self = -2 * self[3] * self[2] * self[1] - (dim - 4) * self[1] * self[2] * self[3];
411 }
else if (!((other - self) & 1) && dim.
is_equal(4)) {
415 *self =
ncmul(
exvector(std::reverse_iterator<exvector::const_iterator>(other), std::reverse_iterator<exvector::const_iterator>(self + 1)));
416 std::fill(self + 1, other,
_ex1);
423 }
else if (((other - self) & 1) && dim.
is_equal(4)) {
427 auto next_to_last = other - 1;
429 ex SR =
ncmul(
exvector(std::reverse_iterator<exvector::const_iterator>(next_to_last), std::reverse_iterator<exvector::const_iterator>(self + 1)));
431 *self = (*next_to_last) * S + SR * (*next_to_last);
432 std::fill(self + 1, other,
_ex1);
443 auto next_to_last = other - 1;
446 *self = 2 * (*next_to_last) * S - (*self) * S * (*other) * (*next_to_last);
447 std::fill(self + 1, other + 1,
_ex1);
451 }
else if (
is_a<symbol>(other->op(0)) && other->nops() == 2) {
478 auto before_other = other - 1;
480 ex mu_toggle = other->
op(1);
481 ex alpha = before_other->
op(1);
484 if (other - self == 1) {
489 }
else if (other - self == 2) {
492 *self = 2 * (*self) * unit.
get_metric(alpha, mu_toggle,
true) - unit.
get_metric(mu, mu_toggle,
true) * (*before_other);
493 *before_other =
_ex1;
514 *self = 2 * (*self) * S * unit.
get_metric(alpha, mu_toggle,
true) - (*self) * S * (*other) * (*before_other);
517 *self = (*self) * S * (*other) * (*before_other);
520 std::fill(self + 1, other + 1,
_ex1);
536 for (
auto & it : v) {
541 bool something_changed =
false;
546 auto first = s.begin(), next_to_last = s.end() - 2;
548 auto it = next_to_last;
552 ex e1 = it->
op(0), e2 = it2->
op(0);
560 something_changed =
true;
568 something_changed =
true;
585 something_changed =
true;
602 something_changed =
true;
610 if (next_to_last ==
first)
618 exvector::iterator it, itend = s.end() - 1;
619 for (it = s.begin(); it != itend; ++it) {
625 const ex & ag = a.
op(0);
626 const ex & bg = b.
op(0);
634 const ex & ia = a.
op(1);
635 const ex & ib = b.
op(1);
639 something_changed =
true;
647 something_changed =
true;
654 something_changed =
true;
666 something_changed =
true;
672 something_changed =
true;
674 }
else if (!a_is_cliffordunit && !b_is_cliffordunit && ag.
is_equal(bg)) {
681 something_changed =
true;
688 if (something_changed)
706 return _ex_1 * (*this);
732 throw std::invalid_argument(
"get_dim_uint: argument is not an index");
735 throw std::invalid_argument(
"get_dim_uint: dimension of index should be a positive integer");
745 throw(std::invalid_argument(
"clifford_unit(): index of Clifford unit must be of type idx or varidx"));
749 if (indices.size() == 2) {
750 return clifford(unit, mu, metr, rl);
753 unsigned n = M.
rows();
754 bool symmetric =
true;
761 for (
unsigned i = 0; i < n; i++) {
762 for (
unsigned j = i+1; j < n; j++) {
763 if (!M(i, j).is_equal(M(j, i))) {
770 throw(std::invalid_argument(
"clifford_unit(): metric for Clifford unit must be a square matrix with the same dimensions as index"));
772 }
else if (indices.size() == 0) {
779 throw(std::invalid_argument(
"clifford_unit(): metric for Clifford unit must be of type tensor, matrix or an expression with two free indices"));
787 throw(std::invalid_argument(
"dirac_gamma(): index of Dirac gamma must be of type varidx"));
827 return (
unsigned char)ti.
rl;
854 for (
size_t i=1; i<num; i++) {
855 for (
size_t n=1, j=0; n<num; n++) {
873 if (rls.find(rl) == rls.end())
877 const ex & g = e.
op(0);
889 for (
size_t i=0; i<e.
nops(); i++) {
890 const ex &o = e.
op(i);
903 if (rls.find(rl) == rls.end())
916 size_t num = e.
nops();
922 if ((num & 1) == 0 || num == 3)
928 ex b1, i1, b2, i2, b3, i3, b4, i4;
940 for (
size_t i=1; i<num; i++)
943 int *iv =
new int[num];
945 for (
size_t i=0; i<num-3; i++) {
947 for (
size_t j=i+1; j<num-2; j++) {
949 for (
size_t k=j+1; k<num-1; k++) {
951 for (
size_t l=k+1; l<num; l++) {
953 iv[0] = i; iv[1] = j; iv[2] = k; iv[3] = l;
956 for (
size_t n=0, t=4; n<num; n++) {
957 if (n == i || n == j || n == k || n == l)
970 return trONE *
I * result *
mul(bv);
987 for (
size_t i=0; i<num; i++)
993 }
else if (e.
nops() > 0) {
1006 std::set<unsigned char> rls;
1007 for (
const auto & i : rll) {
1018 std::set<unsigned char> rls;
1037 for (
auto & i : srl) {
1047 ex rhs_expanded =
rhs.expand();
1056 v.reserve(
rhs.nops());
1057 for (
size_t j=0; j<
rhs.nops(); j++)
1058 v.push_back(
rhs.op(j));
1061 auto it = v.begin(), next_to_last = v.end() - 1;
1065 while (it != next_to_last) {
1066 if (it[0].compare(it[1]) > 0) {
1068 ex save0 = it[0], save1 = it[1];
1096 ex e1= (options & 1 ? e : e.
expand());
1100 ev.reserve(e1.
nops());
1101 cv.reserve(e1.
nops());
1103 for (
size_t i= 0; i < e1.
nops(); ++i) {
1105 cv.push_back(e1.
op(i));
1107 ev.push_back(e1.
op(i));
1109 for (
auto i=cv.rbegin(); i!=cv.rend(); ++i) {
1110 ev.push_back(i->conjugate());
1113 if (do_bar && (cv.size() % 2 == 1))
1149 bool need_reevaluation =
false;
1151 if (! (options & 1) ) {
1161 throw(std::invalid_argument(
"remove_dirac_ONE(): expression is a non-scalar Clifford number!"));
1169 }
catch (std::exception &p) {
1170 need_reevaluation =
true;
1178 }
catch (std::exception &p) {
1179 need_reevaluation =
true;
1182 if (need_reevaluation)
1196 for (
size_t i=0; i < e.
nops(); i++)
1213 throw(std::invalid_argument(
"clifford_inverse(): cannot find inverse of Clifford number with zero norm!"));
1219 throw(std::invalid_argument(
"lst_to_clifford(): Index should have a numeric dimension"));
1243 return indexed(v, mu_toggle) * e;
1244 else if (max - dim == 1) {
1250 throw(std::invalid_argument(
"lst_to_clifford(): dimensions of vector and clifford unit mismatch"));
1252 throw(std::invalid_argument(
"lst_to_clifford(): first argument should be a vector (nx1 or 1xn matrix)"));
1259 throw(std::invalid_argument(
"lst_to_clifford(): list length and dimension of clifford unit mismatch"));
1261 throw(std::invalid_argument(
"lst_to_clifford(): cannot construct from anything but list or vector"));
1263 throw(std::invalid_argument(
"lst_to_clifford(): the second argument should be a Clifford unit"));
1282 bool found=
false, same_value_found=
false;
1284 ev.reserve(e1.
nops());
1285 for (
size_t i=0; i < e1.
nops(); ++i) {
1291 throw(std::invalid_argument(
"get_clifford_comp(): expression is a Clifford multi-vector"));
1295 same_value_found =
true;
1296 }
else if ((std::find(all_dummy.begin(), all_dummy.end(), e1.
op(i).
op(1)) != all_dummy.end())
1298 && std::find(all_dummy.begin(), all_dummy.end(),
1300 dummy_ind=(e1.
op(i).
op(1));
1302 ev.push_back(e.
op(i));
1304 ev.push_back(e1.
op(i));
1308 throw(std::invalid_argument(
"get_clifford_comp(): expression is not a Clifford vector to the given units"));
1311 if (same_value_found) {
1313 }
else if (! dummy_ind.
is_zero()) {
1328 throw(std::invalid_argument(
"get_clifford_comp(): expression is not usable as a Clifford vector"));
1336 throw(std::invalid_argument(
"clifford_to_lst(): index should have a numeric dimension"));
1340 for (
unsigned int i = 0; i < D; i++)
1350 for (
unsigned int i = 0; i < D; i++)
1356 for (
unsigned int i = 0; i < D; i++)
1358 }
catch (std::exception &p) {
1367 for (
unsigned int i = 0; i < D; i++)
1380 throw(std::invalid_argument(
"clifford_moebius_map(): parameter v should be either vector or list"));
1393 }
else throw(std::invalid_argument(
"clifford_moebius_map(): metric should be an indexed object, matrix, or a Clifford unit"));
1407 throw(std::invalid_argument(
"clifford_moebius_map(): parameter M should be a 2x2 matrix"));
Interface to GiNaC's sums of expressions.
Archiving of GiNaC expressions.
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
bool find_unsigned(const std::string &name, unsigned &ret, unsigned index=0) const
Retrieve property of type "unsigned" from node.
void add_unsigned(const std::string &name, unsigned value)
Add property of type "unsigned int" to node.
bool find_ex(const std::string &name, ex &ret, lst &sym_lst, unsigned index=0) const
Retrieve property of type "ex" from node.
void add_ex(const std::string &name, const ex &value)
Add property of type "ex" to node.
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
void print_dispatch(const print_context &c, unsigned level) const
Like print(), but dispatch to the specified class.
unsigned hashvalue
hash value
void ensure_if_modifiable() const
Ensure the object may be modified without hurting others, throws if this is not the case.
unsigned flags
of type status_flags
virtual int compare_same_type(const basic &other) const
Returns order relation between two objects of same type.
This class holds an object representing an element of the Clifford algebra (the Dirac gamma matrices)...
unsigned char get_representation_label() const
ex metric
Metric of the space, all constructors make it an indexed object.
bool match_same_type(const basic &other) const override
Returns true if the attributes of two objects are similar enough for a match.
bool same_metric(const ex &other) const
void do_print_tree(const print_tree &c, unsigned level) const
ex eval_ncmul(const exvector &v) const override
Perform automatic simplification on noncommutative product of clifford objects.
void do_print_dflt(const print_dflt &c, unsigned level) const
size_t nops() const override
Number of operands/members.
ex & let_op(size_t i) override
Return modifiable operand/member at position i.
unsigned precedence() const override
Return relative operator precedence (for parenthezing output).
ex thiscontainer(const exvector &v) const override
Similar to duplicate(), but with a preset sequence.
void do_print_latex(const print_latex &c, unsigned level) const
ex subs(const exmap &m, unsigned options=0) const override
Substitute a set of objects by arbitrary expressions.
ex op(size_t i) const override
Return operand/member at position i.
int commutator_sign
It is the sign in the definition e~i e~j +/- e~j e~i = B(i, j) + B(j, i)
return_type_t return_type_tinfo() const override
unsigned char representation_label
Representation label to distinguish independent spin lines.
clifford(const ex &b, unsigned char rl=0)
Construct object without any indices.
void read_archive(const archive_node &n, lst &sym_lst) override
Load (deserialize) the object from an archive node.
void archive(archive_node &n) const override
Save (serialize) the object into archive node.
int get_commutator_sign() const
This class represents the Clifford algebra generators (units).
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of a Clifford unit with something else.
container & remove_all()
Remove all elements.
container & append(const ex &b)
Add element at back.
This class represents the Dirac gamma5 object which anticommutates with all other gammas.
ex conjugate() const override
This class represents the Dirac gammaL object which behaves like 1/2 (1-gamma5).
ex conjugate() const override
This class represents the Dirac gammaL object which behaves like 1/2 (1+gamma5).
ex conjugate() const override
This class represents the Dirac gamma Lorentz vector.
bool contract_with(exvector::iterator self, exvector::iterator other, exvector &v) const override
Contraction of a gamma matrix with something else.
This class represents the Clifford algebra unity element.
Lightweight wrapper for GiNaC's symbolic objects.
ex to_rational(exmap &repl) const
Rationalization of non-rational functions.
ex map(map_function &f) const
exvector get_free_indices() const
ex expand(unsigned options=0) const
Expand an expression.
bool is_equal(const ex &other) const
ex simplify_indexed(unsigned options=0) const
Simplify/canonicalize expression containing indexed objects.
return_type_t return_type_tinfo() const
ex subs(const exmap &m, unsigned options=0) const
bool info(unsigned inf) const
This class holds one index of an indexed object.
This class holds an indexed expression.
friend ex simplify_indexed(const ex &e, exvector &free_indices, exvector &dummy_indices, const scalar_products &sp)
Simplify indexed expression, return list of free indices.
void printindices(const print_context &c, unsigned level) const
ex get_symmetry() const
Return symmetry properties.
indexed(const ex &b)
Construct indexed object with no index.
ex symtree
Index symmetry (tree of symmetry objects)
unsigned cols() const
Get number of columns.
unsigned rows() const
Get number of rows.
Non-commutative product of expressions.
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
bool is_zero() const
True if object is zero.
Base class for print_contexts.
std::ostream & s
stream to output to
Context for default (ginsh-parsable) output.
Context for latex-parsable output.
Context for tree-like output for debugging.
const unsigned delta_indent
size of indentation step
@ no_pattern
disable pattern matching
This class holds one of GiNaC's predefined special tensors such as the delta and the metric tensors.
This class holds an index with a variance (co- or contravariant).
ex toggle_variance() const
Make a new index with the same value but the opposite variance.
Interface to GiNaC's clifford algebra (Dirac gamma) objects.
Interface to GiNaC's light-weight expression handles.
Interface to GiNaC's indices.
Definition of GiNaC's lst.
Interface to symbolic matrices.
Interface to GiNaC's products of expressions.
ex dirac_slash(const ex &e, const ex &dim, unsigned char rl)
Create a term of the form e_mu * gamma~mu with a unique index mu.
static bool is_dirac_slash(const ex &seq0)
const numeric I
Imaginary unit.
ex hold_ncmul(const exvector &v)
ex remove_dirac_ONE(const ex &e, unsigned char rl, unsigned options)
Replaces dirac_ONE's (with a representation_label no less than rl) in e with 1.
static void base_and_index(const ex &c, ex &b, ex &i)
This function decomposes gamma~mu -> (1, mu) and a\ -> (a.ix, ix)
bool is_clifford_tinfo(const return_type_t &ti)
Check whether a given return_type_t object (as returned by return_type_tinfo() is that of a clifford ...
const numeric pow(const numeric &x, const numeric &y)
ex minimal_dim(const ex &dim1, const ex &dim2)
Return the minimum of two index dimensions.
ex clifford_inverse(const ex &e)
Calculation of the inverse in the Clifford algebra.
const symmetry & not_symmetric()
ex dirac_gammaL(unsigned char rl)
Create a Dirac gammaL object.
ex sub_matrix(const matrix &m, unsigned r, unsigned nr, unsigned c, unsigned nc)
Return the nr times nc submatrix starting at position r, c of matrix m.
ex clifford_unit(const ex &mu, const ex &metr, unsigned char rl)
Create a Clifford unit object.
container< std::list > lst
int clifford_max_label(const ex &e, bool ignore_ONE)
Returns the maximal representation label of a clifford object if e contains at least one,...
ex reeval_ncmul(const exvector &v)
std::map< ex, ex, ex_is_less > exmap
B & dynallocate(Args &&... args)
Constructs a new (class basic or derived) B object on the heap.
ex clifford_moebius_map(const ex &a, const ex &b, const ex &c, const ex &d, const ex &v, const ex &G, unsigned char rl)
Calculations of Moebius transformations (conformal map) defined by a 2x2 Clifford matrix (a b\c d) in...
static unsigned get_dim_uint(const ex &e)
ex dirac_ONE(unsigned char rl)
Create a Clifford unity object.
bool are_ex_trivially_equal(const ex &e1, const ex &e2)
Compare two objects of class quickly without doing a deep tree traversal.
return_type_t make_return_type_t(const unsigned rl=0)
const numeric sqrt(const numeric &x)
Numeric square root.
attribute_pure const T & ex_to(const ex &e)
Return a reference to the basic-derived class T object embedded in an expression.
ex dirac_gamma(const ex &mu, unsigned char rl)
Create a Dirac gamma object.
GINAC_IMPLEMENT_REGISTERED_CLASS_OPT_T(lst, basic, print_func< print_context >(&lst::do_print). print_func< print_tree >(&lst::do_print_tree)) template<> bool ls GINAC_BIND_UNARCHIVER)(lst)
Specialization of container::info() for lst.
print_func< print_dflt >(&diracone::do_print). print_func< print_latex >(&diracone
static ex get_clifford_comp(const ex &e, const ex &c, bool root=true)
Auxiliary structure to define a function for striping one Clifford unit from vectors.
ex simplify_indexed(const ex &thisex, unsigned options=0)
const symmetry & symmetric2()
unsigned rows(const matrix &m)
GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(add, expairseq, print_func< print_context >(&add::do_print). print_func< print_latex >(&add::do_print_latex). print_func< print_csrc >(&add::do_print_csrc). print_func< print_tree >(&add::do_print_tree). print_func< print_python_repr >(&add::do_print_python_repr)) add
ex clifford_prime(const ex &e)
Automorphism of the Clifford algebra, simply changes signs of all clifford units.
ex dirac_gamma5(unsigned char rl)
Create a Dirac gamma5 object.
bool is_a(const basic &obj)
Check if obj is a T, including base classes.
ex clifford_bar(const ex &e)
Main anti-automorphism of the Clifford algebra: makes reversion and changes signs of all clifford uni...
ex canonicalize_clifford(const ex &e_)
Bring all products of clifford objects in an expression into a canonical order.
ex lorentz_eps(const ex &i1, const ex &i2, const ex &i3, const ex &i4, bool pos_sig)
Create an epsilon tensor in a Minkowski space with four indices.
ex op(const ex &thisex, size_t i)
unsigned cols(const matrix &m)
static unsigned char get_representation_label(const return_type_t &ti)
Extract representation label from tinfo key (as returned by return_type_tinfo()).
ex lorentz_g(const ex &i1, const ex &i2, bool pos_sig)
Create a Minkowski metric tensor with specified indices.
static ex trace_string(exvector::const_iterator ix, size_t num)
Take trace of a string of an even number of Dirac gammas given a vector of indices.
ex clifford_star_bar(const ex &e, bool do_bar, unsigned options)
An auxillary function performing clifford_star() and clifford_bar().
int to_int(const numeric &x)
ex clifford_norm(const ex &e)
Calculation of the norm in the Clifford algebra.
lst clifford_to_lst(const ex &e, const ex &c, bool algebraic)
An inverse function to lst_to_clifford().
bool is_exactly_a(const basic &obj)
Check if obj is a T, not including base classes.
ex dirac_trace(const ex &e, const std::set< unsigned char > &rls, const ex &trONE)
Calculate dirac traces over the specified set of representation labels.
int permutation_sign(It first, It last)
ex lst_to_clifford(const ex &v, const ex &mu, const ex &metr, unsigned char rl)
List or vector conversion into the Clifford vector.
class_info< OPT > * class_info< OPT >::first
ex expand_dummy_sum(const ex &e, bool subs_idx)
This function returns the given expression with expanded sums for all dummy index summations,...
std::vector< ex > exvector
size_t nops(const ex &thisex)
exvector get_all_dummy_indices(const ex &e)
Returns all dummy indices from the exvector.
ex dirac_gammaR(unsigned char rl)
Create a Dirac gammaR object.
function G(const T1 &x, const T2 &y)
ex expand(const ex &thisex, unsigned options=0)
Interface to GiNaC's non-commutative products of expressions.
Makes the interface to the underlying bignum package available.
Interface to GiNaC's overloaded operators.
Interface to GiNaC's symbolic exponentiation (basis^exponent).
#define GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(classname, supername, options)
Macro for inclusion in the implementation of each registered class.
Interface to relations between expressions.
Predicate for finding non-clifford objects.
bool operator()(const ex &e)
To distinguish between different kinds of non-commutative objects.
unsigned rl
to distinguish between non-commutative objects of the same type.
Interface to GiNaC's symbolic objects.
Interface to GiNaC's symmetry definitions.
Interface to several small and furry utilities needed within GiNaC but not of any interest to the use...
#define DEFAULT_PRINT_LATEX(classname, text, latex)
#define DEFAULT_CTOR(classname)
#define DEFAULT_COMPARE(classname)