NumCpp  2.9.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Iteration.hpp
Go to the documentation of this file.
1 #pragma once
34 
35 #include <functional>
36 
38 #include "NumCpp/Core/Types.hpp"
39 
40 namespace nc
41 {
42  namespace roots
43  {
44  //================================================================================
45  // Class Description:
47  class Iteration
48  {
49  public:
50  //============================================================================
51  // Method Description:
56  explicit Iteration(double epsilon) noexcept :
57  epsilon_(epsilon)
58  {
59  }
60 
61  //============================================================================
62  // Method Description:
68  Iteration(double epsilon, uint32 maxNumIterations) noexcept :
69  epsilon_(epsilon),
70  maxNumIterations_(maxNumIterations)
71  {
72  }
73 
74  //============================================================================
75  // Method Description:
78  virtual ~Iteration() noexcept = default;
79 
80  //============================================================================
81  // Method Description:
86  uint32 numIterations() const noexcept
87  {
88  return numIterations_;
89  }
90 
91  protected:
92  //============================================================================
93  // Method Description:
96  void resetNumberOfIterations() noexcept
97  {
98  numIterations_ = 0;
99  }
100 
101  //============================================================================
102  // Method Description:
108  {
109  ++numIterations_;
111  {
113  "Maximum number of iterations has been reached; no root has been found within epsilon.");
114  }
115  }
116 
117  //====================================Attributes==============================
118  const double epsilon_;
121  };
122  } // namespace roots
123 } // namespace nc
#define THROW_RUNTIME_ERROR(msg)
Definition: Error.hpp:38
ABC for iteration classes to derive from.
Definition: Iteration.hpp:48
Iteration(double epsilon) noexcept
Definition: Iteration.hpp:56
virtual ~Iteration() noexcept=default
const double epsilon_
Definition: Iteration.hpp:118
Iteration(double epsilon, uint32 maxNumIterations) noexcept
Definition: Iteration.hpp:68
uint32 numIterations_
Definition: Iteration.hpp:120
void resetNumberOfIterations() noexcept
Definition: Iteration.hpp:96
uint32 maxNumIterations_
Definition: Iteration.hpp:119
uint32 numIterations() const noexcept
Definition: Iteration.hpp:86
void incrementNumberOfIterations()
Definition: Iteration.hpp:107
Definition: Coordinate.hpp:45
std::uint32_t uint32
Definition: Types.hpp:40