3 * Interface to GiNaC's indices.
5 * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef __GINAC_IDX_H__
23 #define __GINAC_IDX_H__
28 class idx : public basic
32 // default constructor, destructor, copy constructor assignment operator and helpers
36 idx (idx const & other);
37 idx const & operator=(idx const & other);
39 void copy(idx const & other);
40 void destroy(bool call_parent);
44 explicit idx(bool cov);
45 explicit idx(string const & n, bool cov=false);
46 explicit idx(char const * n, bool cov=false);
47 explicit idx(unsigned const v, bool cov=false);
49 // functions overriding virtual functions from bases classes
51 basic * duplicate() const;
52 void printraw(ostream & os) const;
53 void printtree(ostream & os, unsigned indent) const;
54 void print(ostream & os, unsigned upper_precedence=0) const;
55 bool info(unsigned inf) const;
57 int compare_same_type(basic const & other) const;
58 bool is_equal_same_type(basic const & other) const;
59 unsigned calchash(void) const;
60 ex subs(lst const & ls, lst const & lr) const;
62 // new virtual functions which can be overridden by derived classes
64 virtual bool is_co_contra_pair(basic const & other) const;
65 virtual ex toggle_covariant(void) const;
67 // non-virtual functions in this class
69 bool is_symbolic(void) const;
70 unsigned get_value(void) const;
71 bool is_covariant(void) const;
79 static unsigned next_serial;
80 bool covariant; // x_mu, default is contravariant: x^mu
85 extern const idx some_idx;
86 extern type_info const & typeid_idx;
90 #define ex_to_idx(X) (static_cast<idx const &>(*(X).bp))
94 typedef vector<ex> exvector;
96 int canonicalize_indices(exvector & iv, bool antisymmetric=false);
97 exvector idx_intersect(exvector const & iv1, exvector const & iv2);
98 ex permute_free_index_to_front(exvector const & iv3, exvector const & iv2,
99 bool antisymmetric, int * sig);
100 unsigned subs_index_in_exvector(exvector & v, ex const & is, ex const & ir);
101 ex subs_indices(ex const & e, exvector const & idxv_contra,
102 exvector const & idxv_co);
103 unsigned count_index(ex const & e, ex const & i);
105 #endif // ndef __GINAC_IDX_H__