NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
Iteration.hpp
Go to the documentation of this file.
1
33#pragma once
34
35#include <functional>
36
38#include "NumCpp/Core/Types.hpp"
39
40namespace nc::roots
41{
42 //================================================================================
43 // Class Description:
46 {
47 public:
48 //============================================================================
49 // Method Description:
54 explicit Iteration(double epsilon) noexcept :
55 epsilon_(epsilon)
56 {
57 }
58
59 //============================================================================
60 // Method Description:
66 Iteration(double epsilon, uint32 maxNumIterations) noexcept :
67 epsilon_(epsilon),
68 maxNumIterations_(maxNumIterations)
69 {
70 }
71
72 //============================================================================
73 // Method Description:
76 virtual ~Iteration() noexcept = default;
77
78 //============================================================================
79 // Method Description:
84 [[nodiscard]] uint32 numIterations() const noexcept
85 {
86 return numIterations_;
87 }
88
89 protected:
90 //============================================================================
91 // Method Description:
95 {
97 }
98
99 //============================================================================
100 // Method Description:
104 {
107 {
109 "Maximum number of iterations has been reached; no root has been found within epsilon.");
110 }
111 }
112
113 //====================================Attributes==============================
114 const double epsilon_;
117 };
118} // namespace nc::roots
#define THROW_RUNTIME_ERROR(msg)
Definition: Error.hpp:40
ABC for iteration classes to derive from.
Definition: Iteration.hpp:46
Iteration(double epsilon) noexcept
Definition: Iteration.hpp:54
virtual ~Iteration() noexcept=default
const double epsilon_
Definition: Iteration.hpp:114
Iteration(double epsilon, uint32 maxNumIterations) noexcept
Definition: Iteration.hpp:66
uint32 numIterations_
Definition: Iteration.hpp:116
void resetNumberOfIterations() noexcept
Definition: Iteration.hpp:94
uint32 maxNumIterations_
Definition: Iteration.hpp:115
uint32 numIterations() const noexcept
Definition: Iteration.hpp:84
void incrementNumberOfIterations()
Definition: Iteration.hpp:103
Definition: Bisection.hpp:43
std::uint32_t uint32
Definition: Types.hpp:40