/[GiNaC]/ginac/idx.h
ViewVC logotype

Contents of /ginac/idx.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Wed Nov 10 16:35:11 1999 UTC (13 years, 6 months ago) by cbauer
Branch: MAIN
Changes since 1.1: +21 -6 lines
File MIME type: text/plain
- enforced GiNaC coding standards :-)

1 /** @file idx.h
2 *
3 * Interface to GiNaC's indices.
4 *
5 * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
6 *
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.
11 *
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.
16 *
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
20 */
21
22 #ifndef __GINAC_IDX_H__
23 #define __GINAC_IDX_H__
24
25 #include <string>
26 #include <vector>
27
28 class idx : public basic
29 {
30 // member functions
31
32 // default constructor, destructor, copy constructor assignment operator and helpers
33 public:
34 idx();
35 ~idx();
36 idx (idx const & other);
37 idx const & operator=(idx const & other);
38 protected:
39 void copy(idx const & other);
40 void destroy(bool call_parent);
41
42 // other constructors
43 public:
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);
48
49 // functions overriding virtual functions from bases classes
50 public:
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;
56 protected:
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;
61
62 // new virtual functions which can be overridden by derived classes
63 public:
64 virtual bool is_co_contra_pair(basic const & other) const;
65 virtual ex toggle_covariant(void) const;
66
67 // non-virtual functions in this class
68 public:
69 bool is_symbolic(void) const;
70 unsigned get_value(void) const;
71 bool is_covariant(void) const;
72
73 // member variables
74 protected:
75 unsigned serial;
76 bool symbolic;
77 string name;
78 unsigned value;
79 static unsigned next_serial;
80 bool covariant; // x_mu, default is contravariant: x^mu
81 };
82
83 // global constants
84
85 extern const idx some_idx;
86 extern type_info const & typeid_idx;
87
88 // macros
89
90 #define ex_to_idx(X) (static_cast<idx const &>(*(X).bp))
91
92 // other functions
93
94 typedef vector<ex> exvector;
95
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);
104
105 #endif // ndef __GINAC_IDX_H__

Christian Bauer">Christian Bauer
ViewVC Help
Powered by ViewVC 1.1.15