GiNaC  1.8.0
relational.h
Go to the documentation of this file.
1 
5 /*
6  * GiNaC Copyright (C) 1999-2020 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef GINAC_RELATIONAL_H
24 #define GINAC_RELATIONAL_H
25 
26 #include "basic.h"
27 #include "ex.h"
28 #include "archive.h"
29 
30 namespace GiNaC {
31 
34 class relational : public basic
35 {
37 
38 // types
39 public:
40  enum operators {
47  };
48 
49  // other constructors
50 public:
51  relational(const ex & lhs, const ex & rhs, operators oper=equal);
52 
53  // functions overriding virtual functions from base classes
54 public:
55  unsigned precedence() const override {return 20;}
56  bool info(unsigned inf) const override;
57  size_t nops() const override;
58  ex op(size_t i) const override;
59  ex map(map_function & f) const override;
60  ex subs(const exmap & m, unsigned options = 0) const override;
61 
63  void archive(archive_node& n) const override;
65  void read_archive(const archive_node& n, lst& syms) override;
66 protected:
67  ex eval_ncmul(const exvector & v) const override;
68  bool match_same_type(const basic & other) const override;
69  unsigned return_type() const override;
70  return_type_t return_type_tinfo() const override;
71  unsigned calchash() const override;
72 
73  // new virtual functions which can be overridden by derived classes
74 protected:
75  void do_print(const print_context & c, unsigned level) const;
76  void do_print_python_repr(const print_python_repr & c, unsigned level) const;
77 
78 public:
79  ex lhs() const { return lh; }
80  ex rhs() const { return rh; }
81 
82  // non-virtual functions in this class
83 private:
84  // For conversions to Boolean, as would be used in an if conditional,
85  // implicit conversions from bool to int have a large number of
86  // undesirable side effects. The following safe_bool type enables
87  // use of relational objects in conditionals without those side effects
89  void nonnull() {};
90  };
91 
92  typedef void (safe_bool_helper::*safe_bool)();
93 
94  safe_bool make_safe_bool(bool) const;
95 
96 public:
97  operator safe_bool() const;
98  safe_bool operator!() const;
99 
100 // member variables
101 
102 protected:
106 };
108 
109 // utility functions
110 
111 // inlined functions for efficiency
113 {
114  return make_safe_bool(!static_cast<bool>(*this));
115 }
116 
117 } // namespace GiNaC
118 
119 #endif // ndef GINAC_RELATIONAL_H
GiNaC::relational::make_safe_bool
safe_bool make_safe_bool(bool) const
Definition: relational.cpp:299
GiNaC::print_python_repr
Context for python-parsable output.
Definition: print.h:139
GiNaC::relational::info
bool info(unsigned inf) const override
Information about the object.
Definition: relational.cpp:134
GiNaC::relational::do_print
void do_print(const print_context &c, unsigned level) const
Definition: relational.cpp:112
GiNaC::relational::safe_bool_helper::nonnull
void nonnull()
Definition: relational.h:89
GiNaC::relational::archive
void archive(archive_node &n) const override
Save (a.k.a.
Definition: relational.cpp:71
GiNaC::relational::safe_bool_helper
Definition: relational.h:88
GiNaC::relational::operators
operators
Definition: relational.h:40
GiNaC::relational::subs
ex subs(const exmap &m, unsigned options=0) const override
Substitute a set of objects by arbitrary expressions.
Definition: relational.cpp:179
GiNaC::relational
This class holds a relation consisting of two expressions and a logical relation between them.
Definition: relational.h:35
GiNaC::map_function
Function object for map().
Definition: basic.h:85
GiNaC::print_context
Base class for print_contexts.
Definition: print.h:103
GiNaC::relational::return_type_tinfo
return_type_t return_type_tinfo() const override
Definition: relational.cpp:244
GiNaC::relational::greater_or_equal
@ greater_or_equal
Definition: relational.h:46
GiNaC::exvector
std::vector< ex > exvector
Definition: basic.h:46
GiNaC::relational::relational
relational(const ex &lhs, const ex &rhs, operators oper=equal)
Definition: relational.cpp:52
GiNaC::relational::less_or_equal
@ less_or_equal
Definition: relational.h:44
GiNaC::archive_node
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Definition: archive.h:49
GiNaC::relational::less
@ less
Definition: relational.h:43
options
unsigned options
Definition: factor.cpp:2480
GiNaC::GINAC_DECLARE_UNARCHIVER
GINAC_DECLARE_UNARCHIVER(add)
m
mvec m
Definition: factor.cpp:771
GiNaC::relational::not_equal
@ not_equal
Definition: relational.h:42
GiNaC::relational::o
operators o
Definition: relational.h:105
GiNaC
Definition: add.cpp:38
syms
exset syms
Definition: factor.cpp:2434
GiNaC::relational::lh
ex lh
Definition: relational.h:103
GINAC_DECLARE_REGISTERED_CLASS
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Definition: registrar.h:153
GiNaC::relational::equal
@ equal
Definition: relational.h:41
GiNaC::ex
Lightweight wrapper for GiNaC's symbolic objects.
Definition: ex.h:72
GiNaC::relational::lhs
ex lhs() const
Definition: relational.h:79
GiNaC::relational::match_same_type
bool match_same_type(const basic &other) const override
Returns true if the attributes of two objects are similar enough for a match.
Definition: relational.cpp:230
GiNaC::relational::operator!
safe_bool operator!() const
Definition: relational.h:112
ex.h
Interface to GiNaC's light-weight expression handles.
GiNaC::relational::return_type
unsigned return_type() const override
Definition: relational.cpp:238
GiNaC::relational::op
ex op(size_t i) const override
Return operand/member at position i.
Definition: relational.cpp:160
GiNaC::relational::map
ex map(map_function &f) const override
Construct new expression by applying the specified function to all sub-expressions (one level only,...
Definition: relational.cpp:167
GiNaC::return_type_t
To distinguish between different kinds of non-commutative objects.
Definition: registrar.h:44
GiNaC::container
Wrapper template for making GiNaC classes out of STL containers.
Definition: container.h:73
GiNaC::relational::rhs
ex rhs() const
Definition: relational.h:80
GiNaC::relational::eval_ncmul
ex eval_ncmul(const exvector &v) const override
Definition: relational.cpp:190
c
size_t c
Definition: factor.cpp:770
GiNaC::exmap
std::map< ex, ex, ex_is_less > exmap
Definition: basic.h:50
GiNaC::relational::rh
ex rh
Definition: relational.h:104
archive.h
Archiving of GiNaC expressions.
basic.h
Interface to GiNaC's ABC.
GiNaC::relational::read_archive
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
Definition: relational.cpp:59
n
size_t n
Definition: factor.cpp:1463
GiNaC::relational::safe_bool
void(safe_bool_helper::* safe_bool)()
Definition: relational.h:92
GiNaC::relational::greater
@ greater
Definition: relational.h:45
GiNaC::basic
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
Definition: basic.h:105
GiNaC::relational::nops
size_t nops() const override
Number of operands/members.
Definition: relational.cpp:155
GiNaC::relational::calchash
unsigned calchash() const override
Compute the hash value of an object and if it makes sense to store it in the objects status_flags,...
Definition: relational.cpp:250
GiNaC::relational::precedence
unsigned precedence() const override
Return relative operator precedence (for parenthezing output).
Definition: relational.h:55
GiNaC::relational::do_print_python_repr
void do_print_python_repr(const print_python_repr &c, unsigned level) const
Definition: relational.cpp:123

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.