12 Vector5d roots = Vector5d::Random();
13 cout <<
"Roots: " << roots.transpose() << endl;
18 cout <<
"Complex roots: " << psolve.roots().transpose() << endl;
20 std::vector<double> realRoots;
21 psolve.realRoots( realRoots );
23 cout <<
"Real roots: " << mapRR.transpose() << endl;
26 cout <<
"Illustration of the convergence problem with the QR algorithm: " << endl;
27 cout <<
"---------------------------------------------------------------" << endl;
29 hardCase_polynomial <<
30 -0.957, 0.9219, 0.3516, 0.9453, -0.4023, -0.5508, -0.03125;
31 cout <<
"Hard case polynomial defined by floats: " << hardCase_polynomial.
transpose() << endl;
33 cout <<
"Complex roots: " << psolvef.roots().transpose() << endl;
35 for(
int i=0;
i<6; ++
i ){ evals[
i] =
std::abs(
poly_eval( hardCase_polynomial, psolvef.roots()[i] ) ); }
36 cout <<
"Norms of the evaluations of the polynomial at the roots: " << evals.
transpose() << endl << endl;
38 cout <<
"Using double's almost always solves the problem for small degrees: " << endl;
39 cout <<
"-------------------------------------------------------------------" << endl;
41 cout <<
"Complex roots: " << psolve6d.roots().transpose() << endl;
42 for(
int i=0;
i<6; ++
i )
44 std::complex<float> castedRoot( psolve6d.roots()[i].real(), psolve6d.roots()[i].imag() );
47 cout <<
"Norms of the evaluations of the polynomial at the roots: " << evals.
transpose() << endl << endl;
50 cout <<
"The last root in float then in double: " << psolvef.roots()[5] <<
"\t" << psolve6d.roots()[5] << endl;
51 std::complex<float> castedRoot( psolve6d.roots()[5].real(), psolve6d.roots()[5].imag() );
52 cout <<
"Norm of the difference: " <<
std::abs( psolvef.roots()[5] - castedRoot ) << endl;
TransposeReturnType transpose()
T poly_eval(const Polynomials &poly, const T &x)
void roots_to_monicPolynomial(const RootVector &rv, Polynomial &poly)
adouble abs(const adouble &x)