📄 test_cpoly_roots.cxx
字号:
#include <vnl/vnl_real_polynomial.h>
#include <vnl/algo/vnl_cpoly_roots.h>
#include <testlib/testlib_test.h>
void test_cpoly_roots()
{
const double coeffs[] = {6, 5, 4, 3, 2, 1};
vnl_vector<double> a(coeffs, 6);
vnl_vector<double> monic( (a/a[0]).extract(a.size()-1,1) );
vnl_cpoly_roots roots( monic, 0.0*monic );
testlib_test_assert( "Number of solutions", roots.solns.size() == monic.size() );
// Evaluate results
vnl_real_polynomial f(a);
for (int i = 0; i < f.degree(); ++i)
testlib_test_assert("Root residual", vcl_abs(f.evaluate(roots.solns[i])) < 1e-12);
}
TESTMAIN(test_cpoly_roots);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -