GiNaC 1.8.4
relational.h
Go to the documentation of this file.
1
5/*
6 * GiNaC Copyright (C) 1999-2022 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
30namespace GiNaC {
31
34class relational : public basic
35{
37
38// types
39public:
40 enum operators {
47 };
48
49 // other constructors
50public:
51 relational(const ex & lhs, const ex & rhs, operators oper=equal);
52
53 // functions overriding virtual functions from base classes
54public:
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 ex canonical() const;
67
68protected:
69 ex eval_ncmul(const exvector & v) const override;
70 bool match_same_type(const basic & other) const override;
71 unsigned return_type() const override;
72 return_type_t return_type_tinfo() const override;
73 unsigned calchash() const override;
74
75 // new virtual functions which can be overridden by derived classes
76protected:
77 void do_print(const print_context & c, unsigned level) const;
78 void do_print_python_repr(const print_python_repr & c, unsigned level) const;
79
80public:
81 ex lhs() const { return lh; }
82 ex rhs() const { return rh; }
83
84 // non-virtual functions in this class
85private:
86 // For conversions to Boolean, as would be used in an if conditional,
87 // implicit conversions from bool to int have a large number of
88 // undesirable side effects. The following safe_bool type enables
89 // use of relational objects in conditionals without those side effects
91 void nonnull() {};
92 };
93
94 typedef void (safe_bool_helper::*safe_bool)();
95
96 safe_bool make_safe_bool(bool) const;
97
98public:
99 operator safe_bool() const;
100 safe_bool operator!() const;
101
102// member variables
103
104protected:
108};
110
111// utility functions
112
113// inlined functions for efficiency
115{
116 return make_safe_bool(!static_cast<bool>(*this));
117}
118
119} // namespace GiNaC
120
121#endif // ndef GINAC_RELATIONAL_H
Archiving of GiNaC expressions.
Interface to GiNaC's ABC.
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Definition: archive.h:49
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
Definition: basic.h:105
Wrapper template for making GiNaC classes out of STL containers.
Definition: container.h:73
Lightweight wrapper for GiNaC's symbolic objects.
Definition: ex.h:72
Base class for print_contexts.
Definition: print.h:103
Context for python-parsable output.
Definition: print.h:139
This class holds a relation consisting of two expressions and a logical relation between them.
Definition: relational.h:35
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
Definition: relational.cpp:59
void archive(archive_node &n) const override
Save (a.k.a.
Definition: relational.cpp:71
void(safe_bool_helper::* safe_bool)()
Definition: relational.h:94
safe_bool make_safe_bool(bool) const
Definition: relational.cpp:299
ex rhs() const
Definition: relational.h:82
relational(const ex &lhs, const ex &rhs, operators oper=equal)
Definition: relational.cpp:52
ex op(size_t i) const override
Return operand/member at position i.
Definition: relational.cpp:160
ex canonical() const
Returns an equivalent relational with zero right-hand side.
Definition: relational.cpp:353
void do_print(const print_context &c, unsigned level) const
Definition: relational.cpp:112
unsigned precedence() const override
Return relative operator precedence (for parenthezing output).
Definition: relational.h:55
return_type_t return_type_tinfo() const override
Definition: relational.cpp:244
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
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
ex lhs() const
Definition: relational.h:81
unsigned return_type() const override
Definition: relational.cpp:238
ex eval_ncmul(const exvector &v) const override
Definition: relational.cpp:190
safe_bool operator!() const
Definition: relational.h:114
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
void do_print_python_repr(const print_python_repr &c, unsigned level) const
Definition: relational.cpp:123
bool info(unsigned inf) const override
Information about the object.
Definition: relational.cpp:134
size_t nops() const override
Number of operands/members.
Definition: relational.cpp:155
ex subs(const exmap &m, unsigned options=0) const override
Substitute a set of objects by arbitrary expressions.
Definition: relational.cpp:179
Interface to GiNaC's light-weight expression handles.
unsigned options
Definition: factor.cpp:2480
size_t n
Definition: factor.cpp:1463
size_t c
Definition: factor.cpp:770
exset syms
Definition: factor.cpp:2434
mvec m
Definition: factor.cpp:771
Definition: add.cpp:38
std::map< ex, ex, ex_is_less > exmap
Definition: basic.h:50
GINAC_DECLARE_UNARCHIVER(add)
std::vector< ex > exvector
Definition: basic.h:48
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Definition: registrar.h:153
Function object for map().
Definition: basic.h:85
To distinguish between different kinds of non-commutative objects.
Definition: registrar.h:44

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