You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
635 B

  1. #include <unsupported/Eigen/Polynomials>
  2. #include <iostream>
  3. using namespace Eigen;
  4. using namespace std;
  5. int main()
  6. {
  7. Vector4d roots = Vector4d::Random();
  8. cout << "Roots: " << roots.transpose() << endl;
  9. Eigen::Matrix<double,5,1> polynomial;
  10. roots_to_monicPolynomial( roots, polynomial );
  11. cout << "Polynomial: ";
  12. for( int i=0; i<4; ++i ){ cout << polynomial[i] << ".x^" << i << "+ "; }
  13. cout << polynomial[4] << ".x^4" << endl;
  14. Vector4d evaluation;
  15. for( int i=0; i<4; ++i ){
  16. evaluation[i] = poly_eval( polynomial, roots[i] ); }
  17. cout << "Evaluation of the polynomial at the roots: " << evaluation.transpose();
  18. }