GiNaC 1.8.7
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GiNaC::idx Class Reference

This class holds one index of an indexed object. More...

#include <idx.h>

Inheritance diagram for GiNaC::idx:
GiNaC::basic GiNaC::refcounted GiNaC::varidx GiNaC::spinidx

Public Member Functions

 idx (const ex &v, const ex &dim)
 Construct index with given value and dimension. More...
 
bool info (unsigned inf) const override
 Information about the object. More...
 
size_t nops () const override
 Number of operands/members. More...
 
ex op (size_t i) const override
 Return operand/member at position i. More...
 
ex map (map_function &f) const override
 Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively). More...
 
ex evalf () const override
 By default, basic::evalf would evaluate the index value but we don't want a.1 to become a. More...
 
ex subs (const exmap &m, unsigned options=0) const override
 Substitute a set of objects by arbitrary expressions. More...
 
void archive (archive_node &n) const override
 Save (serialize) the object into archive node. More...
 
void read_archive (const archive_node &n, lst &syms) override
 Load (deserialize) the object from an archive node. More...
 
virtual bool is_dummy_pair_same_type (const basic &other) const
 Check whether the index forms a dummy index pair with another index of the same type. More...
 
ex get_value () const
 Get value of index. More...
 
bool is_numeric () const
 Check whether the index is numeric. More...
 
bool is_symbolic () const
 Check whether the index is symbolic. More...
 
ex get_dim () const
 Get dimension of index space. More...
 
bool is_dim_numeric () const
 Check whether the dimension is numeric. More...
 
bool is_dim_symbolic () const
 Check whether the dimension is symbolic. More...
 
ex replace_dim (const ex &new_dim) const
 Make a new index with the same value but a different dimension. More...
 
ex minimal_dim (const idx &other) const
 Return the minimum of the dimensions of this and another index. 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

ex derivative (const symbol &s) const override
 Implementation of ex::diff() for an index always returns 0. More...
 
bool match_same_type (const basic &other) const override
 Returns true if the attributes of two objects are similar enough for a match. More...
 
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 print_index (const print_context &c, unsigned level) const
 
void do_print (const print_context &c, unsigned level) const
 
void do_print_csrc (const print_csrc &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::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...
 

Protected Attributes

ex value
 Expression that constitutes the index (numeric or symbolic name) More...
 
ex dim
 Dimension of space (can be symbolic or numeric) More...
 
- Protected Attributes inherited from GiNaC::basic
unsigned flags
 of type status_flags More...
 
unsigned hashvalue
 hash value More...
 

Detailed Description

This class holds one index of an indexed object.

Indices can theoretically consist of any symbolic expression but they are usually only just a symbol (e.g. "mu", "i") or numeric (integer). Indices belong to a space with a certain numeric or symbolic dimension.

Definition at line 35 of file idx.h.

Constructor & Destructor Documentation

◆ idx()

GiNaC::idx::idx ( const ex v,
const ex dim 
)
explicit

Construct index with given value and dimension.

Parameters
vValue of index (numeric or symbolic)
dimDimension of index space (numeric or symbolic)

Definition at line 72 of file idx.cpp.

References dim, GiNaC::ex::info(), is_dim_numeric(), and GiNaC::info_flags::posint.

Member Function Documentation

◆ info()

bool GiNaC::idx::info ( unsigned  inf) const
overridevirtual

Information about the object.

See also
class info_flags

Reimplemented from GiNaC::basic.

Definition at line 234 of file idx.cpp.

References GiNaC::info_flags::has_indices, and GiNaC::info_flags::idx.

◆ nops()

size_t GiNaC::idx::nops ( ) const
overridevirtual

Number of operands/members.

Reimplemented from GiNaC::basic.

Definition at line 244 of file idx.cpp.

◆ op()

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

Return operand/member at position i.

Reimplemented from GiNaC::basic.

Definition at line 250 of file idx.cpp.

References GINAC_ASSERT, and value.

◆ map()

ex GiNaC::idx::map ( map_function f) const
overridevirtual

Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively).

Reimplemented from GiNaC::basic.

Definition at line 256 of file idx.cpp.

References GiNaC::are_ex_trivially_equal(), GiNaC::basic::clearflag(), GiNaC::basic::duplicate(), GiNaC::status_flags::hash_calculated, and value.

◆ evalf()

ex GiNaC::idx::evalf ( ) const
overridevirtual

By default, basic::evalf would evaluate the index value but we don't want a.1 to become a.

(1.0).

Reimplemented from GiNaC::basic.

Definition at line 368 of file idx.cpp.

◆ subs()

ex GiNaC::idx::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 373 of file idx.cpp.

References GiNaC::are_ex_trivially_equal(), GiNaC::basic::clearflag(), GiNaC::basic::duplicate(), GiNaC::status_flags::hash_calculated, m, options, GiNaC::subs_options::really_subs_idx, GiNaC::ex::subs(), and value.

