Skip to content

Commit

Permalink
Add 2-parameter, 1-index overload of interpToReal.
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanWollaeger committed Jan 27, 2025
1 parent 71b94fa commit a9d303a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions spiner/databox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ class DataBox {
PORTABLE_FORCEINLINE_FUNCTION T interpToReal(const T x) const noexcept;
PORTABLE_FORCEINLINE_FUNCTION T interpToReal(const T x2,
const T x1) const noexcept;
PORTABLE_FORCEINLINE_FUNCTION T interpToReal(const T x2, const T x1,
const int idx) const noexcept;
PORTABLE_FORCEINLINE_FUNCTION T interpToReal(const T x3, const T x2,
const T x1) const noexcept;
PORTABLE_FORCEINLINE_FUNCTION T interpToReal(const T x3, const T x2,
Expand Down Expand Up @@ -472,6 +474,23 @@ PORTABLE_FORCEINLINE_FUNCTION T DataBox<T, Grid_t, Concept>::interpToReal(
w1[1] * dataView_(ix2 + 1, ix1 + 1)));
}

template <typename T, typename Grid_t, typename Concept>
PORTABLE_FORCEINLINE_FUNCTION T
DataBox<T, Grid_t, Concept>::interpToReal(const T x2, const T x1, const int idx) const noexcept {
assert(canInterpToReal_(2));
int ix1, ix2;
weights_t<T> w1, w2;
grids_[1].weights(x1, ix1, w1);
grids_[2].weights(x2, ix2, w2);

// TODO: prefectch corners for speed?
// TODO: re-order access pattern?
return (w2[0] *
(w1[0] * dataView_(ix2, ix1, idx) + w1[1] * dataView_(ix2, ix1 + 1, idx)) +
w2[1] * (w1[0] * dataView_(ix2 + 1, ix1, idx) +
w1[1] * dataView_(ix2 + 1, ix1 + 1, idx)));
}

template <typename T, typename Grid_t, typename Concept>
PORTABLE_FORCEINLINE_FUNCTION T DataBox<T, Grid_t, Concept>::interpToReal(
const T x3, const T x2, const T x1) const noexcept {
Expand Down

0 comments on commit a9d303a

Please sign in to comment.