GiNaC  1.6.2
Public Member Functions | Protected Member Functions | Protected Attributes
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

List of all members.

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

ex value
 Expression that constitutes the index (numeric or symbolic name)
ex dim
 Dimension of space (can be symbolic or numeric)

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

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)
Returns:
newly constructed index

Definition at line 72 of file idx.cpp.

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


Member Function Documentation

bool GiNaC::idx::info ( unsigned  inf) const [virtual]

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.

size_t GiNaC::idx::nops ( ) const [virtual]

Number of operands/members.

Reimplemented from GiNaC::basic.

Definition at line 244 of file idx.cpp.

ex GiNaC::idx::op ( size_t  i) const [virtual]

Return operand/member at position i.

Reimplemented from GiNaC::basic.

Definition at line 250 of file idx.cpp.

References GINAC_ASSERT, and value.

ex GiNaC::idx::map ( map_function f) const [virtual]

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::dynallocated, GiNaC::status_flags::hash_calculated, GiNaC::basic::setflag(), and value.

ex GiNaC::idx::evalf ( int  level = 0) const [virtual]

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 369 of file idx.cpp.

ex GiNaC::idx::subs ( const exmap m,
unsigned  options = 0 
) const [virtual]
void GiNaC::idx::archive ( archive_node n) const [virtual]

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::spinidx, and GiNaC::varidx.

Definition at line 113 of file idx.cpp.

References GiNaC::archive_node::add_ex(), dim, and value.

void GiNaC::idx::read_archive ( const archive_node n,
lst syms 
) [virtual]

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::spinidx, and GiNaC::varidx.

Definition at line 91 of file idx.cpp.

References dim, GiNaC::archive_node::find_ex(), and value.

ex GiNaC::idx::derivative ( const symbol s) const [protected, virtual]

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

See also:
ex::diff

Reimplemented from GiNaC::basic.

Definition at line 405 of file idx.cpp.

References GiNaC::_ex0.

bool GiNaC::idx::match_same_type ( const basic other) const [protected, virtual]

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::spinidx, and GiNaC::varidx.

Definition at line 283 of file idx.cpp.

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

unsigned GiNaC::idx::calchash ( ) const [protected, virtual]

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 344 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.

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::spinidx, and GiNaC::varidx.

Definition at line 414 of file idx.cpp.

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

Referenced by GiNaC::is_dummy_pair().

ex GiNaC::idx::get_value ( ) const [inline]
bool GiNaC::idx::is_numeric ( ) const [inline]

Check whether the index is numeric.

Definition at line 75 of file idx.h.

References value.

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

Check whether the index is symbolic.

Definition at line 78 of file idx.h.

References value.

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

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

Get dimension of index space.

Definition at line 81 of file idx.h.

References dim.

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

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

Check whether the dimension is numeric.

Definition at line 84 of file idx.h.

References dim.

Referenced by idx().

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

Check whether the dimension is symbolic.

Definition at line 87 of file idx.h.

References dim.

ex GiNaC::idx::replace_dim ( const ex new_dim) const
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 469 of file idx.cpp.

References dim.

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

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

Default output to stream.

Reimplemented from GiNaC::basic.

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

Definition at line 151 of file idx.cpp.

References print_index(), and GiNaC::print_context::s.

void GiNaC::idx::do_print_csrc ( const print_csrc c,
unsigned  level 
) const [protected]
void GiNaC::idx::do_print_latex ( const print_latex c,
unsigned  level 
) const [protected]

Reimplemented in GiNaC::spinidx.

Definition at line 157 of file idx.cpp.

References print_index(), and GiNaC::print_context::s.

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

Tree output to stream.

Reimplemented from GiNaC::basic.

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

Definition at line 174 of file idx.cpp.

References GiNaC::print_tree::delta_indent, dim, GiNaC::basic::flags, GiNaC::basic::hashvalue, GiNaC::ex::print(), GiNaC::print_context::s, and value.


Member Data Documentation

ex GiNaC::idx::value [protected]
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.