Skip to content

Commit 0486a9d

Browse files
Cleaning up things that should (probably?) be private.
1 parent 624d244 commit 0486a9d

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

spiner/regular_grid_1d.hpp

+18-23
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,13 @@ class RegularGrid1D {
7171
PORTABLE_ALWAYS_REQUIRE(xmin_ < xmax_ && N_ > 0, "Valid grid");
7272
}
7373

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?
9077
// Translate between x coordinate and index
9178
PORTABLE_INLINE_FUNCTION T x(const int i) const {
9279
return Transform::reverse(u(i));
9380
}
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-
}
9881

9982
// Returns closest index and weights for interpolation
10083
PORTABLE_INLINE_FUNCTION void weights(const T &x, int &ix, weights_t<T> &w) const {
@@ -126,9 +109,6 @@ class RegularGrid1D {
126109
operator!=(const RegularGrid1D<T, Transform> &other) const {
127110
return !(*this == other);
128111
}
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_; }
132112

133113
PORTABLE_INLINE_FUNCTION T min() const { return xmin_; }
134114
PORTABLE_INLINE_FUNCTION T max() const { return xmax_; }
@@ -184,6 +164,21 @@ class RegularGrid1D {
184164
#endif
185165

186166
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+
187182
T xmin_, xmax_;
188183
T umin_, umax_;
189184
T du_, inv_du_;

0 commit comments

Comments
 (0)