7 template<
typename Poly>
14 assert( !denomEvaluated.is_constant() || !
carl::is_zero( denomEvaluated.constant_part() ) );
16 if( radicandEvaluated.is_constant() &&
carl::sqrt_exact( radicandEvaluated.constant_part(), sqrtExValue ) )
18 return SqrtEx<Poly>(Poly(constantPartEvaluated + factorEvaluated * sqrtExValue),
20 std::move(denomEvaluated),
23 return SqrtEx( std::move(constantPartEvaluated), std::move(factorEvaluated), std::move(denomEvaluated), std::move(radicandEvaluated) );
33 template<
typename Poly>
36 if( !_substituteIn.has( _varToSubstitute ) )
50 auto varInfo =
carl::var_info(_substituteIn, _varToSubstitute,
true);
51 const auto& coeffs = varInfo.coeffs();
53 auto coeff = coeffs.begin();
60 sk.push_back( sk.back() * _substituteBy.
denominator() );
66 rk.push_back( _substituteBy.
factor() );
74 rk.push_back( rk.back() * _substituteBy.
constant_part() + qk.at( i - 1 ) * _substituteBy.
factor() );
79 if( coeff->first == 0 )
81 resConstantPart += sk.back() * coeff->second;
84 for( ; coeff != coeffs.end(); ++coeff )
86 resConstantPart += coeff->second * qk.at( coeff->first - 1 ) * sk.at( lastDegree - coeff->first );
87 resFactor += coeff->second * rk.at( coeff->first - 1 ) * sk.at( lastDegree - coeff->first );
89 return SqrtEx( resConstantPart, resFactor, sk.back(), _substituteBy.
radicand() );
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.
VarInfo< MultivariatePolynomial< Coeff, Ordering, Policies > > var_info(const MultivariatePolynomial< Coeff, Ordering, Policies > &poly, const Variable var, bool collect_coeff=false)
Coeff substitute(const Monomial &m, const std::map< Variable, Coeff > &substitutions)
Applies the given substitutions to a monomial.
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