90 return fpoly.
mpCache !=
nullptr;
93 #define ASSERT_CACHE_EQUAL( _cacheA, _cacheB ) assert( _cacheA == nullptr || _cacheB == nullptr || _cacheA == _cacheB )
95 #define ASSERT_CACHE_REF_LEGAL( _fp ) assert( (_fp.pCache() == nullptr) == (_fp.cacheRef() == CACHE::NO_REF) )
102 template<
typename P1>
113 template<
typename P1>
125 template<
typename P1>
133 explicit FactorizedPolynomial(
const P& _polynomial,
const std::shared_ptr<CACHE>&,
bool _polyNormalized =
false );
224 return content().factorization();
230 if(
content().mpPolynomial ==
nullptr )
236 return *
content().mpPolynomial;
303 result +=
factor.first.size();
345 template<
typename C = CoeffType, EnableIf<is_subset_of_rationals_type<C>> = dummy>
355 template<
typename C = CoeffType, EnableIf<is_subset_of_rationals_type<C>> = dummy>
378 return content().factorizedTrivially();
389 content().gatherVariables( _vars );
394 std::set<Variable> vars;
441 return content().factorization().begin()->first.single_variable();
470 template<
bool gatherCoeff>
473 template<
bool gatherCoeff>
479 std::map<Variable, VarInfo<FactorizedPolynomial<P>>> resultVarInfos;
480 for(
const auto& varViPair : vi )
482 const auto& varI = varViPair.second;
484 resultVarInfos.insert( resultVarInfos.end(), std::make_pair( varViPair.first, std::move( viFactorized ) ) );
498 for(
const auto& varViPair : vi )
500 const auto& varI = varViPair.second;
501 std::map<unsigned,FactorizedPolynomial<P>> coeffs;
502 for(
const auto& expCoeffPair : varI.coeffs() )
504 if( expCoeffPair.second.is_constant() )
514 result.insert( result.
end(), std::make_pair( varViPair.first, std::move( viFactorized ) ) );
559 template<
typename C = CoeffType, EnableIf<is_field_type<C>> = dummy>
582 template<
typename C = CoeffType, EnableIf<is_field_type<C>> = dummy>
591 static std::shared_ptr<CACHE>
chooseCache( std::shared_ptr<CACHE> _pCacheA, std::shared_ptr<CACHE> _pCacheB )
593 if ( _pCacheA !=
nullptr )
597 assert( _pCacheB !=
nullptr );
606 template<
typename P1>
675 std::string
toString(
bool _infix =
true,
bool _friendlyVarNames =
true )
const;
683 template<
typename P1>
691 template<
typename P1>
699 template<
typename P1>
707 template<
typename P1>
717 template<
typename P1>
726 template<
typename P1>
733 template<
typename P1>
737 template <
typename P1>
740 template <
typename P1>
743 template <
typename P1>
746 template <
typename P1>
749 template <
typename P1>
752 template <
typename P1>
759 template <
typename P>
767 template <
typename P>
787 template <
typename P>
802 template <
typename P>
805 template <
typename P>
808 template <
typename P>
823 template <
typename P>
826 template <
typename P>
829 return !(_lhs == _rhs);
832 template <
typename P>
835 return !(_lhs == _rhs);
847 template <
typename P>
850 template <
typename P>
853 template <
typename P>
868 template <
typename P>
871 return !(_rhs < _lhs);
874 template <
typename P>
877 return !(_rhs < _lhs);
880 template <
typename P>
883 return !(_rhs < _lhs);
895 template <
typename P>
901 template <
typename P>
907 template <
typename P>
922 template <
typename P>
928 template <
typename P>
934 template <
typename P>
949 template <
typename P>
952 template <
typename P>
955 template <
typename P>
958 return std::move(_rhs + _lhs);
970 template <
typename P>
973 template <
typename P>
976 template <
typename P>
979 return std::move( -_rhs + _lhs );
991 template <
typename P>
994 template <
typename P>
997 template <
typename P>
1000 return std::move(_rhs * _lhs);
1003 template <
typename P>
1014 template<
typename P>
1015 struct hash<
carl::FactorizedPolynomial<P>>
1019 return _factPoly.
hash();
carl is the main namespace for the library.
bool operator>(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
Interval< Number > operator/(const Interval< Number > &lhs, const Number &rhs)
Operator for the division of an interval and a number.
Interval< Number > operator+(const Interval< Number > &lhs, const Interval< Number > &rhs)
Operator for the addition of two intervals.
bool operator<(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
Interval< Number > operator*(const Interval< Number > &lhs, const Interval< Number > &rhs)
Operator for the multiplication of two intervals.
typename UnderlyingNumberType< P >::type Coeff
Interval< Number > operator-(const Interval< Number > &rhs)
Unary minus.
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)
P computePolynomial(const FactorizedPolynomial< P > &_fpoly)
Obtains the polynomial (representation) of this factorized polynomial.
std::map< Pol, uint > Factors
Definiteness
Regarding a polynomial as a function , its definiteness gives information about the codomain .
VarsInfo< MultivariatePolynomial< Coeff, Ordering, Policies > > vars_info(const MultivariatePolynomial< Coeff, Ordering, Policies > &poly, bool collect_coeff=false)
bool is_one(const Interval< Number > &i)
Check if this interval is a point-interval containing 1.
A Variable represents an algebraic variable that can be used throughout carl.
T type
A type associated with the type.
This class represents a univariate polynomial with coefficients of an arbitrary type.
A strongly typed pair encoding the result of a division, being a quotient and a remainder.
friend FactorizedPolynomial< P1 > quotient(const FactorizedPolynomial< P1 > &_fpolyA, const FactorizedPolynomial< P1 > &_fpolyB)
Calculates the quotient of the polynomials.
void strengthenActivity() const
size_t complexity() const
bool factorizedTrivially() const
void setCoefficient(CoeffType coeff) const
Set coefficient.
FactorizedPolynomial(const FactorizedPolynomial< P > &)
typename P::MonomType MonomType
Type of the monomials within the terms.
std::shared_ptr< CACHE > mpCache
The cache in which the actual content of this factorized polynomial is stored.
bool divideBy(const FactorizedPolynomial< P > &_divisor, FactorizedPolynomial< P > &_quotient) const
Divides the polynomial by another polynomial.
UnivariatePolynomial< FactorizedPolynomial< P > > toUnivariatePolynomial(Variable _var) const
FactorizedPolynomial< P > pow(unsigned _exp) const
Raise polynomial to the power.
FactorizedPolynomial< P > quotient(const FactorizedPolynomial< P > &_fdivisor) const
Calculates the quotient.
typename UnderlyingNumberType< CoeffType >::type NumberType
Number type within the coefficients.
friend FactorizedPolynomial< P1 > operator-(const FactorizedPolynomial< P1 > &_lhs, const typename FactorizedPolynomial< P1 >::CoeffType &_rhs)
static std::shared_ptr< CACHE > chooseCache(std::shared_ptr< CACHE > _pCacheA, std::shared_ptr< CACHE > _pCacheB)
Choose a non-null cache from two caches.
typename P::TermsType TermsType
std::shared_ptr< CACHE > pCache() const
FactorizedPolynomial< P > divideBy(const CoeffType &_divisor) const
Divides the polynomial by the given coefficient.
FactorizedPolynomial< P > & operator-=(const CoeffType &_coef)
const Factorization< P > & factorization() const
const CoeffType & coefficient() const
bool is_linear() const
Checks if the polynomial is linear.
CoeffType coprime_factor() const
FactorizedPolynomial< P > derivative(const carl::Variable &_var, unsigned _nth=1) const
Derivative of the factorized polynomial wrt variable x.
CoeffType lcoeff() const
Returns the coefficient of the leading term.
const PolynomialFactorizationPair< P > & content() const
FactorizedPolynomial(FactorizedPolynomial< P > &&)
CoeffType coprime_factor_without_constant() const
typename IntegralType< NumberType >::type IntNumberType
Integer type associated with the number type.
CoeffType mCoefficient
Co-prime coefficient of the factorization.
std::set< Variable > gatherVariables() const
TermType trailingTerm() const
Gives the last term according to Ordering.
friend Factorization< P1 > commonDivisor(const FactorizedPolynomial< P1 > &_fFactorizationA, const FactorizedPolynomial< P1 > &_fFactorizationB, Factorization< P1 > &_fFactorizationRestA, Factorization< P1 > &_fFactorizationRestB)
Computes the common divisor with rest of two factorizations.
CACHE::Ref cacheRef() const
bool has(Variable _var) const
Definiteness definiteness(bool _fullEffort=true) const
Retrieves information about the definiteness of the polynomial.
FactorizedPolynomial< P > & operator/=(const CoeffType &_coef)
Calculates the quotient.
FactorizedPolynomial(const P &_polynomial, const std::shared_ptr< CACHE > &, bool _polyNormalized=false)
FactorizedPolynomial< P > & operator/=(const FactorizedPolynomial< P > &_fpoly)
Calculates the quotient.
typename P::TermType TermType
Type of the terms.
friend FactorizedPolynomial< P1 > lcm(const FactorizedPolynomial< P1 > &_fpolyA, const FactorizedPolynomial< P1 > &_fpolyB)
Computes the least common multiple of two given polynomials.
FactorizedPolynomial< P > & operator-=(const FactorizedPolynomial< P > &_fpoly)
friend FactorizedPolynomial< P1 > gcd(const FactorizedPolynomial< P1 > &_fpolyA, const FactorizedPolynomial< P1 > &_fpolyB, FactorizedPolynomial< P1 > &_fpolyRestA, FactorizedPolynomial< P1 > &_fpolyRestB)
Determines the greatest common divisor of the two given factorized polynomials.
FactorizedPolynomial< P > & operator*=(const CoeffType &_coef)
friend Coeff< P1 > distributeCoefficients(Factorization< P1 > &_factorization)
Computes the coefficient of the factorization and sets the coefficients of all factors to 1.
FactorizedPolynomial< P > operator-() const
friend bool existsFactorization(const FactorizedPolynomial< P1 > &fpoly)
CACHE::Ref mCacheRef
The reference of the entry in the cache corresponding to this factorized polynomial.
P polynomialWithCoefficient() const
friend P1 computePolynomial(const FactorizedPolynomial< P1 > &_fpoly)
friend FactorizedPolynomial< P1 > operator-(const FactorizedPolynomial< P1 > &_lhs, const FactorizedPolynomial< P1 > &_rhs)
typename P::CoeffType CoeffType
Type of the coefficients.
friend std::pair< FactorizedPolynomial< P1 >, FactorizedPolynomial< P1 > > lazyDiv(const FactorizedPolynomial< P1 > &_fpolyA, const FactorizedPolynomial< P1 > &_fpolyB)
Divides each of the two given factorized polynomials by their common factors of their (partial) facto...
UnivariatePolynomial< CoeffType > toUnivariatePolynomial() const
bool sqrt(FactorizedPolynomial< P > &_result) const
Calculates the square of this factorized polynomial if it is a square.
FactorizedPolynomial(Factorization< P > &&_factorization, const CoeffType &, const std::shared_ptr< CACHE > &)
friend FactorizedPolynomial< P1 > operator*(const FactorizedPolynomial< P1 > &_lhs, const typename FactorizedPolynomial< P1 >::CoeffType &_rhs)
TermType lterm() const
The leading term.
CoeffType constant_part() const
Retrieves the constant term of this polynomial or zero, if there is no constant term.
FactorizedPolynomial< P > & operator+=(const FactorizedPolynomial< P > &_fpoly)
typename P::Policy Policy
Policies for this monomial.
friend FactorizedPolynomial< P1 > gcd(const FactorizedPolynomial< P1 > &_fpolyA, const FactorizedPolynomial< P1 > &_fpolyB)
Determines the greatest common divisor of the two given factorized polynomials.
friend FactorizedPolynomial< P1 > operator*(const FactorizedPolynomial< P1 > &_lhs, const FactorizedPolynomial< P1 > &_rhs)
FactorizedPolynomial(const CoeffType &)
FactorizedPolynomial< P > & operator=(const FactorizedPolynomial< P > &)
Copies the given factorized polynomial.
FactorizedPolynomial(const std::pair< ConstructorOperation, std::vector< FactorizedPolynomial >> &_p)
friend FactorizedPolynomial< P1 > operator+(const FactorizedPolynomial< P1 > &_lhs, const FactorizedPolynomial< P1 > &_rhs)
VarsInfo< FactorizedPolynomial< P > > var_info() const
VarsInfo< FactorizedPolynomial< P > > var_info() const
size_t nr_terms() const
Calculates the number of terms.
bool is_univariate() const
Checks whether only one variable occurs.
friend FactorizedPolynomial< P1 > commonDivisor(const FactorizedPolynomial< P1 > &_fpolyA, const FactorizedPolynomial< P1 > &_fpolyB)
Variable single_variable() const
For terms with exactly one variable, get this variable.
size_t total_degree() const
Calculates the max.
DivisionResult< FactorizedPolynomial< P > > divideBy(const FactorizedPolynomial< P > &_divisor) const
Calculating the quotient and the remainder, such that for a given polynomial p we have p = _divisor *...
friend Factors< FactorizedPolynomial< P1 > > factor(const FactorizedPolynomial< P1 > &_fpoly)
void rehash() const
Updates the hash of the entry in the cache corresponding to this factorized polynomial,...
typename P::OrderedBy OrderedBy
The ordering of the terms.
friend FactorizedPolynomial< P1 > commonMultiple(const FactorizedPolynomial< P1 > &_fpolyA, const FactorizedPolynomial< P1 > &_fpolyB)
std::string toString(bool _infix=true, bool _friendlyVarNames=true) const
friend Factorization< P1 > gcd(const PolynomialFactorizationPair< P1 > &_pfPairA, const PolynomialFactorizationPair< P1 > &_pfPairB, Factorization< P1 > &_restA, Factorization< P1 > &_rest2B, bool &_pfPairARefined, bool &_pfPairBRefined)
VarInfo< FactorizedPolynomial< P > > var_info(Variable _var) const
const P & polynomial() const
FactorizedPolynomial< P > coprime_coefficients() const
void gatherVariables(std::set< carl::Variable > &_vars) const
Iterates through all factors and their terms to find variables occurring in this polynomial.
bool has_constant_term() const
Checks if the polynomial has a constant term that is not zero.
friend FactorizedPolynomial< P1 > operator+(const FactorizedPolynomial< P1 > &_lhs, const typename FactorizedPolynomial< P1 >::CoeffType &_rhs)
FactorizedPolynomial< P > & operator*=(const FactorizedPolynomial< P > &_fpoly)
FactorizedPolynomial< P > & operator+=(const CoeffType &_coef)
size_t operator()(const carl::FactorizedPolynomial< P > &_factPoly) const