]> www.ginac.de Git - ginac.git/blob - ginac/indexed.h
7b425ba0697495fa76372e86178489c7cc5daeaf
[ginac.git] / ginac / indexed.h
1 /** @file indexed.h
2  *
3  *  Interface to GiNaC's index carrying objects. */
4
5 /*
6  *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef __GINAC_INDEXED_H__
24 #define __GINAC_INDEXED_H__
25
26 #include <string>
27 #include <ginac/exprseq.h>
28
29 #ifndef NO_GINAC_NAMESPACE
30 namespace GiNaC {
31 #endif // ndef NO_GINAC_NAMESPACE
32
33 /** Base class for non-commutative indexed objects */
34 class indexed : public exprseq
35 {
36 // member functions
37
38     // default constructor, destructor, copy constructor assignment operator and helpers
39 public:
40     indexed();
41     ~indexed();
42     indexed(indexed const & other);
43     indexed const & operator=(indexed const & other);
44 protected:
45     void copy(indexed const & other); 
46     void destroy(bool call_parent);
47
48     // other constructors
49 public:
50     indexed(ex const & i1);
51     indexed(ex const & i1, ex const & i2);
52     indexed(ex const & i1, ex const & i2, ex const & i3);
53     indexed(ex const & i1, ex const & i2, ex const & i3, ex const & i4);
54     indexed(exvector const & iv);
55     indexed(exvector * iv);
56
57     // functions overriding virtual functions from base classes
58 public:
59     basic * duplicate() const;
60     void printraw(ostream & os) const;
61     void printtree(ostream & os, unsigned indent) const;
62     void print(ostream & os, unsigned upper_precedence=0) const;
63     void printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const;
64     bool info(unsigned inf) const;
65     ex diff(symbol const & s) const;
66     exvector get_indices(void) const;
67 protected:
68     int compare_same_type(basic const & other) const;
69     bool is_equal_same_type(basic const & other) const;
70     unsigned return_type(void) const;
71     unsigned return_type_tinfo(void) const;
72     ex thisexprseq(exvector const & v) const;
73     ex thisexprseq(exvector * vp) const;
74
75     // new virtual functions which can be overridden by derived classes
76     // none
77     
78     // non-virtual functions in this class
79 protected:
80     void printrawindices(ostream & os) const;
81     void printtreeindices(ostream & os, unsigned indent) const;
82     void printindices(ostream & os) const;
83     bool all_of_type_idx(void) const;
84
85 // member variables
86     // none
87 };
88
89 // global constants
90
91 extern const indexed some_indexed;
92 extern type_info const & typeid_indexed;
93
94 // utility functions
95 inline const indexed &ex_to_indexed(const ex &e)
96 {
97         return static_cast<const indexed &>(*e.bp);
98 }
99
100 #ifndef NO_GINAC_NAMESPACE
101 } // namespace GiNaC
102 #endif // ndef NO_GINAC_NAMESPACE
103
104 #endif // ndef __GINAC_INDEXED_H__