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