Go to the documentation of this file.
76 throw(std::invalid_argument(
"dimension of space must be a positive integer"));
83 spinidx::spinidx(
const ex & v,
const ex & d,
bool cov,
bool dot) : inherited(v, d, cov), dotted(dot)
93 inherited::read_archive(
n, sym_lst);
94 n.find_ex(
"value",
value, sym_lst);
95 n.find_ex(
"dim",
dim, sym_lst);
101 inherited::read_archive(
n, sym_lst);
108 inherited::read_archive(
n, sym_lst);
115 inherited::archive(
n);
117 n.add_ex(
"dim",
dim);
122 inherited::archive(
n);
128 inherited::archive(
n);
138 bool need_parens = !(is_exactly_a<numeric>(
value) || is_a<symbol>(
value));
168 c.s << ex_to<numeric>(
value).to_int();
176 c.s << std::string(level,
' ') << class_name() <<
" @" <<
this
177 << std::hex <<
", hash=0x" <<
hashvalue <<
", flags=0x" <<
flags << std::dec
194 c.s << std::string(level,
' ') << class_name() <<
" @" <<
this
195 << std::hex <<
", hash=0x" <<
hashvalue <<
", flags=0x" <<
flags << std::dec
196 << (
covariant ?
", covariant" :
", contravariant")
225 c.s << std::string(level,
' ') << class_name() <<
" @" <<
this
226 << std::hex <<
", hash=0x" <<
hashvalue <<
", flags=0x" <<
flags << std::dec
227 << (
covariant ?
", covariant" :
", contravariant")
228 << (
dotted ?
", dotted" :
", undotted")
241 return inherited::info(inf);
258 const ex &mapped_value = f(
value);
264 copy->
value = mapped_value;
274 const idx &o =
static_cast<const idx &
>(other);
285 const idx &o =
static_cast<const idx &
>(other);
295 int cmpval = inherited::compare_same_type(other);
314 return inherited::match_same_type(other);
326 int cmpval = inherited::compare_same_type(other);
340 return inherited::match_same_type(other);
376 auto it =
m.find(*
this);
385 i_copy->
value = it->second;
396 i_copy->
value = subsed_value;
415 const idx &o =
static_cast<const idx &
>(other);
418 if (!is_a<symbol>(
value))
430 return is_exactly_a<numeric>(
dim) || is_exactly_a<numeric>(o.
dim);
441 return inherited::is_dummy_pair_same_type(other);
452 return inherited::is_dummy_pair_same_type(other);
463 i_copy->
dim = new_dim;
505 if (
typeid(i1) !=
typeid(i2))
515 if (!is_a<idx>(e1) || !is_a<idx>(e2))
531 if (itend - it == 1) {
532 if (ex_to<idx>(*it).is_symbolic())
533 out_free.push_back(*it);
543 it = v.begin(); itend = v.end();
545 while (it != itend) {
547 out_dummy.push_back(*
last);
552 if (!it->is_equal(*
last) && ex_to<idx>(*last).is_symbolic())
553 out_free.push_back(*
last);
557 if (ex_to<idx>(*last).is_symbolic())
558 out_free.push_back(*
last);
563 if (dim1.
is_equal(dim2) || dim1 < dim2 || (is_exactly_a<numeric>(dim1) && !is_a<numeric>(dim2)))
565 else if (dim1 > dim2 || (!is_a<numeric>(dim1) && is_exactly_a<numeric>(dim2)))
568 std::ostringstream s;
569 s <<
"minimal_dim(): index dimensions " << dim1 <<
" and " << dim2 <<
" cannot be ordered";
570 throw (std::runtime_error(s.str()));
bool match_same_type(const basic &other) const override
Returns true if the attributes of two objects are similar enough for a match.
ex minimal_dim(const ex &dim1, const ex &dim2)
Return the minimum of two index dimensions.
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
void archive(archive_node &n) const override
Save (serialize) the object into archive node.
@ print_index_dimensions
print the dimensions of indices
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.
unsigned hashvalue
hash value
bool match_same_type(const basic &other) const override
Returns true if the attributes of two objects are similar enough for a match.
Function object for map().
int compare(const ex &other) const
ex subs(const exmap &m, unsigned options=0) const
Base class for print_contexts.
spinidx(const ex &v, const ex &dim=2, bool covariant=false, bool dotted=false)
Construct index with given value, dimension, variance and dot.
Base context for C source output.
std::vector< ex > exvector
@ evaluated
.eval() has already done its job
void do_print_latex(const print_latex &c, unsigned level) const
void read_archive(const archive_node &n, lst &syms) override
Load (deserialize) the object from an archive node.
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Interface to GiNaC's indices.
bool covariant
x.mu, default is contravariant: x~mu
ex subs(const exmap &m, unsigned options=0) const override
Substitute a set of objects by arbitrary expressions.
Interface to relations between expressions.
This class holds a spinor index that can be dotted or undotted and that also has a variance.
void do_print(const print_context &c, unsigned level) const
bool is_dummy_pair_same_type(const basic &other) const override
Check whether the index forms a dummy index pair with another index of the same type.
bool is_equal(const ex &other) const
GINAC_BIND_UNARCHIVER(add)
idx(const ex &v, const ex &dim)
Construct index with given value and dimension.
const basic & clearflag(unsigned f) const
Clear some status_flags.
bool are_ex_trivially_equal(const ex &e1, const ex &e2)
Compare two objects of class quickly without doing a deep tree traversal.
void do_print_tree(const print_tree &c, unsigned level) const
ex dim
Dimension of space (can be symbolic or numeric)
varidx(const ex &v, const ex &dim, bool covariant=false)
Construct index with given value, dimension and variance.
bool info(unsigned inf) const
Interface to several small and furry utilities needed within GiNaC but not of any interest to the use...
bool is_dummy_pair_same_type(const basic &other) const override
Check whether the index forms a dummy index pair with another index of the same type.
ex toggle_variance_dot() const
Make a new index with the same value but opposite variance and dottedness.
Lightweight wrapper for GiNaC's symbolic objects.
Definition of GiNaC's lst.
virtual int compare_same_type(const basic &other) const
Returns order relation between two objects of same type.
virtual basic * duplicate() const
Create a clone of this object on the heap.
void do_print(const print_context &c, unsigned level) const
ex evalf() const override
By default, basic::evalf would evaluate the index value but we don't want a.1 to become a.
void do_print_tree(const print_tree &c, unsigned level) const
@ hash_calculated
.calchash() has already done its job
void read_archive(const archive_node &n, lst &syms) override
Load (deserialize) the object from an archive node.
Context for latex-parsable output.
Interface to GiNaC's symbolic objects.
void do_print_tree(const print_tree &c, unsigned level) const
This class holds an index with a variance (co- or contravariant).
ex op(size_t i) const override
Return operand/member at position i.
unsigned calchash() const override
Compute the hash value of an object and if it makes sense to store it in the objects status_flags,...
bool match_same_type(const basic &other) const override
Returns true if the attributes of two objects are similar enough for a match.
void print(const print_context &c, unsigned level=0) const
Print expression to stream.
Context for tree-like output for debugging.
void do_print_csrc(const print_csrc &c, unsigned level) const
unsigned rotate_left(unsigned n)
Rotate bits of unsigned value by one bit to the left.
void read_archive(const archive_node &n, lst &syms) override
Load (deserialize) the object from an archive node.
const basic & setflag(unsigned f) const
Set some status_flags.
Wrapper template for making GiNaC classes out of STL containers.
ex value
Expression that constitutes the index (numeric or symbolic name)
ex toggle_variance() const
Make a new index with the same value but the opposite variance.
void shaker_sort(It first, It last, Cmp comp, Swap swapit)
std::map< ex, ex, ex_is_less > exmap
ex derivative(const symbol &s) const override
Implementation of ex::diff() for an index always returns 0.
Archiving of GiNaC expressions.
void print_index(const print_context &c, unsigned level) const
void do_print(const print_context &c, unsigned level) const
bool is_dim_numeric() const
Check whether the dimension is numeric.
void find_free_and_dummy(exvector::const_iterator it, exvector::const_iterator itend, exvector &out_free, exvector &out_dummy)
Given a vector of indices, split them into two vectors, one containing the free indices,...
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
ex map(map_function &f) const override
Construct new expression by applying the specified function to all sub-expressions (one level only,...
void archive(archive_node &n) const override
Save (serialize) the object into archive node.
bool info(unsigned inf) const override
Information about the object.
void do_print_latex(const print_latex &c, unsigned level) const
ex replace_dim(const ex &new_dim) const
Make a new index with the same value but a different dimension.
This class holds one index of an indexed object.
unsigned flags
of type status_flags
bool is_dummy_pair(const idx &i1, const idx &i2)
Check whether two indices form a dummy pair.
size_t nops() const override
Number of operands/members.
print_func< print_context >(&varidx::do_print). print_func< print_latex >(&varidx
ex toggle_dot() const
Make a new index with the same value and variance but the opposite dottedness.
void archive(archive_node &n) const override
Save (serialize) the object into archive node.
static unsigned make_hash_seed(const std::type_info &tinfo)
We need a hash function which gives different values for objects of different types.
Interface to GiNaC's overloaded operators.
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
ex minimal_dim(const idx &other) const
Return the minimum of the dimensions of this and another index.
This page is part of the GiNaC
developer's reference. It was generated automatically by doxygen. For
an introduction, see the tutorial.