3 * Interface to GiNaC's indices. */
13 class idx : public basic
17 // default constructor, destructor, copy constructor assignment operator and helpers
21 idx (idx const & other);
22 idx const & operator=(idx const & other);
24 void copy(idx const & other);
25 void destroy(bool call_parent);
29 explicit idx(bool cov);
30 explicit idx(string const & n, bool cov=false);
31 explicit idx(char const * n, bool cov=false);
32 explicit idx(unsigned const v, bool cov=false);
34 // functions overriding virtual functions from bases classes
36 basic * duplicate() const;
37 void printraw(ostream & os) const;
38 void printtree(ostream & os, unsigned indent) const;
39 void print(ostream & os, unsigned upper_precedence=0) const;
40 bool info(unsigned inf) const;
42 int compare_same_type(basic const & other) const;
43 bool is_equal_same_type(basic const & other) const;
44 unsigned calchash(void) const;
45 ex subs(lst const & ls, lst const & lr) const;
47 // new virtual functions which can be overridden by derived classes
49 virtual bool is_co_contra_pair(basic const & other) const;
50 virtual ex toggle_covariant(void) const;
52 // non-virtual functions in this class
54 bool is_symbolic(void) const;
55 unsigned get_value(void) const;
56 bool is_covariant(void) const;
64 static unsigned next_serial;
65 bool covariant; // x_mu, default is contravariant: x^mu
70 extern const idx some_idx;
71 extern type_info const & typeid_idx;
75 #define ex_to_idx(X) (static_cast<idx const &>(*(X).bp))
79 typedef vector<ex> exvector;
81 int canonicalize_indices(exvector & iv, bool antisymmetric=false);
82 exvector idx_intersect(exvector const & iv1, exvector const & iv2);
83 ex permute_free_index_to_front(exvector const & iv3, exvector const & iv2,
84 bool antisymmetric, int * sig);
85 unsigned subs_index_in_exvector(exvector & v, ex const & is, ex const & ir);
86 ex subs_indices(ex const & e, exvector const & idxv_contra,
87 exvector const & idxv_co);
88 unsigned count_index(ex const & e, ex const & i);
90 #endif // ndef _IDX_H_