16 #include "../common/Operations.h"
17 #include "../common/NumberOperations.h"
20 #include <boost/logic/tribool.hpp>
24 template<
typename Number>
28 template<
typename Num>
31 template<
typename Num>
34 template<
typename Num,
typename Poly>
37 template<
typename Num>
40 template<
typename Num>
43 template<
typename Num>
46 template<
typename Num>
49 template<
typename Num>
52 template<
typename Num>
55 template<
typename Num>
58 template<
typename Num>
61 template<
typename Num>
64 template<
typename Num>
81 assert(
interval.is_point_interval());
98 CARL_LOG_DEBUG(
"carl.ran.interval",
"Interval contains 0 or integer");
108 CARL_LOG_DEBUG(
"carl.ran.interval",
"Interval does not define a zero");
185 CARL_LOG_DEBUG(
"carl.ran.interval",
"Creating (" << p <<
"," << i <<
")");
240 template<
typename Number>
245 template<
typename Number>
249 template<
typename Number>
253 template<
typename Number>
266 template<
typename Number>
270 assert(lower < upper);
279 template<
typename Number>
283 assert(lower < upper);
292 template<
typename Number>
296 template<
typename Number>
301 template<
typename Number>
306 template<
typename Number>
311 template<
typename Number>
316 template<
typename Number>
331 template<
typename Number>
340 template<
typename Number>
352 template<
typename Number>
358 assert((variations == -1) || (variations == 0) || (variations == 1));
359 switch (variations) {
367 CARL_LOG_ERROR(
"carl.ran.interval",
"Unexpected number of variations, should be -1, 0, 1 but was " << variations);
372 template<
typename Number>
383 template<
typename Number>
385 CARL_LOG_DEBUG(
"carl.ran.interval",
"Compare " << lhs <<
" " << relation <<
" " << rhs);
400 assert(!intersection.is_empty());
403 if (!intersection.is_point_interval()) {
424 CARL_LOG_TRACE(
"carl.ran.interval",
"gcd(lhs,rhs) has a zero in the common interval");
429 CARL_LOG_TRACE(
"carl.ran.interval",
"gcd(lhs,rhs) has no zero in the common interval");
432 CARL_LOG_TRACE(
"carl.ran.interval",
"Refine until intervals become disjoint");
453 template<
typename Number>
474 template<
typename Num>
479 return os <<
"(NR " << ran.
value() <<
")";
483 template<
typename Number>
486 template<
typename Number>
491 template<
typename Number>
492 struct hash<
carl::IntRepRealAlgebraicNumber<Number>> {
#define CARL_LOG_ERROR(channel, msg)
#define CARL_LOG_TRACE(channel, msg)
#define CARL_LOG_DEBUG(channel, msg)
carl is the main namespace for the library.
MultivariatePolynomial< C, O, P > squareFreePart(const MultivariatePolynomial< C, O, P > &polynomial)
std::vector< UnivariatePolynomial< Coeff > > sturm_sequence(const UnivariatePolynomial< Coeff > &p, const UnivariatePolynomial< Coeff > &q)
Computes the sturm sequence of two polynomials.
const T & derivative(const T &t, Variable, std::size_t n=1)
Computes the n'th derivative of a number, which is either the number itself (for n = 0) or zero.
Interval< Number > ceil(const Interval< Number > &_in)
Method which returns the next larger integer of the passed number or the number itself,...
Number sample(const Interval< Number > &i, bool includingBounds=true)
Searches for some point in this interval, preferably near the midpoint and with a small representatio...
Interval< Number > abs(const Interval< Number > &_in)
Method which returns the absolute value of the passed number.
Interval< Number > floor(const Interval< Number > &_in)
Method which returns the next smaller integer of this number or the number itself,...
int count_real_roots(const std::vector< UnivariatePolynomial< Coefficient >> &seq, const Interval< Coefficient > &i)
Calculate the number of real roots of a polynomial within a given interval based on a sturm sequence ...
const Number & branching_point(const Number &n)
Number sample_above(const Number &n)
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
cln::cl_I gcd(const cln::cl_I &a, const cln::cl_I &b)
Calculate the greatest common divisor of two integers.
signed compare(const BasicConstraint< Pol > &_constraintA, const BasicConstraint< Pol > &_constraintB)
Compares _constraintA with _constraintB.
Sign
This class represents the sign of a number .
@ NEGATIVE
Indicates that .
@ POSITIVE
Indicates that .
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
bool evaluate(const BasicConstraint< Poly > &c, const Assignment< Number > &m)
UnivariatePolynomial< Coeff > replace_main_variable(const UnivariatePolynomial< Coeff > &p, Variable newVar)
Replaces the main variable in a polynomial.
Number integer_below(const IntRepRealAlgebraicNumber< Number > &n)
Sign sgn(const Number &n)
Obtain the sign of the given number.
Interval< Number > set_intersection(const Interval< Number > &lhs, const Interval< Number > &rhs)
Intersects two intervals in a set-theoretic manner.
Variable fresh_real_variable() noexcept
bool contained_in(const IntRepRealAlgebraicNumber< Number > &n, const Interval< Number > &i)
bool set_have_intersection(const Interval< Number > &lhs, const Interval< Number > &rhs)
bool is_integer(const Interval< Number > &n)
@ WEAK
the given bound is compared by a weak ordering relation
@ STRICT
the given bound is compared by a strict ordering relation
std::map< Variable, T > Assignment
std::size_t hash_all(Args &&... args)
Hashes an arbitrary number of values.
Number sample_below(const Number &n)
std::size_t bitsize(const cln::cl_I &n)
Get the bit size of the representation of a integer.
Number sample_between(const Number &lower, const Number &upper)
Represent a polynomial (in)equality against zero.
A Variable represents an algebraic variable that can be used throughout carl.
The class which contains the interval arithmetic including trigonometric functions.
const Number & upper() const
The getter for the upper boundary of the interval.
bool contains(const Number &val) const
Checks if the interval contains the given value.
const Number & lower() const
The getter for the lower boundary of the interval.
This class represents a univariate polynomial with coefficients of an arbitrary type.
The general-purpose multivariate polynomial class.
IntRepRealAlgebraicNumber(const UnivariatePolynomial< Number > &p, const Interval< Number > &i)
auto & interval_int() const
const auto & value() const
std::optional< Sign > refine_using(const Number &pivot) const
void refine_to_integrality() const
Refines until the number is either numeric or the interval does not contain any integer.
friend Num sample_between(const IntRepRealAlgebraicNumber< Num > &lower, const Num &upper)
static const Variable auxVariable
std::shared_ptr< content > m_content
IntRepRealAlgebraicNumber & operator=(const IntRepRealAlgebraicNumber &n)=default
const auto & interval() const
const auto & polynomial() const
friend Num floor(const IntRepRealAlgebraicNumber< Num > &n)
friend bool compare(const IntRepRealAlgebraicNumber< Num > &, const IntRepRealAlgebraicNumber< Num > &, const Relation)
void set_polynomial(const UnivariatePolynomial< Number > &p, Sign lower_sign) const
friend boost::tribool evaluate(const BasicConstraint< Poly > &, const Assignment< IntRepRealAlgebraicNumber< Num >> &, bool, bool)
friend bool compare(const IntRepRealAlgebraicNumber< Num > &, const Num &, const Relation)
friend std::optional< IntRepRealAlgebraicNumber< Num > > evaluate(MultivariatePolynomial< Num >, const Assignment< IntRepRealAlgebraicNumber< Num >> &, bool)
IntRepRealAlgebraicNumber(const IntRepRealAlgebraicNumber &ran)=default
friend Num sample_above(const IntRepRealAlgebraicNumber< Num > &n)
IntRepRealAlgebraicNumber(IntRepRealAlgebraicNumber &&ran)=default
auto & polynomial_int() const
friend Num sample_between(const Num &lower, const IntRepRealAlgebraicNumber< Num > &upper)
friend Num sample_between(const IntRepRealAlgebraicNumber< Num > &lower, const IntRepRealAlgebraicNumber< Num > &upper)
friend Num branching_point(const IntRepRealAlgebraicNumber< Num > &n)
IntRepRealAlgebraicNumber()
friend Sign sgn(const IntRepRealAlgebraicNumber< Num > &n, const UnivariatePolynomial< Num > &p)
friend Num ceil(const IntRepRealAlgebraicNumber< Num > &n)
IntRepRealAlgebraicNumber & operator=(IntRepRealAlgebraicNumber &&n)=default
Sign refine_internal(const Number &pivot) const
Returns the sign of "interval_int() - pivot": Returns ZERO if pivot is equal to RAN.
friend Num sample_below(const IntRepRealAlgebraicNumber< Num > &n)
static IntRepRealAlgebraicNumber< Number > create_safe(const UnivariatePolynomial< Number > &p, const Interval< Number > &i)
static UnivariatePolynomial< Number > replace_variable(const UnivariatePolynomial< Number > &p)
bool is_consistent() const
IntRepRealAlgebraicNumber(const Number &n)
Sign lower_sign
Sign of polynomial at interval.lower()
content(UnivariatePolynomial< Number > &&p, const Interval< Number > &i)
Interval< Number > interval
content(const Interval< Number > &i)
content(const UnivariatePolynomial< Number > &p, const Interval< Number > &i)
std::optional< UnivariatePolynomial< Number > > polynomial
std::size_t operator()(const carl::IntRepRealAlgebraicNumber< Number > &n) const