@@ -71,30 +71,13 @@ class RegularGrid1D {
71
71
PORTABLE_ALWAYS_REQUIRE (xmin_ < xmax_ && N_ > 0 , " Valid grid" );
72
72
}
73
73
74
- // Forces x in the interval
75
- PORTABLE_INLINE_FUNCTION int bound (int ix) const {
76
- #ifndef SPINER_DISABLE_BOUNDS_CHECKS
77
- if (ix < 0 ) ix = 0 ;
78
- if (ix >= (int )N_ - 1 ) ix = (int )N_ - 2 ; // Ensures ix+1 exists
79
- #endif
80
- return ix;
81
- }
82
-
83
- // TODO: make these private to hide u as an internal detail
84
- // Translate between u (transformed variable) coordinate and index
85
- PORTABLE_INLINE_FUNCTION T u (const int i) const { return i * du_ + umin_; }
86
- PORTABLE_INLINE_FUNCTION int index_u (const T u) const {
87
- return bound (inv_du_ * (u - umin_));
88
- }
89
-
74
+ // TODO: min() and x(0) won't necessarily match.
75
+ // max() and x(nPoints-1) won't necessarily match.
76
+ // Should we do anything about this?
90
77
// Translate between x coordinate and index
91
78
PORTABLE_INLINE_FUNCTION T x (const int i) const {
92
79
return Transform::reverse (u (i));
93
80
}
94
- // TODO: Delete index since internally we only use index_u?
95
- PORTABLE_INLINE_FUNCTION int index (const T x) const {
96
- return index_u (Transform::forward (x));
97
- }
98
81
99
82
// Returns closest index and weights for interpolation
100
83
PORTABLE_INLINE_FUNCTION void weights (const T &x, int &ix, weights_t <T> &w) const {
@@ -126,9 +109,6 @@ class RegularGrid1D {
126
109
operator !=(const RegularGrid1D<T, Transform> &other) const {
127
110
return !(*this == other);
128
111
}
129
- // TODO: umin, umax should be private
130
- PORTABLE_INLINE_FUNCTION T umin () const { return umin_; }
131
- PORTABLE_INLINE_FUNCTION T umax () const { return umax_; }
132
112
133
113
PORTABLE_INLINE_FUNCTION T min () const { return xmin_; }
134
114
PORTABLE_INLINE_FUNCTION T max () const { return xmax_; }
@@ -184,6 +164,21 @@ class RegularGrid1D {
184
164
#endif
185
165
186
166
private:
167
+ // Forces x in the interval
168
+ PORTABLE_INLINE_FUNCTION int bound (int ix) const {
169
+ #ifndef SPINER_DISABLE_BOUNDS_CHECKS
170
+ if (ix < 0 ) ix = 0 ;
171
+ if (ix >= (int )N_ - 1 ) ix = (int )N_ - 2 ; // Ensures ix+1 exists
172
+ #endif
173
+ return ix;
174
+ }
175
+
176
+ // Translate between u (transformed variable) coordinate and index
177
+ PORTABLE_INLINE_FUNCTION T u (const int i) const { return i * du_ + umin_; }
178
+ PORTABLE_INLINE_FUNCTION int index_u (const T u) const {
179
+ return bound (inv_du_ * (u - umin_));
180
+ }
181
+
187
182
T xmin_, xmax_;
188
183
T umin_, umax_;
189
184
T du_, inv_du_;
0 commit comments