16 template<
typename Poly>
21 assert( radicandEvaluated.is_constant() );
22 Rational radicandValue = radicandEvaluated.constant_part();
23 assert( radicandValue >= 0 );
25 assert( factorEvaluated.is_constant() );
26 Rational factorValue = factorEvaluated.constant_part();
28 assert( constantPartEvaluated.is_constant() );
29 Rational constantPartValue = constantPartEvaluated.constant_part();
31 assert( denomEvaluated.is_constant() );
32 Rational denomValue = denomEvaluated.constant_part();
41 assert( factorValue != 0 );
43 sqrtExValue = carl::rationalize<Rational>( dbSqrt ) ;
47 if( factorValue > 0 && (sqrtExValue*sqrtExValue) > radicandValue )
50 dbSqrt = std::nextafter( dbSqrt, -INFINITY );
51 sqrtExValue = carl::rationalize<Rational>( dbSqrt );
52 assert( !((sqrtExValue*sqrtExValue) > radicandValue) );
54 else if( factorValue < 0 && (sqrtExValue*sqrtExValue) < radicandValue )
57 dbSqrt = std::nextafter( dbSqrt, INFINITY );
58 sqrtExValue = carl::rationalize<Rational>( dbSqrt );
59 assert( !((sqrtExValue*sqrtExValue) < radicandValue) );
64 if( factorValue < 0 && (sqrtExValue*sqrtExValue) > radicandValue )
67 dbSqrt = std::nextafter( dbSqrt, -INFINITY );
68 sqrtExValue = carl::rationalize<Rational>( dbSqrt );
69 assert( !((sqrtExValue*sqrtExValue) > radicandValue) );
71 else if( factorValue > 0 && (sqrtExValue*sqrtExValue) < radicandValue )
74 dbSqrt = std::nextafter( dbSqrt, INFINITY );
75 sqrtExValue = carl::rationalize<Rational>( dbSqrt );
76 assert( !((sqrtExValue*sqrtExValue) < radicandValue) );
80 return std::make_pair(((constantPartValue + factorValue * sqrtExValue) / denomValue),
exact);
carl is the main namespace for the library.
bool sqrt_exact(const cln::cl_RA &a, cln::cl_RA &b)
Calculate the square root of a fraction if possible.
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)
Interval< Number > sqrt(const Interval< Number > &i)
Coeff substitute(const Monomial &m, const std::map< Variable, Coeff > &substitutions)
Applies the given substitutions to a monomial.
double to_double(const cln::cl_RA &n)
Converts the given fraction to a double.
Bitset exact(SetCover &sc)
Exact "heuristic": Computes a minimum set cover.
A Variable represents an algebraic variable that can be used throughout carl.
const Poly & radicand() const
const Poly & constant_part() const
const Poly & denominator() const
typename UnderlyingNumberType< Poly >::type Rational
const Poly & factor() const