]> www.ginac.de Git - ginac.git/blob - ginac/clifford.h
68a81a452e19b9ec1bcb8a44e930862807213599
[ginac.git] / ginac / clifford.h
1 /** @file clifford.h
2  *
3  *  Interface to GiNaC's clifford objects.
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_CLIFFORD_H__
23 #define __GINAC_CLIFFORD_H__
24
25 #include <string>
26
27 /** Base class for clifford object */
28 class clifford : public indexed
29 {
30 // member functions
31
32     // default constructor, destructor, copy constructor assignment operator and helpers
33 public:
34     clifford();
35     ~clifford();
36     clifford(clifford const & other);
37     clifford const & operator=(clifford const & other);
38 protected:
39     void copy(clifford const & other); 
40     void destroy(bool call_parent);
41
42     // other constructors
43 public:
44     explicit clifford(string const & initname);
45
46     // functions overriding virtual functions from base classes
47 public:
48     basic * duplicate() const;
49     void printraw(ostream & os) const;
50     void printtree(ostream & os, unsigned indent) const;
51     void print(ostream & os, unsigned upper_precedence=0) const;
52     void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
53     bool info(unsigned inf) const;
54 protected:
55     int compare_same_type(basic const & other) const;
56     ex simplify_ncmul(exvector const & v) const;
57     unsigned calchash(void) const;
58
59     // new virtual functions which can be overridden by derived classes
60     // none
61     
62     // non-virtual functions in this class
63 public:
64     void setname(string const & n);
65 private:
66     string & autoname_prefix(void);
67
68 // member variables
69
70 protected:
71     string name;
72     unsigned serial; // unique serial number for comparision
73 private:
74     static unsigned next_serial;
75 };
76
77 // global constants
78
79 extern const clifford some_clifford;
80 extern type_info const & typeid_clifford;
81
82 // macros
83
84 #define ex_to_clifford(X) static_cast<clifford const &>(*(X).bp)
85
86 #endif // ndef __GINAC_CLIFFORD_H__
87
88