GiNaC 1.8.7
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
GiNaC::symmetry Class Reference

This class describes the symmetry of a group of indices. More...

#include <symmetry.h>

Inheritance diagram for GiNaC::symmetry:
GiNaC::basic GiNaC::refcounted

Public Types

enum  symmetry_type { none , symmetric , antisymmetric , cyclic }
 Type of symmetry. More...
 

Public Member Functions

 symmetry (unsigned i)
 Create leaf node that represents one index. More...
 
 symmetry (symmetry_type t, const symmetry &c1, const symmetry &c2)
 Create node with two children. More...
 
void archive (archive_node &n) const override
 Save (a.k.a. More...
 
void read_archive (const archive_node &n, lst &syms) override
 Read (a.k.a. More...
 
symmetry_type get_type () const
 Get symmetry type. More...
 
void set_type (symmetry_type t)
 Set symmetry type. More...
 
symmetryadd (const symmetry &c)
 Add child node, check index sets for consistency. More...
 
void validate (unsigned n)
 Verify that all indices of this node are in the range [0..n-1]. More...
 
bool has_symmetry () const
 Check whether this node actually represents any kind of symmetry. More...
 
bool has_nonsymmetric () const
 Check whether this node involves anything non symmetric. More...
 
bool has_cyclic () const
 Check whether this node involves a cyclic symmetry. More...
 
- Public Member Functions inherited from GiNaC::basic
virtual ~basic ()
 basic destructor, virtual because class ex will delete objects of derived classes via a basic*. More...
 
 basic (const basic &other)
 
const basicoperator= (const basic &other)
 basic assignment operator: the other object might be of a derived class. More...
 
virtual basicduplicate () const
 Create a clone of this object on the heap. More...
 
virtual ex eval () const
 Perform automatic non-interruptive term rewriting rules. More...
 
virtual ex evalf () const
 Evaluate object numerically. More...
 
virtual ex evalm () const
 Evaluate sums, products and integer powers of matrices. More...
 
virtual ex eval_integ () const
 Evaluate integrals, if result is known. More...
 
virtual ex eval_indexed (const basic &i) const
 Perform automatic symbolic evaluations on indexed expression that contains this object as the base expression. More...
 
virtual void print (const print_context &c, unsigned level=0) const
 Output to stream. More...
 
virtual void dbgprint () const
 Little wrapper around print to be called within a debugger. More...
 
virtual void dbgprinttree () const
 Little wrapper around printtree to be called within a debugger. More...
 
virtual unsigned precedence () const
 Return relative operator precedence (for parenthezing output). More...
 
virtual bool info (unsigned inf) const
 Information about the object. More...
 
virtual size_t nops () const
 Number of operands/members. More...
 
virtual ex op (size_t i) const
 Return operand/member at position i. More...
 
virtual ex operator[] (const ex &index) const
 
virtual ex operator[] (size_t i) const
 
virtual exlet_op (size_t i)
 Return modifiable operand/member at position i. More...
 
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. More...
 
virtual bool match (const ex &pattern, exmap &repls) const
 Check whether the expression matches a given pattern. More...
 
virtual ex subs (const exmap &m, unsigned options=0) const
 Substitute a set of objects by arbitrary expressions. More...
 
virtual ex map (map_function &f) const
 Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively). More...
 
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. More...
 
virtual int degree (const ex &s) const
 Return degree of highest power in object s. More...
 
virtual int ldegree (const ex &s) const
 Return degree of lowest power in object s. More...
 
virtual ex coeff (const ex &s, int n=1) const
 Return coefficient of degree n in object s. More...
 
virtual ex expand (unsigned options=0) const
 Expand expression, i.e. More...
 
virtual ex collect (const ex &s, bool distributed=false) const
 Sort expanded expression in terms of powers of some object(s). More...
 
virtual ex series (const relational &r, int order, unsigned options=0) const
 Default implementation of ex::series(). More...
 
virtual ex normal (exmap &repl, exmap &rev_lookup, lst &modifier) const
 Default implementation of ex::normal(). More...
 
virtual ex to_rational (exmap &repl) const
 Default implementation of ex::to_rational(). More...
 
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. More...
 
virtual numeric max_coefficient () const
 Implementation ex::max_coefficient(). More...
 
virtual exvector get_free_indices () const
 Return a vector containing the free indices of an expression. More...
 
virtual ex add_indexed (const ex &self, const ex &other) const
 Add two indexed expressions. More...
 
virtual ex scalar_mul_indexed (const ex &self, const numeric &other) const
 Multiply an indexed expression with a scalar. More...
 
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. More...
 
virtual unsigned return_type () const
 
virtual return_type_t return_type_tinfo () const
 
virtual ex conjugate () const
 
virtual ex real_part () const
 
virtual ex imag_part () const
 
template<class T >
void print_dispatch (const print_context &c, unsigned level) const
 Like print(), but dispatch to the specified class. More...
 
void print_dispatch (const registered_class_info &ri, const print_context &c, unsigned level) const
 Like print(), but dispatch to the specified class. More...
 
virtual void archive (archive_node &n) const
 Save (serialize) the object into archive node. More...
 
virtual void read_archive (const archive_node &n, lst &syms)
 Load (deserialize) the object from an archive node. More...
 
ex subs_one_level (const exmap &m, unsigned options) const
 Helper function for subs(). More...
 
ex diff (const symbol &s, unsigned nth=1) const
 Default interface of nth derivative ex::diff(s, n). More...
 
int compare (const basic &other) const
 Compare objects syntactically to establish canonical ordering. More...
 
bool is_equal (const basic &other) const
 Test for syntactic equality. More...
 
const basichold () const
 Stop further evaluation. More...
 
unsigned gethash () const
 
const basicsetflag (unsigned f) const
 Set some status_flags. More...
 
const basicclearflag (unsigned f) const
 Clear some status_flags. More...
 
- 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

unsigned calchash () const override
 Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so. More...
 
void do_print (const print_context &c, unsigned level) const
 
void do_print_tree (const print_tree &c, unsigned level) const
 
- Protected Member Functions inherited from GiNaC::basic
 basic ()
 
virtual ex eval_ncmul (const exvector &v) const
 
virtual bool match_same_type (const basic &other) const
 Returns true if the attributes of two objects are similar enough for a match. More...
 
virtual ex derivative (const symbol &s) const
 Default implementation of ex::diff(). More...
 
virtual int compare_same_type (const basic &other) const
 Returns order relation between two objects of same type. More...
 
virtual bool is_equal_same_type (const basic &other) const
 Returns true if two objects of same type are equal. More...
 
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. More...
 
void ensure_if_modifiable () const
 Ensure the object may be modified without hurting others, throws if this is not the case. More...
 
void do_print (const print_context &c, unsigned level) const
 Default output to stream. More...
 
void do_print_tree (const print_tree &c, unsigned level) const
 Tree output to stream. More...
 
void do_print_python_repr (const print_python_repr &c, unsigned level) const
 Python parsable output to stream. More...
 

Private Attributes

symmetry_type type
 Type of symmetry described by this node. More...
 
std::set< unsigned > indices
 Sorted union set of all indices handled by this node. More...
 
exvector children
 Vector of child nodes. More...
 

Friends

class sy_is_less
 
class sy_swap
 
int canonicalize (exvector::iterator v, const symmetry &symm)
 Canonicalize the order of elements of an expression vector, according to the symmetry properties defined in a symmetry tree. More...
 

Additional Inherited Members

- Protected Attributes inherited from GiNaC::basic
unsigned flags
 of type status_flags More...
 
unsigned hashvalue
 hash value More...
 

Detailed Description

This class describes the symmetry of a group of indices.

These objects can be grouped into a tree to form complex mixed symmetries.

Definition at line 38 of file symmetry.h.

Member Enumeration Documentation

◆ symmetry_type

Type of symmetry.

Enumerator
none 

no symmetry properties

symmetric 

totally symmetric

antisymmetric 

totally antisymmetric

cyclic 

cyclic symmetry

Definition at line 49 of file symmetry.h.

Constructor & Destructor Documentation

◆ symmetry() [1/2]

GiNaC::symmetry::symmetry ( unsigned  i)

Create leaf node that represents one index.

Definition at line 70 of file symmetry.cpp.

References GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, indices, and GiNaC::basic::setflag().

◆ symmetry() [2/2]

GiNaC::symmetry::symmetry ( symmetry_type  t,
const symmetry c1,
const symmetry c2 
)

Create node with two children.

Definition at line 76 of file symmetry.cpp.

References add(), GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, and GiNaC::basic::setflag().

Member Function Documentation

◆ archive()

void GiNaC::symmetry::archive ( archive_node n) const
overridevirtual

Save (a.k.a.

Archive the object.

serialize) object into archive.

Reimplemented from GiNaC::basic.

Definition at line 119 of file symmetry.cpp.

References children, indices, n, and type.

◆ read_archive()

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

Read (a.k.a.

Construct object from archive_node.

deserialize) object from archive.

Reimplemented from GiNaC::basic.

Definition at line 87 of file symmetry.cpp.

References add(), indices, n, and type.

◆ calchash()

unsigned GiNaC::symmetry::calchash ( ) const
overrideprotectedvirtual

Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so.

The method inherited from class basic computes a hash value based on the type and hash values of possible members. For this reason it is well suited for container classes but atomic classes should override this implementation because otherwise they would all end up with the same hashvalue.

Reimplemented from GiNaC::basic.

Definition at line 183 of file symmetry.cpp.

References children, GiNaC::status_flags::evaluated, GiNaC::basic::flags, GiNaC::status_flags::hash_calculated, GiNaC::basic::hashvalue, indices, GiNaC::make_hash_seed(), none, GiNaC::rotate_left(), GiNaC::basic::setflag(), and type.

◆ get_type()

symmetry_type GiNaC::symmetry::get_type ( ) const
inline

Get symmetry type.

Definition at line 76 of file symmetry.h.

References type.

◆ set_type()

void GiNaC::symmetry::set_type ( symmetry_type  t)
inline

Set symmetry type.

Definition at line 79 of file symmetry.h.

References type.

Referenced by GiNaC::sy_anti(), GiNaC::sy_cycl(), and GiNaC::sy_symm().

◆ add()

symmetry & GiNaC::symmetry::add ( const symmetry c)

Add child node, check index sets for consistency.

Definition at line 289 of file symmetry.cpp.

References c, children, GINAC_ASSERT, indices, none, and type.

Referenced by read_archive(), GiNaC::sy_anti(), GiNaC::sy_cycl(), GiNaC::sy_none(), GiNaC::sy_symm(), symmetry(), and validate().

◆ validate()

void GiNaC::symmetry::validate ( unsigned  n)

Verify that all indices of this node are in the range [0..n-1].

This function throws an exception if the verification fails. If the top node has a type != none and no children, add all indices in the range [0..n-1] as children.

Definition at line 312 of file symmetry.cpp.

References add(), indices, n, none, and type.

◆ has_symmetry()

bool GiNaC::symmetry::has_symmetry ( ) const
inline

Check whether this node actually represents any kind of symmetry.

Definition at line 91 of file symmetry.h.

References children, none, and type.

◆ has_nonsymmetric()

bool GiNaC::symmetry::has_nonsymmetric ( ) const

Check whether this node involves anything non symmetric.

Definition at line 265 of file symmetry.cpp.

References antisymmetric, children, cyclic, has_nonsymmetric(), and type.

Referenced by has_nonsymmetric().

◆ has_cyclic()

bool GiNaC::symmetry::has_cyclic ( ) const

Check whether this node involves a cyclic symmetry.

Definition at line 277 of file symmetry.cpp.

References children, cyclic, has_cyclic(), and type.

Referenced by has_cyclic().

◆ do_print()

void GiNaC::symmetry::do_print ( const print_context c,
unsigned  level 
) const
protected

Definition at line 206 of file symmetry.cpp.

References antisymmetric, c, children, cyclic, indices, none, symmetric, and type.

◆ do_print_tree()

void GiNaC::symmetry::do_print_tree ( const print_tree c,
unsigned  level 
) const
protected

Friends And Related Function Documentation

◆ sy_is_less

friend class sy_is_less
friend

Definition at line 40 of file symmetry.h.

◆ sy_swap

friend class sy_swap
friend

Definition at line 41 of file symmetry.h.

◆ canonicalize

int canonicalize ( exvector::iterator  v,
const symmetry symm 
)
friend

Canonicalize the order of elements of an expression vector, according to the symmetry properties defined in a symmetry tree.

Parameters
vStart of expression vector
symmRoot node of symmetry tree
Returns
the overall sign introduced by the reordering (+1, -1 or 0) or numeric_limits<int>::max() if nothing changed

Definition at line 438 of file symmetry.cpp.

Member Data Documentation

◆ type

symmetry_type GiNaC::symmetry::type
private

Type of symmetry described by this node.

Definition at line 103 of file symmetry.h.

Referenced by add(), archive(), calchash(), do_print(), do_print_tree(), get_type(), has_cyclic(), has_nonsymmetric(), has_symmetry(), read_archive(), set_type(), and validate().

◆ indices

std::set<unsigned> GiNaC::symmetry::indices
private

Sorted union set of all indices handled by this node.

Definition at line 106 of file symmetry.h.

Referenced by add(), archive(), calchash(), do_print(), do_print_tree(), read_archive(), symmetry(), and validate().

◆ children

exvector GiNaC::symmetry::children
private

Vector of child nodes.

Definition at line 109 of file symmetry.h.

Referenced by add(), archive(), calchash(), do_print(), do_print_tree(), has_cyclic(), has_nonsymmetric(), and has_symmetry().


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.