18template <
typename T,
bool extrapolation = true>
21template <
typename T,
bool extrapolation = true>
61 return f_data_ptr->operator[](i);
84template <
typename T,
bool extrapolation = true>
90template <
typename T,
bool extrapolation>
93 using size_type = int;
97 std::function<T(T, T,
int)> F = [](T x_min_, T dx_, size_type i) {
return x_min_ + i * dx_; };
101 FixedData(T x_min_, T dx_,
int n_) : x_min(x_min_), dx(dx_), n(n_) {}
102 FixedData(T x_min_, T dx_,
int n_, std::function<T(T, T,
int)> F_) : x_min(x_min_), dx(dx_), n(n_), F(F_) {}
107 if constexpr (!extrapolation)
109 if (i >= n || i < 0) {
110 std::cout << i <<
' ' << n <<
'\n';
111 throw std::out_of_range(
"fixed data is out of range");
115 auto x = F(x_min, dx, i);
121 return F(x_min, dx, i);
132 T
dstep() const noexcept {
return dx; }
137 auto temp_data = *
this;
138 temp_data.x_min = x_current;
139 return temp_data(-1);
145 auto temp_data = *
this;
146 temp_data.x_min = x_current;
147 return temp_data(+1);
157 constexpr auto size() const noexcept {
return static_cast<size_t>(n); }
Definition: FixedData.hpp:23
friend bool operator==(const FixedDataIter &a, const FixedDataIter &b)
Definition: FixedData.hpp:66
const value_type operator*() const
Definition: FixedData.hpp:64
std::input_iterator_tag iterator_category
< For more information, see: https://internalpointers.com/post/writing-custom-iterators-modern-cpp
Definition: FixedData.hpp:25
FixedDataIter & operator++()
Definition: FixedData.hpp:33
value_type * pointer
Definition: FixedData.hpp:28
friend difference_type operator-(const FixedDataIter &a, const FixedDataIter &b)
Definition: FixedData.hpp:74
FixedDataIter(FixedData< T, extrapolation > *const f_data_ptr_, int n_)
Definition: FixedData.hpp:31
FixedDataIter operator++(int)
Definition: FixedData.hpp:39
friend FixedDataIter operator+(const FixedDataIter &a, const int b)
Definition: FixedData.hpp:69
friend bool operator!=(const FixedDataIter &a, const FixedDataIter &b)
Definition: FixedData.hpp:67
value_type operator[](int i)
Definition: FixedData.hpp:59
value_type & reference
Definition: FixedData.hpp:29
FixedDataIter & operator--()
Definition: FixedData.hpp:46
int difference_type
Definition: FixedData.hpp:26
T value_type
Definition: FixedData.hpp:27
FixedDataIter operator--(int)
Definition: FixedData.hpp:52
Definition: FixedData.hpp:92
T next(T x_current) noexcept
Definition: FixedData.hpp:142
T operator[](int i) const
Definition: FixedData.hpp:104
constexpr FixedDataIter< T, extrapolation > begin() noexcept
Definition: FixedData.hpp:124
T front() const
Definition: FixedData.hpp:131
constexpr void reserve(int n_) noexcept
Definition: FixedData.hpp:150
T operator()(int i) const
< Can extrapolate (go out of bounds).
Definition: FixedData.hpp:119
constexpr const FixedDataIter< T, extrapolation > cend() const noexcept
Definition: FixedData.hpp:128
FixedData(T x_min_, T dx_, int n_)
Definition: FixedData.hpp:101
constexpr FixedDataIter< T, extrapolation > end() noexcept
Definition: FixedData.hpp:125
T back() const
Definition: FixedData.hpp:130
T prev(T x_current) noexcept
Definition: FixedData.hpp:134
FixedData(T x_min_, T dx_, int n_, std::function< T(T, T, int)> F_)
Definition: FixedData.hpp:102
T dstep() const noexcept
Definition: FixedData.hpp:132
constexpr const FixedDataIter< T, extrapolation > cbegin() const noexcept
Definition: FixedData.hpp:127
constexpr auto size() const noexcept
Definition: FixedData.hpp:157
constexpr void clear() noexcept
Definition: FixedData.hpp:151
Slide namespace contains all the types, classes, and functions for the simulation framework.
Definition: Cell.hpp:27
int distance(const FixedDataIter< T, extrapolation > &a, const FixedDataIter< T, extrapolation > &b)
Definition: FixedData.hpp:85