GiNaC 1.8.7
GiNaC::clifford Class Reference

This class holds an object representing an element of the Clifford algebra (the Dirac gamma matrices). More...

#include <clifford.h>

Inheritance diagram for GiNaC::clifford:
GiNaC::indexed GiNaC::container< std::vector > GiNaC::basic GiNaC::container_storage< C > GiNaC::refcounted

Public Member Functions

 clifford (const ex &b, unsigned char rl=0)
 Construct object without any indices.
 clifford (const ex &b, const ex &mu, const ex &metr, unsigned char rl=0, int comm_sign=-1)
 Construct object with one Lorentz index.
 clifford (unsigned char rl, const ex &metr, int comm_sign, const exvector &v)
 clifford (unsigned char rl, const ex &metr, int comm_sign, exvector &&v)
unsigned precedence () const override
 Return relative operator precedence (for parenthezing output).
void archive (archive_node &n) const override
 Save (serialize) the object into archive node.
void read_archive (const archive_node &n, lst &sym_lst) override
 Load (deserialize) the object from an archive node.
unsigned char get_representation_label () const
ex get_metric () const
virtual ex get_metric (const ex &i, const ex &j, bool symmetrised=false) const
bool same_metric (const ex &other) const
int get_commutator_sign () const
size_t nops () const override
 Number of operands/members.
ex op (size_t i) const override
 Return operand/member at position i.
exlet_op (size_t i) override
 Return modifiable operand/member at position i.
ex subs (const exmap &m, unsigned options=0) const override
 Substitute a set of objects by arbitrary expressions.
Public Member Functions inherited from GiNaC::indexed
 indexed (const ex &b)
 Construct indexed object with no index.
 indexed (const ex &b, const ex &i1)
 Construct indexed object with one index.
 indexed (const ex &b, const ex &i1, const ex &i2)
 Construct indexed object with two indices.
 indexed (const ex &b, const ex &i1, const ex &i2, const ex &i3)
 Construct indexed object with three indices.
 indexed (const ex &b, const ex &i1, const ex &i2, const ex &i3, const ex &i4)
 Construct indexed object with four indices.
 indexed (const ex &b, const symmetry &symm, const ex &i1, const ex &i2)
 Construct indexed object with two indices and a specified symmetry.
 indexed (const ex &b, const symmetry &symm, const ex &i1, const ex &i2, const ex &i3)
 Construct indexed object with three indices and a specified symmetry.
 indexed (const ex &b, const symmetry &symm, const ex &i1, const ex &i2, const ex &i3, const ex &i4)
 Construct indexed object with four indices and a specified symmetry.
 indexed (const ex &b, const exvector &iv)
 Construct indexed object with a specified vector of indices.
 indexed (const ex &b, const symmetry &symm, const exvector &iv)
 Construct indexed object with a specified vector of indices and symmetry.
 indexed (const symmetry &symm, const exprseq &es)
 indexed (const symmetry &symm, const exvector &v)
 indexed (const symmetry &symm, exvector &&v)
unsigned precedence () const override
 Return relative operator precedence (for parenthezing output).
bool info (unsigned inf) const override
 Information about the object.
ex eval () const override
 Perform automatic non-interruptive term rewriting rules.
ex real_part () const override
ex imag_part () const override
exvector get_free_indices () const override
 Return a vector containing the free indices of an expression.
