summaryrefslogtreecommitdiffhomepage
path: root/eigen/unsupported/doc/examples/PolynomialSolver1.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-03-03 21:09:10 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-03-03 21:10:13 +0100
commitf0238cfb6997c4acfc2bd200de7295f3fa36968f (patch)
treeb215183760e4f615b9c1dabc1f116383b72a1b55 /eigen/unsupported/doc/examples/PolynomialSolver1.cpp
parent543edd372a5193d04b3de9f23c176ab439e51b31 (diff)
don't index Eigen
Diffstat (limited to 'eigen/unsupported/doc/examples/PolynomialSolver1.cpp')
-rw-r--r--eigen/unsupported/doc/examples/PolynomialSolver1.cpp53
1 files changed, 0 insertions, 53 deletions
diff --git a/eigen/unsupported/doc/examples/PolynomialSolver1.cpp b/eigen/unsupported/doc/examples/PolynomialSolver1.cpp
deleted file mode 100644
index cd777a4..0000000
--- a/eigen/unsupported/doc/examples/PolynomialSolver1.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <unsupported/Eigen/Polynomials>
-#include <vector>
-#include <iostream>
-
-using namespace Eigen;
-using namespace std;
-
-int main()
-{
- typedef Matrix<double,5,1> Vector5d;
-
- Vector5d roots = Vector5d::Random();
- cout << "Roots: " << roots.transpose() << endl;
- Eigen::Matrix<double,6,1> polynomial;
- roots_to_monicPolynomial( roots, polynomial );
-
- PolynomialSolver<double,5> psolve( polynomial );
- cout << "Complex roots: " << psolve.roots().transpose() << endl;
-
- std::vector<double> realRoots;
- psolve.realRoots( realRoots );
- Map<Vector5d> mapRR( &realRoots[0] );
- cout << "Real roots: " << mapRR.transpose() << endl;
-
- cout << endl;
- cout << "Illustration of the convergence problem with the QR algorithm: " << endl;
- cout << "---------------------------------------------------------------" << endl;
- Eigen::Matrix<float,7,1> hardCase_polynomial;
- hardCase_polynomial <<
- -0.957, 0.9219, 0.3516, 0.9453, -0.4023, -0.5508, -0.03125;
- cout << "Hard case polynomial defined by floats: " << hardCase_polynomial.transpose() << endl;
- PolynomialSolver<float,6> psolvef( hardCase_polynomial );
- cout << "Complex roots: " << psolvef.roots().transpose() << endl;
- Eigen::Matrix<float,6,1> evals;
- for( int i=0; i<6; ++i ){ evals[i] = std::abs( poly_eval( hardCase_polynomial, psolvef.roots()[i] ) ); }
- cout << "Norms of the evaluations of the polynomial at the roots: " << evals.transpose() << endl << endl;
-
- cout << "Using double's almost always solves the problem for small degrees: " << endl;
- cout << "-------------------------------------------------------------------" << endl;
- PolynomialSolver<double,6> psolve6d( hardCase_polynomial.cast<double>() );
- cout << "Complex roots: " << psolve6d.roots().transpose() << endl;
- for( int i=0; i<6; ++i )
- {
- std::complex<float> castedRoot( psolve6d.roots()[i].real(), psolve6d.roots()[i].imag() );
- evals[i] = std::abs( poly_eval( hardCase_polynomial, castedRoot ) );
- }
- cout << "Norms of the evaluations of the polynomial at the roots: " << evals.transpose() << endl << endl;
-
- cout.precision(10);
- cout << "The last root in float then in double: " << psolvef.roots()[5] << "\t" << psolve6d.roots()[5] << endl;
- std::complex<float> castedRoot( psolve6d.roots()[5].real(), psolve6d.roots()[5].imag() );
- cout << "Norm of the difference: " << std::abs( psolvef.roots()[5] - castedRoot ) << endl;
-}