![]() |
UtilsLite
Utilities for C++ programming
|
Class for managing and computing the Sturm sequence associated with a polynomial. More...
#include <Utils_Poly.hh>
Public Types | |
using | Integer = int |
using | Poly_t = Poly<Real> |
using | dvec_t = Eigen::Matrix<Real,Eigen::Dynamic,1> |
using | Interval |
Public Member Functions | |
Sturm () | |
void | build (Poly_t const &p) |
Constructs the Sturm sequence for a given polynomial. | |
Integer | length () const |
Retrieves the length of the stored Sturm sequence. | |
Poly_t const & | get (Integer i) const |
Retrieves the i-th polynomial of the stored Sturm sequence. | |
Integer | sign_variations (Real x, bool &on_root) const |
Computes the sign variations of the stored Sturm sequence at a given point \( x \). | |
Integer | separate_roots (Real a, Real b) |
Computes subintervals containing single roots within a given interval \( [a,b] \). | |
Integer | separate_roots () |
Compute an interval \( [a,b] \) that contains all real roots and separate them into subintervals. | |
Integer | n_roots () const |
Returns the number of roots found by the Sturm sequence. | |
Real | a () const |
Returns the left boundary \( a \) of the interval \( [a,b] \) containing all real roots. | |
Real | b () const |
Returns the right boundary \( b \) of the interval \( [a,b] \) containing all real roots. | |
Interval const & | get_interval (Integer i) const |
Returns the i-th interval containing a single root. | |
void | refine_roots () |
Refine the roots of the polynomial after the intervals have been separated. | |
dvec_t const & | roots () const |
Returns a vector containing the computed roots after refinement. | |
Class for managing and computing the Sturm sequence associated with a polynomial.
The Sturm class is dedicated to the construction and manipulation of the Sturm sequence for a given polynomial \( p(x) \). This sequence is instrumental in real algebraic geometry, as it provides crucial insights into the behavior of polynomial roots. Specifically, it enables users to ascertain the number of real roots within specific intervals and helps identify the locations of distinct real roots.
Real | The data type used for the polynomial coefficients, typically a floating-point type. |
Features
using Utils::Sturm< Real >::dvec_t = Eigen::Matrix<Real,Eigen::Dynamic,1> |
using Utils::Sturm< Real >::Integer = int |
using Utils::Sturm< Real >::Interval |
using Utils::Sturm< Real >::Poly_t = Poly<Real> |
|
inline |
|
inline |
Returns the left boundary \( a \) of the interval \( [a,b] \) containing all real roots.
This method returns the left endpoint of the interval that contains all real roots of the polynomial after using methods such as separate_roots()
.
|
inline |
Returns the right boundary \( b \) of the interval \( [a,b] \) containing all real roots.
This method returns the right endpoint of the interval that contains all real roots of the polynomial after using methods such as separate_roots()
.
void Utils::Sturm< Real >::build | ( | Poly_t const & | p | ) |
Constructs the Sturm sequence for a given polynomial.
This method takes a polynomial \( p(x) \) as input and builds its corresponding Sturm sequence.
p | The polynomial \( p(x) \) for which to build the Sturm sequence. This should be a valid polynomial of type Poly_t. |
|
inline |
Retrieves the i-th polynomial of the stored Sturm sequence.
This method returns a constant reference to the polynomial at the specified index i
in the Sturm sequence. The index is zero-based, meaning that get(0)
will return the first polynomial in the sequence, get(1)
will return the second, and so on.
i | The index of the polynomial to retrieve from the Sturm sequence. It must be a valid index (0 <= i < length of Sturm sequence). |
std::out_of_range | if the index i is out of bounds. |
Example
|
inline |
Returns the i-th interval containing a single root.
After separating the roots of the polynomial, this method provides access to the specific interval that contains the i-th root. The interval is defined by a structure Interval
, which holds the boundaries of the interval.
i | The index of the interval (root). |
|
inline |
Retrieves the length of the stored Sturm sequence.
This method returns the number of polynomials in the Sturm sequence that has been built for the corresponding polynomial.
|
inline |
Returns the number of roots found by the Sturm sequence.
After running root separation (e.g., using separate_roots()
), this method returns the number of intervals found, each containing a single root.
Example
void Utils::Sturm< Real >::refine_roots | ( | ) |
Refine the roots of the polynomial after the intervals have been separated.
This method computes the roots within the intervals determined by the separate_roots()
method. After separating the intervals that contain the roots, this method applies a refinement procedure to accurately locate the roots within those intervals.
Example
|
inline |
Returns a vector containing the computed roots after refinement.
This method returns the refined roots of the polynomial that were computed using the refine_roots()
method. The roots are stored in a vector of type dvec_t
.
Example
Integer Utils::Sturm< Real >::separate_roots | ( | ) |
Compute an interval \( [a,b] \) that contains all real roots and separate them into subintervals.
This method uses Cauchy's bounds to compute an interval \( [-B, B] \), where \( B \) is an upper bound for the absolute values of the real roots of the polynomial. It then isolates each root by dividing this interval into subintervals, each containing exactly one root. It returns the number of subintervals (i.e., roots) found.
The method leverages Cauchy's bound \( B = 1 + \frac{\max |a_i|}{|a_n|} \), where \( a_n \) is the leading coefficient and \( a_i \) are the other coefficients, to determine an interval that contains all real roots.
Example
This method can be used to isolate all real roots of a polynomial in a simple, automated fashion.
Integer Utils::Sturm< Real >::separate_roots | ( | Real | a, |
Real | b ) |
Computes subintervals containing single roots within a given interval \( [a,b] \).
This method identifies subintervals within the specified range \( [a,b] \) that each contain a single root of the polynomial. It performs root isolation and returns the number of such intervals found.
a | The lower bound of the interval. |
b | The upper bound of the interval. |
example
Integer Utils::Sturm< Real >::sign_variations | ( | Real | x, |
bool & | on_root ) const |
Computes the sign variations of the stored Sturm sequence at a given point \( x \).
This method evaluates the sign variations of the polynomials in the stored Sturm sequence at the specified point \( x \). The number of sign variations can help determine the number of real roots of the polynomial in the interval up to \( x \).
x | The point at which to compute the sign variations of the Sturm sequence. |
on_root | A reference to a boolean variable that will be set to true if \( x \) is a root of the first polynomial of the Sturm sequence; otherwise, it will be false. |
Example