void archive (archive_node &n) const override
 Save (a.k.a.
void read_archive (const archive_node &n, lst &syms) override
 Read (a.k.a.
bool all_index_values_are (unsigned inf) const
 Check whether all index values have a certain property.
exvector get_indices () const
 Return a vector containing the object's indices.
exvector get_dummy_indices () const
 Return a vector containing the dummy indices of the object, if any.
exvector get_dummy_indices (const indexed &other) const
 Return a vector containing the dummy indices in the contraction with another indexed object.
bool has_dummy_index_for (const ex &i) const
 Check whether the object has an index that forms a dummy index pair with a given index.
ex get_symmetry () const
 Return symmetry properties.
Public Member Functions inherited from GiNaC::container< std::vector >
 container (STLT const &s)
 container (STLT &&v)
 container (exvector::const_iterator b, exvector::const_iterator e)
 container (std::initializer_list< ex > il)
size_t nops () const override
 Number of operands/members.
ex op (size_t i) const override
 Return operand/member at position i.
exlet_op (size_t i) override
 Return modifiable operand/member at position i.
ex subs (const exmap &m, unsigned options=0) const override
 Substitute a set of objects by arbitrary expressions.
containerprepend (const ex &b)
 Add element at front.
containerappend (const ex &b)
 Add element at back.
containerremove_first ()
 Remove first element.
containerremove_last ()
 Remove last element.
containerremove_all ()
 Remove all elements.
containersort ()
 Sort elements.
containerunique ()
 Remove adjacent duplicate elements.
const_iterator begin () const
const_iterator end () const
const_reverse_iterator rbegin () const
const_reverse_iterator rend () const
Public Member Functions inherited from GiNaC::basic
virtual ~basic ()
 basic destructor, virtual because class ex will delete objects of derived classes via a basic*.
 basic (const basic &other)
const basicoperator= (const basic &other)
 basic assignment operator: the other object might be of a derived class.
virtual basicduplicate () const
 Create a clone of this object on the heap.
virtual ex evalf () const
 Evaluate object numerically.
virtual ex evalm () const
 Evaluate sums, products and integer powers of matrices.
virtual ex eval_integ () const
 Evaluate integrals, if result is known.
virtual ex eval_indexed (const basic &i) const
 Perform automatic symbolic evaluations on indexed expression that contains this object as the base expression.
virtual void print (const print_context &c, unsigned level=0) const
 Output to stream.
virtual void dbgprint () const
 Little wrapper around print to be called within a debugger.
virtual void dbgprinttree () const
 Little wrapper around printtree to be called within a debugger.
virtual ex operator[] (const ex &index) const
virtual ex operator[] (size_t i) const
virtual exoperator[] (const ex &index)
virtual exoperator[] (size_t i)
virtual bool has (const ex &other, unsigned options=0) const
 Test for occurrence of a pattern.
virtual bool match (const ex &pattern, exmap &repls) const
 Check whether the expression matches a given pattern.
virtual ex map (map_function &f) const
 Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively).
virtual void accept (GiNaC::visitor &v) const
virtual bool is_polynomial (const ex &var) const
 Check whether this is a polynomial in the given variables.
virtual int degree (const ex &s) const
 Return degree of highest power in object s.
virtual int ldegree (const ex &s) const
 Return degree of lowest power in object s.
virtual ex coeff (const ex &s, int n=1) const
 Return coefficient of degree n in object s.
virtual ex collect (const ex &s, bool distributed=false) const
 Sort expanded expression in terms of powers of some object(s).
virtual ex series (const relational &r, int order, unsigned options=0) const
 Default implementation of ex::series().
virtual ex normal (exmap &repl, exmap &rev_lookup, lst &modifier) const
 Default implementation of ex::normal().
virtual ex to_rational (exmap &repl) const
 Default implementation of ex::to_rational().
virtual ex to_polynomial (exmap &repl) const
virtual numeric integer_content () const
virtual ex smod (const numeric &xi) const
 Apply symmetric modular homomorphism to an expanded multivariate polynomial.
virtual numeric max_coefficient () const
 Implementation ex::max_coefficient().
virtual ex add_indexed (const ex &self, const ex &other) const
 Add two indexed expressions.
virtual ex scalar_mul_indexed (const ex &self, const numeric &other) const
 Multiply an indexed expression with a scalar.
virtual bool contract_with (exvector::iterator self, exvector::iterator other, exvector &v) const
 Try to contract two indexed expressions that appear in the same product.
template<class T>
void print_dispatch (const print_context &c, unsigned level) const
 Like print(), but dispatch to the specified class.
void print_dispatch (const registered_class_info &ri, const print_context &c, unsigned level) const
 Like print(), but dispatch to the specified class.
ex subs_one_level (const exmap &m, unsigned options) const
 Helper function for subs().
ex diff (const symbol &s, unsigned nth=1) const
 Default interface of nth derivative ex::diff(s, n).
int compare (const basic &other) const
 Compare objects syntactically to establish canonical ordering.
bool is_equal (const basic &other) const
 Test for syntactic equality.
const basichold () const
 Stop further evaluation.
unsigned gethash () const
const basicsetflag (unsigned f) const
 Set some status_flags.
const basicclearflag (unsigned f) const
 Clear some status_flags.
Public Member Functions inherited from GiNaC::refcounted
 refcounted () noexcept
unsigned int add_reference () noexcept
unsigned int remove_reference () noexcept
unsigned int get_refcount () const noexcept
void set_refcount (unsigned int r) noexcept

Protected Member Functions

ex eval_ncmul (const exvector &v) const override
 Perform automatic simplification on noncommutative product of clifford objects.
bool match_same_type (const basic &other) const override
 Returns true if the attributes of two objects are similar enough for a match.
ex thiscontainer (const exvector &v) const override
 Similar to duplicate(), but with a preset sequence.
ex thiscontainer (exvector &&v) const override
 Similar to duplicate(), but with a preset sequence (which gets pilfered).
unsigned return_type () const override
return_type_t return_type_tinfo () const override
void do_print_dflt (const print_dflt &c, unsigned level) const
void do_print_latex (const print_latex &c, unsigned level) const
void do_print_tree (const print_tree &c, unsigned level) const
Protected Member Functions inherited from GiNaC::indexed
ex derivative (const symbol &s) const override
 Implementation of ex::diff() for an indexed object always returns 0.
ex thiscontainer (const exvector &v) const override
 Similar to duplicate(), but with a preset sequence.
ex thiscontainer (exvector &&v) const override
 Similar to duplicate(), but with a preset sequence (which gets pilfered).
unsigned return_type () const override
return_type_t return_type_tinfo () const override
ex expand (unsigned options=0) const override
 Expand expression, i.e.
void printindices (const print_context &c, unsigned level) const
void print_indexed (const print_context &c, const char *openbrace, const char *closebrace, unsigned level) const
void do_print (const print_context &c, unsigned level) const
void do_print_latex (const print_latex &c, unsigned level) const
void do_print_tree (const print_tree &c, unsigned level) const
void validate () const
 Check whether all indices are of class idx and validate the symmetry tree.
Protected Member Functions inherited from GiNaC::container< std::vector >
ex conjugate () const override
bool is_equal_same_type (const basic &other) const override
 Returns true if two objects of same type are equal.
virtual void printseq (const print_context &c, char openbracket, char delim, char closebracket, unsigned this_precedence, unsigned upper_precedence=0) const
 Print sequence of contained elements.
void do_print (const print_context &c, unsigned level) const
void do_print_tree (const print_tree &c, unsigned level) const
void do_print_python (const print_python &c, unsigned level) const
void do_print_python_repr (const print_python_repr &c, unsigned level) const
STLT subschildren (const exmap &m, unsigned options=0) const
Protected Member Functions inherited from GiNaC::basic
 basic ()
virtual int compare_same_type (const basic &other) const
 Returns order relation between two objects of same type.
virtual unsigned calchash () const
 Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so.
void ensure_if_modifiable () const
 Ensure the object may be modified without hurting others, throws if this is not the case.
void do_print (const print_context &c, unsigned level) const
 Default output to stream.
void do_print_tree (const print_tree &c, unsigned level) const
 Tree output to stream.
void do_print_python_repr (const print_python_repr &c, unsigned level) const
 Python parsable output to stream.
Protected Member Functions inherited from GiNaC::container_storage< C >
 container_storage ()
 container_storage (size_t n, const ex &e)
 container_storage (std::initializer_list< ex > il)
template<class In>
 container_storage (In b, In e)
void reserve (size_t)
 ~container_storage ()
void reserve (size_t n)
void reserve (std::vector< ex > &v, size_t n)

Protected Attributes

unsigned char representation_label
 Representation label to distinguish independent spin lines.
ex metric
 Metric of the space, all constructors make it an indexed object.
int commutator_sign
 It is the sign in the definition e~i e~j +/- e~j e~i = B(i, j) + B(j, i)
Protected Attributes inherited from GiNaC::indexed
ex symtree
 Index symmetry (tree of symmetry objects)
Protected Attributes inherited from GiNaC::basic
unsigned flags
 of type status_flags
unsigned hashvalue
 hash value
Protected Attributes inherited from GiNaC::container_storage< C >
STLT seq

Additional Inherited Members

Public Types inherited from GiNaC::container< std::vector >
typedef STLT::const_iterator const_iterator
typedef STLT::const_reverse_iterator const_reverse_iterator
Protected Types inherited from GiNaC::container< std::vector >
typedef container_storage< std::vector >::STLT STLT
Protected Types inherited from GiNaC::container_storage< C >
typedef C< exSTLT
Static Protected Member Functions inherited from GiNaC::container< std::vector >
static unsigned get_default_flags ()
static char get_open_delim ()
static char get_close_delim ()
Static Protected Member Functions inherited from GiNaC::container_storage< C >
static void reserve (STLT &, size_t)

Detailed Description

This class holds an object representing an element of the Clifford algebra (the Dirac gamma matrices).

These objects only carry Lorentz indices. Spinor indices are hidden. A representation label (an unsigned 8-bit integer) is used to distinguish elements from different Clifford algebras (objects with different labels commutate).

Definition at line 40 of file clifford.h.

Constructor & Destructor Documentation

◆ clifford() [1/4]

GiNaC::clifford::clifford ( const ex & b,
unsigned char rl = 0 )

Construct object without any indices.

This constructor is for internal use only. Use the dirac_ONE() function instead.

See also
dirac_ONE

Definition at line 96 of file clifford.cpp.

References clifford(), commutator_sign, metric, and representation_label.

Referenced by clifford(), eval_ncmul(), match_same_type(), subs(), thiscontainer(), and thiscontainer().

◆ clifford() [2/4]

GiNaC::clifford::clifford ( const ex & b,
const ex & mu,
const ex & metr,
unsigned char rl = 0,
int comm_sign = -1 )

Construct object with one Lorentz index.

This constructor is for internal use only. Use the clifford_unit() or dirac_gamma() functions instead.

See also
clifford_unit
dirac_gamma

Definition at line 104 of file clifford.cpp.

References commutator_sign, GINAC_ASSERT, GiNaC::is_a(), metric, and representation_label.

◆ clifford() [3/4]

GiNaC::clifford::clifford ( unsigned char rl,
const ex & metr,
int comm_sign,
const exvector & v )

Definition at line 109 of file clifford.cpp.

References commutator_sign, metric, GiNaC::not_symmetric(), and representation_label.

◆ clifford() [4/4]

GiNaC::clifford::clifford ( unsigned char rl,
const ex & metr,
int comm_sign,
exvector && v )

Definition at line 113 of file clifford.cpp.

References commutator_sign, metric, GiNaC::not_symmetric(), and representation_label.

Member Function Documentation

◆ precedence()

unsigned GiNaC::clifford::precedence ( ) const
inlineoverridevirtual

Return relative operator precedence (for parenthezing output).

Reimplemented from GiNaC::basic.

Definition at line 54 of file clifford.h.

Referenced by do_print_dflt(), and do_print_latex().

◆ archive()

void GiNaC::clifford::archive ( archive_node & n) const
overridevirtual

Save (serialize) the object into archive node.

Archive the object.

Losely speaking, this method turns an expression into a byte stream (which can be saved and restored later on, or sent via network, etc.)

Reimplemented from GiNaC::basic.

Definition at line 137 of file clifford.cpp.

References GiNaC::archive_node::add_ex(), GiNaC::archive_node::add_unsigned(), commutator_sign, metric, and representation_label.

◆ read_archive()

void GiNaC::clifford::read_archive ( const archive_node & n,
lst & syms )
overridevirtual

Load (deserialize) the object from an archive node.

Construct object from archive_node.

Note
This method is essentially a constructor. However, constructors can't be virtual. So, if unarchiving routines are implemented as constructors one would need to define such a constructor in every class, even if all it does is simply calling constructor of a superclass.

Reimplemented from GiNaC::basic.

Definition at line 126 of file clifford.cpp.

References commutator_sign, GiNaC::archive_node::find_ex(), GiNaC::archive_node::find_unsigned(), metric, and representation_label.

◆ eval_ncmul()

ex GiNaC::clifford::eval_ncmul ( const exvector & v) const
overrideprotectedvirtual

Perform automatic simplification on noncommutative product of clifford objects.

This removes superfluous ONEs, permutes gamma5/L/R's to the front and removes squares of gamma objects.

Reimplemented from GiNaC::basic.

Definition at line 529 of file clifford.cpp.

References GiNaC::_ex0, GiNaC::class_info< OPT >::first, clifford(), GiNaC::dirac_ONE(), GiNaC::dynallocate(), GiNaC::ex_to(), get_commutator_sign(), GiNaC::hold_ncmul(), GiNaC::indexed::indexed(), GiNaC::is_a(), GiNaC::ex::is_equal(), GiNaC::ex::op(), GiNaC::reeval_ncmul(), representation_label, same_metric(), and GiNaC::varidx::toggle_variance().

◆ match_same_type()

bool GiNaC::clifford::match_same_type ( const basic & other) const
overrideprotectedvirtual

Returns true if the attributes of two objects are similar enough for a match.

This function must not match subexpressions (this is already done by basic::match()). Only attributes not accessible by op() should be compared. This is also the reason why this function doesn't take the wildcard replacement list from match() as an argument: only subexpressions are subject to wildcard matches. Also, this function only needs to be implemented for container classes because is_equal_same_type() is automatically used instead of match_same_type() if nops() == 0.

See also
basic::match

Reimplemented from GiNaC::basic.

Definition at line 247 of file clifford.cpp.

References clifford(), commutator_sign, get_commutator_sign(), GINAC_ASSERT, GiNaC::is_a(), representation_label, and same_metric().

◆ thiscontainer() [1/2]

ex GiNaC::clifford::thiscontainer ( const exvector & v) const
overrideprotectedvirtual

Similar to duplicate(), but with a preset sequence.

Must be overridden by derived classes.

Reimplemented from GiNaC::container< std::vector >.

Definition at line 693 of file clifford.cpp.

References clifford(), commutator_sign, metric, and representation_label.

◆ thiscontainer() [2/2]

ex GiNaC::clifford::thiscontainer ( exvector && v) const
overrideprotectedvirtual

Similar to duplicate(), but with a preset sequence (which gets pilfered).

Must be overridden by derived classes.

Reimplemented from GiNaC::container< std::vector >.

Definition at line 698 of file clifford.cpp.

References clifford(), commutator_sign, metric, and representation_label.

◆ return_type()

unsigned GiNaC::clifford::return_type ( ) const
inlineoverrideprotectedvirtual

Reimplemented from GiNaC::basic.

Definition at line 62 of file clifford.h.

References GiNaC::return_types::noncommutative.

◆ return_type_tinfo()

return_type_t GiNaC::clifford::return_type_tinfo ( ) const
overrideprotectedvirtual

Reimplemented from GiNaC::basic.

Definition at line 117 of file clifford.cpp.

References GiNaC::make_return_type_t(), and representation_label.

◆ get_representation_label()

unsigned char GiNaC::clifford::get_representation_label ( ) const
inline

Definition at line 66 of file clifford.h.

References representation_label.

Referenced by GiNaC::cliffordunit::contract_with().

◆ get_metric() [1/2]

ex GiNaC::clifford::get_metric ( ) const
inline

Definition at line 67 of file clifford.h.

References metric.

Referenced by GiNaC::cliffordunit::contract_with(), and same_metric().

◆ get_metric() [2/2]

ex GiNaC::clifford::get_metric ( const ex & i,
const ex & j,
bool symmetrised = false ) const
virtual

◆ same_metric()

◆ get_commutator_sign()

int GiNaC::clifford::get_commutator_sign ( ) const
inline

Definition at line 70 of file clifford.h.

References commutator_sign.

Referenced by eval_ncmul(), and match_same_type().

◆ nops()

size_t GiNaC::clifford::nops ( ) const
inlineoverridevirtual

Number of operands/members.

Reimplemented from GiNaC::basic.

Definition at line 72 of file clifford.h.

Referenced by let_op(), and op().

◆ op()

ex GiNaC::clifford::op ( size_t i) const
overridevirtual

Return operand/member at position i.

Reimplemented from GiNaC::basic.

Definition at line 198 of file clifford.cpp.

References GINAC_ASSERT, nops(), and representation_label.

Referenced by same_metric().

◆ let_op()

ex & GiNaC::clifford::let_op ( size_t i)
overridevirtual

Return modifiable operand/member at position i.

Reimplemented from GiNaC::basic.

Definition at line 207 of file clifford.cpp.

References GiNaC::basic::ensure_if_modifiable(), GINAC_ASSERT, nops(), and representation_label.

◆ subs()

ex GiNaC::clifford::subs ( const exmap & m,
unsigned options = 0 ) const
overridevirtual

Substitute a set of objects by arbitrary expressions.

The ex returned will already be evaluated.

Reimplemented from GiNaC::basic.

Definition at line 219 of file clifford.cpp.

References GiNaC::are_ex_trivially_equal(), clifford(), GiNaC::ex_to(), GiNaC::is_a(), metric, and GiNaC::ex::subs().

◆ do_print_dflt()

◆ do_print_latex()

void GiNaC::clifford::do_print_latex ( const print_latex & c,
unsigned level ) const
protected

◆ do_print_tree()

Member Data Documentation

◆ representation_label

unsigned char GiNaC::clifford::representation_label
protected

◆ metric

ex GiNaC::clifford::metric
protected

Metric of the space, all constructors make it an indexed object.

Definition at line 85 of file clifford.h.

Referenced by archive(), clifford(), clifford(), clifford(), clifford(), do_print_tree(), get_metric(), get_metric(), read_archive(), subs(), thiscontainer(), and thiscontainer().

◆ commutator_sign

int GiNaC::clifford::commutator_sign
protected

It is the sign in the definition e~i e~j +/- e~j e~i = B(i, j) + B(j, i)

Definition at line 86 of file clifford.h.

Referenced by archive(), clifford(), clifford(), clifford(), clifford(), get_commutator_sign(), match_same_type(), read_archive(), thiscontainer(), and thiscontainer().


The documentation for this class was generated from the following files:

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.