⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_rpoly_roots.cxx

📁 InsightToolkit-1.4.0(有大量的优化算法程序)
💻 CXX
字号:
#include <vnl/vnl_real_polynomial.h>
#include <vnl/algo/vnl_rpoly_roots.h>

#include <testlib/testlib_test.h>

void test_rpoly_roots()
{
  double coeffs[] = {5, 4, 3, 2, 1};
  vnl_vector<double> a(coeffs, 5);

  vnl_rpoly_roots roots(a);

  testlib_test_assert("Result sizes", (roots.real().size() == 4) && (roots.imag().size() == 4));
  testlib_test_assert("Complex size", (roots.roots().size() == 4));
  //testlib_test_assert("degree", roots.degree() == 4);

  // Evaluate results
  vnl_real_polynomial p(a);
  for (int i = 0; i < p.degree(); ++i)
    testlib_test_assert("Root residual", vcl_abs(p.evaluate(roots[i])) < 1e-12);
}

TESTMAIN(test_rpoly_roots);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -