isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Kernels.h
1 #pragma once
2 
3 #include "forward.h"
4 
5 #include <cmath>
6 #include <thrust/device_vector.h>
7 
8 #include <isce3/core/Common.h>
9 #include <isce3/core/Kernels.h>
10 
11 namespace isce3 { namespace cuda { namespace core {
12 
18 template<typename T, class Derived>
19 class Kernel {
20 public:
22  using value_type = T;
23 
25  explicit constexpr Kernel(double width) noexcept
26  : _halfwidth(std::abs(width) / 2.)
27  {}
28 
34  constexpr double halfwidth() const noexcept { return _halfwidth; }
35 
41  constexpr double width() const noexcept { return 2. * _halfwidth; }
42 
44  CUDA_HOSTDEV T operator()(double t) const;
45 
46 private:
47  double _halfwidth;
48 };
49 
51 template<typename T>
52 class BartlettKernel : public Kernel<T, BartlettKernel<T>> {
53  using Base = Kernel<T, BartlettKernel<T>>;
54  friend Base;
55 
56 public:
59 
61  explicit constexpr BartlettKernel(double width) : Base(width) {}
62 
65  : BartlettKernel(other.width())
66  {}
67 
68 protected:
70  constexpr T eval(double t) const;
71 };
72 
74 template<typename T>
75 class LinearKernel : public BartlettKernel<T> {
76  using Base = BartlettKernel<T>;
77 
78 public:
81 
83  constexpr LinearKernel() : Base(2.) {}
84 
87 };
88 
94 template<typename T>
95 class KnabKernel : public Kernel<T, KnabKernel<T>> {
96  using Base = Kernel<T, KnabKernel<T>>;
97  friend Base;
98 
99 public:
102 
110  constexpr KnabKernel(double width, double bandwidth);
111 
114  : Base(other.width()), _bandwidth(other.bandwidth())
115  {}
116 
118  constexpr double bandwidth() const noexcept { return _bandwidth; }
119 
120 protected:
122  CUDA_HOSTDEV T eval(double t) const;
123 
124 private:
125  double _bandwidth;
126 };
127 
129 template<typename T>
130 class TabulatedKernelView : public Kernel<T, TabulatedKernelView<T>> {
132  friend Base;
133 
134  friend class TabulatedKernel<T>;
135 
136 public:
139 
141 
147  CUDA_DEV T operator()(double t) const { return eval(t); }
148 
149 protected:
151  CUDA_DEV T eval(double t) const;
152 
153 private:
154  const T* _table;
155  int _imax;
156  T _rdx;
157 };
158 
160 template<typename T>
161 class TabulatedKernel : public Kernel<T, TabulatedKernel<T>> {
162  using Base = Kernel<T, TabulatedKernel<T>>;
163  friend Base;
164 
165  friend class TabulatedKernelView<T>;
166 
167 public:
170 
179  template<class OtherKernel>
180  TabulatedKernel(const OtherKernel& kernel, int n);
181 
184 
190  CUDA_DEV T operator()(double t) const { return eval(t); }
191 
192 protected:
194  CUDA_DEV T eval(double t) const;
195 
196 private:
197  thrust::device_vector<T> _table;
198  int _imax;
199  T _rdx;
200 };
201 
203 template<typename T>
204 class ChebyKernelView : public Kernel<T, ChebyKernelView<T>> {
206  friend Base;
207 
208  friend class ChebyKernel<T>;
209 
210 public:
213 
214  ChebyKernelView(const ChebyKernel<T>& kernel);
215 
221  CUDA_DEV T operator()(double t) const { return eval(t); }
222 
223 protected:
225  CUDA_DEV T eval(double t) const;
226 
227 private:
228  const T* _coeffs;
229  int _n;
230  T _scale;
231 };
232 
234 template<typename T>
235 class ChebyKernel : public Kernel<T, ChebyKernel<T>> {
236  using Base = Kernel<T, ChebyKernel<T>>;
237  friend Base;
238 
239  friend class ChebyKernelView<T>;
240 
241 public:
244 
253  template<class OtherKernel>
254  ChebyKernel(const OtherKernel& kernel, int n);
255 
258  : Base(other.width()), _scale(4. / other.width()),
259  _coeffs(other.coeffs())
260  {}
261 
267  CUDA_DEV T operator()(double t) const { return eval(t); }
268 
269 protected:
271  CUDA_DEV T eval(double t) const;
272 
273 private:
274  T _scale;
275  thrust::device_vector<T> _coeffs;
276 };
277 
278 }}} // namespace isce3::cuda::core
279 
280 #include "Kernels.icc"
Kernel based on the paper by Knab for interpolating band-limited signals.
Definition: forward.h:42
Kernel based on the paper by Knab for interpolating band-limited signals .
Definition: forward.h:18
LinearKernel(const isce3::core::LinearKernel< T > &)
Construct from corresponding host kernel object.
Definition: Kernels.h:86
T value_type
Kernel coefficients value type.
Definition: Kernels.h:22
Polynomial Kernel.
Definition: forward.h:46
Linear kernel (special case of Bartlett)
Definition: forward.h:17
CRTP base class for kernels.
Definition: Kernels.h:19
constexpr double halfwidth() const noexcept
Get the halfwidth of the kernel.
Definition: Kernels.h:34
BartlettKernel(const isce3::core::BartlettKernel< T > &other)
Construct from corresponding host kernel object.
Definition: Kernels.h:64
TabulatedKernel(const OtherKernel &kernel, int n)
Construct a new TabulatedKernel object.
Definition: Kernels.icc:82
constexpr double bandwidth() const noexcept
Get bandwidth of the kernel.
Definition: Kernels.h:118
constexpr KnabKernel(double width, double bandwidth)
Construct a new KnabKernel object.
Definition: Kernels.icc:35
KnabKernel(const isce3::core::KnabKernel< T > &other)
Construct from corresponding host kernel object.
Definition: Kernels.h:113
Linear kernel, which is just a special case of Bartlett.
Definition: forward.h:43
ChebyKernel(const OtherKernel &kernel, int n)
Construct a new ChebyKernel object by computing a fit to another kernel.
Definition: Kernels.icc:155
Abstract base class for all kernels.
Definition: forward.h:40
A non-owning reference to a TabulatedKernel object.
Definition: Kernels.h:130
constexpr BartlettKernel(double width)
Construct a new BartlettKernel object.
Definition: Kernels.h:61
constexpr Kernel(double width) noexcept
Construct a new Kernel object.
Definition: Kernels.h:25
Chebyshev polynomial kernel.
Definition: forward.h:20
CUDA_DEV T operator()(double t) const
Evaluate the kernel at a given location in [-halfwidth, halfwidth].
Definition: Kernels.h:190
constexpr double width() const noexcept
Get the width of the kernel.
Definition: Kernels.h:41
constexpr LinearKernel()
Construct a new LinearKernel object.
Definition: Kernels.h:83
Tabulated Kernel.
Definition: forward.h:45
CUDA_DEV T operator()(double t) const
Evaluate the kernel at a given location in [-halfwidth, halfwidth].
Definition: Kernels.h:221
A non-owning reference to a ChebyKernel object.
Definition: Kernels.h:204
CUDA_HOSTDEV T operator()(double t) const
Evaluate the kernel at a given location in [-halfwidth, halfwidth].
Definition: Kernels.icc:22
Tabulated kernel.
Definition: forward.h:19
CUDA_DEV T operator()(double t) const
Evaluate the kernel at a given location in [-halfwidth, halfwidth].
Definition: Kernels.h:147
ChebyKernel(const isce3::core::ChebyKernel< T > &other)
Construct from corresponding host kernel object.
Definition: Kernels.h:257
CUDA_DEV T operator()(double t) const
Evaluate the kernel at a given location in [-halfwidth, halfwidth].
Definition: Kernels.h:267

Generated for ISCE3.0 by doxygen 1.8.5.