isce3 0.25.0
Loading...
Searching...
No Matches
Interp1d.icc
1#include <cmath>
2#include <type_traits>
3
4namespace isce3 { namespace cuda { namespace core {
5
6template<class Kernel, typename T>
7CUDA_HOSTDEV inline T interp1d(const Kernel& kernel, const T* x, size_t length,
8 size_t stride, double t, bool periodic)
9{
10
11 auto width = static_cast<int>(std::ceil(kernel.width()));
12 auto i0 = (width % 2 == 0) ? static_cast<long>(std::ceil(t))
13 : static_cast<long>(std::round(t));
14
15 auto low = i0 - width / 2;
16 auto high = low + width;
17
18 if (not periodic and (low < 0 or high >= length)) {
19 return T(0);
20 }
21
22 using U = typename std::common_type<typename Kernel::value_type, T>::type;
23
24 U sum = 0.;
25 for (auto i = low; i < high; ++i) {
26 auto j = (periodic) ? i % length : i;
27 double ti = static_cast<double>(i) - t;
28 auto w = kernel(ti);
29 sum += w * x[j * stride];
30 }
31
32 return static_cast<T>(sum);
33}
34
35}}} // namespace isce3::cuda::core
CRTP base class for kernels.
Definition Kernels.h:19
base interpolator is an abstract base class
Definition BinarySearchFunc.cpp:5

Generated for ISCE3.0 by doxygen 1.13.2.