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