8#ifndef BSPLINE_SUPPORT_GRID_H
9#define BSPLINE_SUPPORT_GRID_H
11#include <bspline/exceptions/BSplineException.h>
12#include <bspline/internal/misc.h>
13#include <bspline/internal/test_checks.h>
30 std::shared_ptr<const std::vector<T>> _data;
36 bool isSteadilyIncreasing()
const {
37 for (
size_t i = 1;
i < _data->
size();
i++) {
38 if ((*_data)[
i - 1] >= (*_data)[
i]) {
52 void checkValidity()
const {
54 if (!_data || _data->size() < 2) {
56 }
else if (!isSteadilyIncreasing()) {
58 "The grid points are not steadily increasing.");
80 template <
typename Iter>
107 explicit Grid(std::shared_ptr<
const std::vector<T>>
data)
149 if (_data ==
g._data) {
155 return (*_data) == (*
g._data);
171 return _data->size();
180 std::shared_ptr<const std::vector<T>>
getData()
const {
194 return _data->empty();
236 return _data->front();
249 return _data->back();
258 return _data->begin();
The main exception class.
Definition BSplineException.h:84
Represents a global Grid.
Definition Grid.h:27
const T & at(size_t i) const
Gives access to the i-th element of the Grid.
Definition Grid.h:218
typename std::vector< T >::const_iterator const_iterator
Iterator type.
Definition Grid.h:66
Grid(Iter begin, Iter end)
Constructs a Grid from a set of begin and end iterators.
Definition Grid.h:81
Grid(const std::initializer_list< T > &v)
Constructs a Grid from a std::initializer_list.
Definition Grid.h:99
const_iterator end() const
Returns the end iterator of the Grid..
Definition Grid.h:265
Grid & operator=(Grid &&g)=delete
Explicitly deleted move assignment operator.
bool operator!=(const Grid &g) const
Negated comparison operator.
Definition Grid.h:163
const T & operator[](size_t i) const
Gives access to the i-th element of the Grid.
Definition Grid.h:205
size_t size() const
Returns the number of elements of the Grid.
Definition Grid.h:169
Grid(std::shared_ptr< const std::vector< T > > data)
Constructs a Grid from a std::shared_ptr<const std::vector<T>>.
Definition Grid.h:107
bool empty() const
Checks whether the spline is empty.
Definition Grid.h:192
std::shared_ptr< const std::vector< T > > getData() const
Gives access to the underlying data.
Definition Grid.h:180
const_iterator begin() const
Returns the begin iterator of the Grid.
Definition Grid.h:256
Grid(Grid &&g)=delete
Explicitly deleted move constructor.
Grid(const Grid &g) noexcept=default
Default copy constructor.
size_t findElement(const T &x) const
Returns the index corresponding to the element x.
Definition Grid.h:275
Grid(std::vector< T > v)
Constructs a Grid from a std::vector.
Definition Grid.h:90
Grid & operator=(const Grid &g) noexcept=default
Default copy assignment operator.
bool operator==(const Grid &g) const
Comparison operator.
Definition Grid.h:146
const T & back() const
Returns a reference to the last element of the Grid.
Definition Grid.h:244
~Grid()=default
Default destructor.
const T & front() const
Returns a reference to the first element of the Grid.
Definition Grid.h:231
Exceptions and error codes.
Definition BSplineException.h:19
Namespace for the Spline's Grid and Support.
Definition Grid.h:19