GiNaC 1.8.10
relational.h
Go to the documentation of this file.
1
5/*
6 * GiNaC Copyright (C) 1999-2026 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef GINAC_RELATIONAL_H
23#define GINAC_RELATIONAL_H
24
25#include "basic.h"
26#include "ex.h"
27#include "archive.h"
28
29namespace GiNaC {
30
33class relational : public basic
34{
36
37// types
38public:
47
48 // other constructors
49public:
50 relational(const ex & lhs, const ex & rhs, operators oper=equal);
51
52 // functions overriding virtual functions from base classes
53public:
54 unsigned precedence() const override {return 20;}
55 bool info(unsigned inf) const override;
56 size_t nops() const override;
57 ex op(size_t i) const override;
58 ex map(map_function & f) const override;
59 ex subs(const exmap & m, unsigned options = 0) const override;
60
62 void archive(archive_node& n) const override;
64 void read_archive(const archive_node& n, lst& syms) override;
65 ex canonical() const;
66
67protected:
68 ex eval_ncmul(const exvector & v) const override;
69 bool match_same_type(const basic & other) const override;
70 unsigned return_type() const override;
71 return_type_t return_type_tinfo() const override;
72 unsigned calchash() const override;
73
74 // new virtual functions which can be overridden by derived classes
75protected:
76 void do_print(const print_context & c, unsigned level) const;
77 void do_print_python_repr(const print_python_repr & c, unsigned level) const;
78
79public:
80 ex lhs() const { return lh; }
81 ex rhs() const { return rh; }
82
83 // non-virtual functions in this class
84private:
85 // For conversions to Boolean, as would be used in an if conditional,
86 // implicit conversions from bool to int have a large number of
87 // undesirable side effects. The following safe_bool type enables
88 // use of relational objects in conditionals without those side effects
90 void nonnull() {};
91 };
92
93 typedef void (safe_bool_helper::*safe_bool)();
94
95 safe_bool make_safe_bool(bool) const;
96
97public:
98 operator safe_bool() const;
99 safe_bool operator!() const;
100
101// member variables
102
103protected:
107};
109
110// utility functions
111
112// inlined functions for efficiency
114{
115 return make_safe_bool(!static_cast<bool>(*this));
116}
117
118} // namespace GiNaC
119
120#endif // ndef GINAC_RELATIONAL_H
Archiving of GiNaC expressions.
#define GINAC_DECLARE_UNARCHIVER(classname)
Helper macros to register a class with (un)archiving (a.k.a.
Definition archive.h:218
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:48
This class holds archived versions of GiNaC expressions (class ex).
Definition archive.h:254
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
Definition basic.h:104
Wrapper template for making GiNaC classes out of STL containers.
Definition container.h:72
Lightweight wrapper for GiNaC's symbolic objects.
Definition ex.h:72
Base class for print_contexts.
Definition print.h:101
Context for python-parsable output.
Definition print.h:137
This class holds a relation consisting of two expressions and a logical relation between them.
Definition relational.h:34
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
void(safe_bool_helper::* safe_bool)()
Definition relational.h:93
safe_bool make_safe_bool(bool) const
ex rhs() const
Definition relational.h:81
ex op(size_t i) const override
Return operand/member at position i.
ex canonical() const
Returns an equivalent relational with zero right-hand side.
void do_print(const print_context &c, unsigned level) const
unsigned precedence() const override
Return relative operator precedence (for parenthezing output).
Definition relational.h:54
return_type_t return_type_tinfo() const override
bool match_same_type(const basic &other) const override
Returns true if the attributes of two objects are similar enough for a match.
unsigned calchash() const override
Compute the hash value of an object and if it makes sense to store it in the objects status_flags,...
ex lhs() const
Definition relational.h:80
unsigned return_type() const override
ex eval_ncmul(const exvector &v) const override
safe_bool operator!() const
Definition relational.h:113
ex map(map_function &f) const override
Construct new expression by applying the specified function to all sub-expressions (one level only,...
void do_print_python_repr(const print_python_repr &c, unsigned level) const
bool info(unsigned inf) const override
Information about the object.
size_t nops() const override
Number of operands/members.
ex subs(const exmap &m, unsigned options=0) const override
Substitute a set of objects by arbitrary expressions.
Interface to GiNaC's light-weight expression handles.
unsigned options
Definition factor.cpp:2473
size_t n
Definition factor.cpp:1431
size_t c
Definition factor.cpp:756
exset syms
Definition factor.cpp:2427
mvec m
Definition factor.cpp:757
Definition add.cpp:35
std::map< ex, ex, ex_is_less > exmap
Definition basic.h:49
std::vector< ex > exvector
Definition basic.h:47
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Definition registrar.h:151
Function object for map().
Definition basic.h:84
To distinguish between different kinds of non-commutative objects.
Definition registrar.h:42

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