carl  24.04
Computer ARithmetic Library
Operations.h
Go to the documentation of this file.
1 #pragma once
2 
4 
7 
8 #include <functional>
9 
10 namespace carl {
11 
12 template<typename T>
13 struct is_ran_type : std::false_type {};
14 
15 /* operators */
16 
17 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
18 Number is_root_of(const UnivariatePolynomial<Number>& p, const RAN& value) {
19  return sgn(value, p) == Sign::ZERO;
20 }
21 
22 
23 /* comparison operators */
24 
25 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
26 bool operator==(const RAN& lhs, const Number& rhs) {
27  return compare(lhs, rhs, Relation::EQ);
28 }
29 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
30 bool operator!=(const RAN& lhs, const Number& rhs) {
31  return compare(lhs, rhs, Relation::NEQ);
32 }
33 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
34 bool operator<=(const RAN& lhs, const Number& rhs) {
35  return compare(lhs, rhs, Relation::LEQ);
36 }
37 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
38 bool operator>=(const RAN& lhs, const Number& rhs) {
39  return compare(lhs, rhs, Relation::GEQ);
40 }
41 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
42 bool operator<(const RAN& lhs, const Number& rhs) {
43  return compare(lhs, rhs, Relation::LESS);
44 }
45 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
46 bool operator>(const RAN& lhs, const Number& rhs) {
47  return compare(lhs, rhs, Relation::GREATER);
48 }
49 
50 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
51 bool operator==(const Number& lhs, const RAN& rhs) {
52  return rhs == lhs;
53 }
54 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
55 bool operator!=(const Number& lhs, const RAN& rhs) {
56  return rhs != lhs;
57 }
58 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
59 bool operator<=(const Number& lhs, const RAN& rhs) {
60  return rhs >= lhs;
61 }
62 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
63 bool operator>=(const Number& lhs, const RAN& rhs) {
64  return rhs <= lhs;
65 }
66 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
67 bool operator<(const Number& lhs, const RAN& rhs) {
68  return rhs > lhs;
69 }
70 template<typename Number, typename RAN, typename = std::enable_if_t<is_ran_type<RAN>::value>>
71 bool operator>(const Number& lhs, const RAN& rhs) {
72  return rhs < lhs;
73 }
74 
75 template<typename RAN, EnableIf<is_ran_type<RAN>> = dummy>
76 bool operator==(const RAN& lhs, const RAN& rhs) {
77  return compare(lhs, rhs, Relation::EQ);
78 }
79 template<typename RAN, EnableIf<is_ran_type<RAN>> = dummy>
80 bool operator!=(const RAN& lhs, const RAN& rhs) {
81  return compare(lhs, rhs, Relation::NEQ);
82 }
83 template<typename RAN, EnableIf<is_ran_type<RAN>> = dummy>
84 bool operator<=(const RAN& lhs, const RAN& rhs) {
85  return compare(lhs, rhs, Relation::LEQ);
86 }
87 template<typename RAN, EnableIf<is_ran_type<RAN>> = dummy>
88 bool operator>=(const RAN& lhs, const RAN& rhs) {
89  return compare(lhs, rhs, Relation::GEQ);
90 }
91 template<typename RAN, EnableIf<is_ran_type<RAN>> = dummy>
92 bool operator<(const RAN& lhs, const RAN& rhs) {
93  return compare(lhs, rhs, Relation::LESS);
94 }
95 template<typename RAN, EnableIf<is_ran_type<RAN>> = dummy>
96 bool operator>(const RAN& lhs, const RAN& rhs) {
97  return compare(lhs, rhs, Relation::GREATER);
98 }
99 
100 }
carl is the main namespace for the library.
bool operator>(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
bool operator<(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
signed compare(const BasicConstraint< Pol > &_constraintA, const BasicConstraint< Pol > &_constraintB)
Compares _constraintA with _constraintB.
Definition: Comparison.h:25
@ ZERO
Indicates that .
bool is_root_of(const UnivariatePolynomial< Coeff > &p, const Coeff &value)
Definition: Evaluation.h:62
Sign sgn(const Number &n)
Obtain the sign of the given number.
Definition: Sign.h:54
bool operator!=(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
bool operator<=(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
bool operator==(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
bool operator>=(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
@ GREATER
Definition: SignCondition.h:15