◆ archive()

void GiNaC::idx::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.

Reimplemented in GiNaC::varidx, and GiNaC::spinidx.

Definition at line 113 of file idx.cpp.

References dim, n, and value.

◆ read_archive()

void GiNaC::idx::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.

Reimplemented in GiNaC::varidx, and GiNaC::spinidx.

Definition at line 91 of file idx.cpp.

References dim, n, and value.

◆ derivative()

ex GiNaC::idx::derivative ( const symbol s) const
overrideprotectedvirtual

Implementation of ex::diff() for an index always returns 0.

See also
ex::diff

Reimplemented from GiNaC::basic.

Definition at line 404 of file idx.cpp.

References GiNaC::_ex0.

◆ match_same_type()

bool GiNaC::idx::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.

Reimplemented in GiNaC::varidx, and GiNaC::spinidx.

Definition at line 282 of file idx.cpp.

References dim, GINAC_ASSERT, and GiNaC::ex::is_equal().

◆ calchash()

unsigned GiNaC::idx::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 343 of file idx.cpp.

References GiNaC::status_flags::evaluated, GiNaC::basic::flags, GiNaC::ex::gethash(), GiNaC::status_flags::hash_calculated, GiNaC::basic::hashvalue, GiNaC::make_hash_seed(), GiNaC::rotate_left(), GiNaC::basic::setflag(), and value.

◆ is_dummy_pair_same_type()

bool GiNaC::idx::is_dummy_pair_same_type ( const basic other) const
virtual

Check whether the index forms a dummy index pair with another index of the same type.

Reimplemented in GiNaC::varidx, and GiNaC::spinidx.

Definition at line 413 of file idx.cpp.

References dim, GiNaC::ex::is_equal(), and value.

Referenced by GiNaC::is_dummy_pair().

◆ get_value()

ex GiNaC::idx::get_value ( ) const
inline

◆ is_numeric()

bool GiNaC::idx::is_numeric ( ) const
inline

Check whether the index is numeric.

Definition at line 74 of file idx.h.

References value.

◆ is_symbolic()

bool GiNaC::idx::is_symbolic ( ) const
inline

Check whether the index is symbolic.

Definition at line 77 of file idx.h.

References value.

Referenced by GiNaC::spinmetric::contract_with(), and GiNaC::tensor::replace_contr_index().

◆ get_dim()

ex GiNaC::idx::get_dim ( ) const
inline

Get dimension of index space.

Definition at line 80 of file idx.h.

References dim.

Referenced by GiNaC::matrix::eval_indexed(), GiNaC::tensdelta::eval_indexed(), and GiNaC::tensmetric::eval_indexed().

◆ is_dim_numeric()

bool GiNaC::idx::is_dim_numeric ( ) const
inline

Check whether the dimension is numeric.

Definition at line 83 of file idx.h.

References dim.

Referenced by idx().

◆ is_dim_symbolic()

bool GiNaC::idx::is_dim_symbolic ( ) const
inline

Check whether the dimension is symbolic.

Definition at line 86 of file idx.h.

References dim.

◆ replace_dim()

ex GiNaC::idx::replace_dim ( const ex new_dim) const

Make a new index with the same value but a different dimension.

Definition at line 460 of file idx.cpp.

References GiNaC::basic::clearflag(), dim, GiNaC::basic::duplicate(), and GiNaC::status_flags::hash_calculated.

Referenced by GiNaC::tensdelta::eval_indexed(), GiNaC::tensmetric::eval_indexed(), and GiNaC::tensor::replace_contr_index().

◆ minimal_dim()

ex GiNaC::idx::minimal_dim ( const idx other) const

Return the minimum of the dimensions of this and another index.

If this is undecidable, throw an exception.

Definition at line 468 of file idx.cpp.

References dim, and GiNaC::minimal_dim().

Referenced by GiNaC::tensdelta::eval_indexed(), GiNaC::tensmetric::eval_indexed(), and GiNaC::tensor::replace_contr_index().

◆ print_index()

void GiNaC::idx::print_index ( const print_context c,
unsigned  level 
) const
protected

◆ do_print()

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

Definition at line 151 of file idx.cpp.

References c, and print_index().

◆ do_print_csrc()

void GiNaC::idx::do_print_csrc ( const print_csrc c,
unsigned  level 
) const
protected

Definition at line 164 of file idx.cpp.

References c, GiNaC::ex::info(), GiNaC::info_flags::integer, GiNaC::ex::print(), and value.

◆ do_print_latex()

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

Definition at line 157 of file idx.cpp.

References c, and print_index().

◆ do_print_tree()

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

Definition at line 174 of file idx.cpp.

References c, dim, GiNaC::basic::flags, GiNaC::basic::hashvalue, GiNaC::ex::print(), and value.

Member Data Documentation

◆ value

ex GiNaC::idx::value
protected

◆ dim

ex GiNaC::idx::dim
protected

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.