]> www.ginac.de Git - ginac.git/blob - ginac/relational.h
Fixed 50 percent of the bugs on Alex' list. More, soon...
[ginac.git] / ginac / relational.h
1 /** @file relational.h
2  *
3  *  Interface to relations between expressions.
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_RELATIONAL_H__
23 #define __GINAC_RELATIONAL_H__
24
25 #include <ginac/basic.h>
26 #include <ginac/ex.h>
27
28 /** This class holds a relation consisting of two expressions and a logical
29  *  relation between them. */
30 class relational : public basic
31 {
32
33 // types
34 public:
35     enum operators { equal,
36            not_equal,
37            less,
38            less_or_equal,
39            greater,
40            greater_or_equal
41     };
42     
43 // member functions
44
45     // default constructor, destructor, copy constructor assignment operator and helpers
46 public:
47     relational();
48     ~relational();
49     relational(relational const & other);
50     relational const & operator=(relational const & other);
51 protected:
52     void copy(relational const & other);
53     void destroy(bool call_parent);
54
55     // other constructors
56 public:
57     relational(ex const & lhs, ex const & rhs, operators oper=equal);
58     
59     // functions overriding virtual functions from bases classes
60 public:
61     basic * duplicate() const;
62     void printraw(ostream & os) const;
63     void print(ostream & os, unsigned upper_precedence=0) const;
64     void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const;
65     bool info(unsigned inf) const;
66     int nops() const;
67     ex & let_op(int const i);
68     ex eval(int level=0) const;
69     ex evalf(int level=0) const;
70     ex simplify_ncmul(exvector const & v) const;
71 protected:
72     int compare_same_type(basic const & other) const;
73     unsigned return_type(void) const;
74     unsigned return_type_tinfo(void) const;
75
76     // new virtual functions which can be overridden by derived classes
77     // none
78
79     // non-virtual functions in this class
80 public:
81     operator bool(void) const;
82     
83 // member variables
84     
85 protected:
86     ex lh;
87     ex rh;
88     operators o;
89     static unsigned precedence;
90 };
91
92 // global constants
93
94 extern const relational some_relational;
95 extern type_info const & typeid_relational;
96
97 #define ex_to_relational(X) static_cast<relational const &>(*(X).bp)
98
99 #endif // ndef __GINAC_RELATIONAL_H__
100
101