Added a testcase for newton's method
This commit is contained in:
parent
5b3bef64b1
commit
4c08fdc90d
@ -18,3 +18,6 @@ target_link_libraries(testkd2 ${tolink})
|
||||
|
||||
add_executable(testDelaunay testDelaunay.cpp)
|
||||
target_link_libraries(testDelaunay ${tolink})
|
||||
|
||||
add_executable(testNewton testNewton.cpp)
|
||||
target_link_libraries(testNewton ${tolink})
|
@ -1,6 +1,8 @@
|
||||
#ifndef _COSMOTOOL_NEWTON_HPP
|
||||
#define _COSMOTOOL_NEWTON_HPP
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace CosmoTool
|
||||
{
|
||||
template<typename T, typename FunT>
|
||||
@ -12,7 +14,7 @@ namespace CosmoTool
|
||||
|
||||
x = xold - f_x/df_x;
|
||||
|
||||
while (abs(xold-x) > residual)
|
||||
while (std::abs(xold-x) > residual)
|
||||
{
|
||||
xold = x;
|
||||
f_x = function.eval(x);
|
||||
|
Loading…
Reference in New Issue
Block a user