| 1 |
#include <cmath> |
| 2 |
|
| 3 |
#include "stk_middle_mesh/newton_scalar.hpp" |
| 4 |
#include "gtest/gtest.h" |
| 5 |
|
| 6 |
namespace stk { |
| 7 |
namespace middle_mesh { |
| 8 |
namespace impl { |
| 9 |
|
| 10 |
TEST(NewtonScalar, Solve) |
| 11 |
{ |
| 12 |
auto func = [](double x) { return std::pow(x, 4); }; |
| 13 |
auto jac = [](double x) { return 4 * std::pow(x, 3); }; |
| 14 |
|
| 15 |
double x0 = 2; |
| 16 |
|
| 17 |
utils::impl::NewtonScalar newton(1e-60, 1000); |
| 18 |
newton.solve(func, jac, x0); |
| 19 |
|
| 20 |
EXPECT_NEAR(x0, 0.0, 1e-13); |
| 21 |
} |
| 22 |
|
| 23 |
} // namespace impl |
| 24 |
} // namespace middle_mesh |
| 25 |
} // namespace stk |