mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-07 08:41:11 +00:00
Imported Healpix, cfitsio, cosmotool. Added cmake tool to build dependencies (cfitsio, hdf5, netcdf, boost, healpix, gsl, ..). Adjusted CMakeLists.txt
This commit is contained in:
parent
4bfb62f177
commit
51f6798f88
241 changed files with 243806 additions and 0 deletions
30
external/cosmotool/src/newton.hpp
vendored
Normal file
30
external/cosmotool/src/newton.hpp
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
#ifndef _COSMOTOOL_NEWTON_HPP
|
||||
#define _COSMOTOOL_NEWTON_HPP
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace CosmoTool
|
||||
{
|
||||
template<typename T, typename FunT>
|
||||
T newtonSolver(T x0, FunT function, double residual = 1e-3)
|
||||
{
|
||||
T x, xold = x0;
|
||||
T f_x = function.eval(x0);
|
||||
T df_x = function.derivative(x0);
|
||||
|
||||
x = xold - f_x/df_x;
|
||||
|
||||
while (std::abs(xold-x) > residual)
|
||||
{
|
||||
xold = x;
|
||||
f_x = function.eval(x);
|
||||
df_x = function.derivative(x);
|
||||
x = xold - f_x/df_x;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue