carl  24.04
Computer ARithmetic Library
term.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <carl-arith/vs/SqrtEx.h>
4 
5 namespace carl::vs {
6 
7 enum class TermType {
8  NORMAL,
12 };
13 
14 template<class Poly>
15 class Term {
16 private:
17  /// The substitution type.
19  /// A square root expression.
20  std::optional<SqrtEx<Poly>> m_sqrt_ex;
21 
22 public:
25 
26  static Term normal(const SqrtEx<Poly>& sqrt_ex) {
27  return Term(TermType::NORMAL, sqrt_ex);
28  }
29 
30  static Term plus_eps(const SqrtEx<Poly>& sqrt_ex) {
32  }
33 
34  static Term minus_infty() {
35  return Term(TermType::MINUS_INFINITY, std::nullopt);
36  }
37 
38  static Term plus_infty() {
39  return Term(TermType::PLUS_INFINITY, std::nullopt);
40  }
41 
42  bool is_normal() const {
43  return m_type == TermType::NORMAL;
44  }
45 
46  bool is_plus_eps() const {
48  }
49 
50  bool is_minus_infty() const {
52  }
53 
54  bool is_plus_infty() const {
56  }
57 
58  const SqrtEx<Poly> sqrt_ex() const {
59  return *m_sqrt_ex;
60  }
61 
62  TermType type() const {
63  return m_type;
64  }
65 
66  bool operator==(const Term&) const;
67 };
68 
69 template<class Poly>
70 std::ostream& operator<<(std::ostream& os, const Term<Poly>& s);
71 
72 } // namespace carl::vs
73 
74 namespace std {
75 template<class Poly>
76 struct hash<carl::vs::Term<Poly>> {
77 public:
78  size_t operator()(const carl::vs::Term<Poly>& term) const {
79  return ((hash<carl::SqrtEx<Poly>>()(term.sqrt_ex()) << 5) ^ term.type());
80  }
81 };
82 } // namespace std
83 
84 #include "term.tpp"
carl is the main namespace for the library.
TermType
Definition: term.h:7
std::ostream & operator<<(std::ostream &os, const Term< Poly > &s)
const SqrtEx< Poly > sqrt_ex() const
Definition: term.h:58
bool is_plus_eps() const
Definition: term.h:46
bool is_normal() const
Definition: term.h:42
bool is_plus_infty() const
Definition: term.h:54
TermType m_type
The substitution type.
Definition: term.h:18
std::optional< SqrtEx< Poly > > m_sqrt_ex
A square root expression.
Definition: term.h:20
static Term normal(const SqrtEx< Poly > &sqrt_ex)
Definition: term.h:26
TermType type() const
Definition: term.h:62
static Term plus_eps(const SqrtEx< Poly > &sqrt_ex)
Definition: term.h:30
bool is_minus_infty() const
Definition: term.h:50
bool operator==(const Term &) const
static Term minus_infty()
Definition: term.h:34
Term(TermType type, std::optional< SqrtEx< Poly >> sqrt_ex)
Definition: term.h:23
static Term plus_infty()
Definition: term.h:38
size_t operator()(const carl::vs::Term< Poly > &term) const
Definition: term.h:78