11 #include <unsupported/Eigen/Polynomials> 19 struct increment_if_fixed_size
28 template<
typename _Scalar,
int _Deg>
31 typedef internal::increment_if_fixed_size<_Deg> Dim;
32 typedef Matrix<_Scalar,Dim::ret,1> PolynomialType;
33 typedef Matrix<_Scalar,_Deg,1> EvalRootsType;
35 PolynomialType pols(deg+1);
36 EvalRootsType roots = EvalRootsType::Random(deg);
39 EvalRootsType evr( deg );
40 for(
int i=0; i<roots.size(); ++i ){
43 bool evalToZero = evr.isZero( test_precision<_Scalar>() );
45 cerr << evr.transpose() << endl; }
51 CALL_SUBTEST_2( (realRoots_to_monicPolynomial_test<_Scalar,2>(2)) );
52 CALL_SUBTEST_3( (realRoots_to_monicPolynomial_test<_Scalar,3>(3)) );
53 CALL_SUBTEST_4( (realRoots_to_monicPolynomial_test<_Scalar,4>(4)) );
54 CALL_SUBTEST_5( (realRoots_to_monicPolynomial_test<_Scalar,5>(5)) );
55 CALL_SUBTEST_6( (realRoots_to_monicPolynomial_test<_Scalar,6>(6)) );
56 CALL_SUBTEST_7( (realRoots_to_monicPolynomial_test<_Scalar,7>(7)) );
57 CALL_SUBTEST_8( (realRoots_to_monicPolynomial_test<_Scalar,17>(17)) );
59 CALL_SUBTEST_9( (realRoots_to_monicPolynomial_test<_Scalar,Dynamic>(
60 internal::random<int>(18,26) )) );
66 template<
typename _Scalar,
int _Deg>
69 typedef internal::increment_if_fixed_size<_Deg> Dim;
70 typedef Matrix<_Scalar,Dim::ret,1> PolynomialType;
71 typedef Matrix<_Scalar,_Deg,1> EvalRootsType;
73 PolynomialType pols(deg+1);
74 EvalRootsType roots = EvalRootsType::Random(deg);
78 _Scalar Max = roots.array().abs().maxCoeff();
79 _Scalar
min = roots.array().abs().minCoeff();
80 bool eval = (M >= Max) && (m <= min);
83 cerr <<
"Roots: " << roots << endl;
84 cerr <<
"Bounds: (" << m <<
", " << M <<
")" << endl;
85 cerr <<
"Min,Max: (" << min <<
", " << Max <<
")" << endl;
92 CALL_SUBTEST_2( (CauchyBounds<_Scalar,2>(2)) );
93 CALL_SUBTEST_3( (CauchyBounds<_Scalar,3>(3)) );
94 CALL_SUBTEST_4( (CauchyBounds<_Scalar,4>(4)) );
95 CALL_SUBTEST_5( (CauchyBounds<_Scalar,5>(5)) );
96 CALL_SUBTEST_6( (CauchyBounds<_Scalar,6>(6)) );
97 CALL_SUBTEST_7( (CauchyBounds<_Scalar,7>(7)) );
98 CALL_SUBTEST_8( (CauchyBounds<_Scalar,17>(17)) );
100 CALL_SUBTEST_9( (CauchyBounds<_Scalar,Dynamic>(
101 internal::random<int>(18,26) )) );
106 for(
int i = 0; i < g_repeat; i++)
108 realRoots_to_monicPolynomial_scalar<double>();
109 realRoots_to_monicPolynomial_scalar<float>();
110 CauchyBounds_scalar<double>();
111 CauchyBounds_scalar<float>();
T poly_eval(const Polynomials &poly, const T &x)
void test_polynomialutils()
void realRoots_to_monicPolynomial_test(int deg)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
void roots_to_monicPolynomial(const RootVector &rv, Polynomial &poly)
void realRoots_to_monicPolynomial_scalar()
void CauchyBounds_scalar()
void CauchyBounds(int deg)
NumTraits< typename Polynomial::Scalar >::Real cauchy_min_bound(const Polynomial &poly)
NumTraits< typename Polynomial::Scalar >::Real cauchy_max_bound(const Polynomial &poly)