58 Dekker(
const double epsilon, std::function<
double(
double)>
f) noexcept :
72 Dekker(
const double epsilon,
const uint32 maxNumIterations, std::function<
double(
double)>
f) noexcept :
92 double solve(
double a,
double b)
99 checkAndFixAlgorithmCriteria(a, b, fa, fb);
106 const double s = calculateSecant(b, fb, lastB, lastFb);
107 const double m = calculateBisection(a, b);
111 b = useSecantMethod(b, s, m) ? s : m;
116 if (fa * fb > 0 && fb * lastFb < 0)
122 checkAndFixAlgorithmCriteria(a, b, fa, fb);
132 const std::function<double(
double)> f_;
143 static void checkAndFixAlgorithmCriteria(
double &a,
double &b,
double &fa,
double &fb)
noexcept
146 if (std::fabs(fa) < std::fabs(fb))
163 static double calculateSecant(
double b,
double fb,
double lastB,
double lastFb)
noexcept
167 return b - fb * (b - lastB) / (fb - lastFb);
178 static double calculateBisection(
double a,
double b)
noexcept
180 return 0.5 * (a + b);
192 static bool useSecantMethod(
double b,
double s,
double m)
noexcept
195 return (b > m && s > m && s < b) || (b < m && s > b && s < m);
Definition: Dekker.hpp:49
~Dekker() override=default
double solve(double a, double b)
Definition: Dekker.hpp:92
Dekker(const double epsilon, std::function< double(double)> f) noexcept
Definition: Dekker.hpp:58
Dekker(const double epsilon, const uint32 maxNumIterations, std::function< double(double)> f) noexcept
Definition: Dekker.hpp:72
ABC for iteration classes to derive from.
Definition: Iteration.hpp:46
Iteration(double epsilon) noexcept
Definition: Iteration.hpp:54
const double epsilon_
Definition: Iteration.hpp:114
void resetNumberOfIterations() noexcept
Definition: Iteration.hpp:94
void incrementNumberOfIterations()
Definition: Iteration.hpp:103
dtype f(GeneratorType &generator, dtype inDofN, dtype inDofD)
Definition: f.hpp:56
Definition: Bisection.hpp:43
void swap(NdArray< dtype > &inArray1, NdArray< dtype > &inArray2) noexcept
Definition: swap.hpp:42
std::uint32_t uint32
Definition: Types.hpp:40