#include "lst.h"
#include "relational.h"
#include "operators.h"
-#include "print.h"
#include "archive.h"
#include "utils.h"
// functions overriding virtual functions from base classes
//////////
-void idx::do_print_idx(const print_context & c, unsigned level) const
+void idx::print_index(const print_context & c, unsigned level) const
{
bool need_parens = !(is_exactly_a<numeric>(value) || is_a<symbol>(value));
if (need_parens)
void idx::do_print(const print_context & c, unsigned level) const
{
c.s << ".";
- do_print_idx(c, level);
+ print_index(c, level);
}
void idx::do_print_latex(const print_latex & c, unsigned level) const
{
c.s << "{";
- do_print_idx(c, level);
+ print_index(c, level);
c.s << "}";
}
void idx::do_print_tree(const print_tree & c, unsigned level) const
{
- c.s << std::string(level, ' ') << class_name()
+ c.s << std::string(level, ' ') << class_name() << " @" << this
<< std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
<< std::endl;
value.print(c, level + c.delta_indent);
c.s << ".";
else
c.s << "~";
- do_print_idx(c, level);
+ print_index(c, level);
}
void varidx::do_print_tree(const print_tree & c, unsigned level) const
{
- c.s << std::string(level, ' ') << class_name()
+ c.s << std::string(level, ' ') << class_name() << " @" << this
<< std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
<< (covariant ? ", covariant" : ", contravariant")
<< std::endl;
c.s << "~";
if (dotted)
c.s << "*";
- do_print_idx(c, level);
+ print_index(c, level);
}
void spinidx::do_print_latex(const print_latex & c, unsigned level) const
c.s << "\\dot{";
else
c.s << "{";
- do_print_idx(c, level);
+ print_index(c, level);
c.s << "}";
}
void spinidx::do_print_tree(const print_tree & c, unsigned level) const
{
- c.s << std::string(level, ' ') << class_name()
+ c.s << std::string(level, ' ') << class_name() << " @" << this
<< std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
<< (covariant ? ", covariant" : ", contravariant")
<< (dotted ? ", dotted" : ", undotted")
unsigned idx::calchash() const
{
+ // NOTE: The code in simplify_indexed() assumes that canonically
+ // ordered sequences of indices have the two members of dummy index
+ // pairs lying next to each other. The hash values for indices must
+ // be devised accordingly. The easiest (only?) way to guarantee the
+ // desired ordering is to make indices with the same value have equal
+ // hash keys. That is, the hash values must not depend on the index
+ // dimensions or other attributes (variance etc.).
+ // The compare_same_type() methods will take care of the rest.
unsigned v = golden_ratio_hash(tinfo());
v = rotate_left(v);
v ^= value.gethash();
- v = rotate_left(v);
- v ^= dim.gethash();
// Store calculated hash value only if object is already evaluated
if (flags & status_flags::evaluated) {