ArraySamplers1.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: ArraySamplers1.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 1-D nearest array sampler class.
6 > Created Time: 2017/04/29
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_ARRAY_SAMPLERS1_H
10 #define CUBBYFLOW_ARRAY_SAMPLERS1_H
11 
14 
15 #include <functional>
16 
17 namespace CubbyFlow
18 {
27  template <typename T, typename R>
28  class NearestArraySampler<T, R, 1> final
29  {
30  public:
31  static_assert(std::is_floating_point<R>::value, "Samplers only can be instantiated with floating point types");
32 
41  explicit NearestArraySampler(
42  const ConstArrayAccessor1<T>& accessor,
43  R gridSpacing,
44  R gridOrigin);
45 
48 
50  T operator()(R pt) const;
51 
53  void GetCoordinate(R pt, size_t* i) const;
54 
56  std::function<T(R)> Functor() const;
57 
58  private:
59  R m_gridSpacing;
60  R m_origin;
61  ConstArrayAccessor1<T> m_accessor;
62  };
63 
65  template <typename T, typename R>
67 
76  template <typename T, typename R>
77  class LinearArraySampler<T, R, 1> final
78  {
79  public:
80  static_assert(std::is_floating_point<R>::value, "Samplers only can be instantiated with floating point types");
81 
90  explicit LinearArraySampler(
91  const ConstArrayAccessor1<T>& accessor,
92  R gridSpacing,
93  R gridOrigin);
94 
97 
99  T operator()(R pt) const;
100 
102  void GetCoordinatesAndWeights(R pt, size_t* i0, size_t* i1, T* weight0, T* weight1) const;
103 
105  std::function<T(R)> Functor() const;
106 
107  private:
108  R m_gridSpacing;
109  R m_origin;
110  ConstArrayAccessor1<T> m_accessor;
111  };
112 
114  template <typename T, typename R>
116 
125  template <typename T, typename R>
126  class CubicArraySampler<T, R, 1> final
127  {
128  public:
129  static_assert(std::is_floating_point<R>::value, "Samplers only can be instantiated with floating point types");
130 
139  explicit CubicArraySampler(
140  const ConstArrayAccessor1<T>& accessor,
141  R gridSpacing,
142  R gridOrigin);
143 
145  CubicArraySampler(const CubicArraySampler& other);
146 
148  T operator()(R pt) const;
149 
151  std::function<T(R)> Functor() const;
152 
153  private:
154  R m_gridSpacing;
155  R m_origin;
156  ConstArrayAccessor1<T> m_accessor;
157  };
158 
160  template <typename T, typename R>
162 }
163 
165 
166 #endif
1-D cubic array sampler class.
Definition: ArraySamplers1.h:126
Generic N-D nearest array sampler class.
Definition: ArraySamplers.h:22
1-D read-only array accessor class.
Definition: ArrayAccessor1.h:185
1-D linear array sampler class.
Definition: ArraySamplers1.h:77
Definition: pybind11Utils.h:24
Generic N-D cubic array sampler class.
Definition: ArraySamplers.h:50
Generic N-D linear array sampler class.
Definition: ArraySamplers.h:36
1-D nearest array sampler class.
Definition: ArraySamplers1.h:28