isce3 0.25.0
Loading...
Searching...
No Matches
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
11namespace isce3 { namespace cuda { namespace core {
12
18template<typename T, class Derived>
19class Kernel {
20public:
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
46private:
47 double _halfwidth;
48};
49
51template<typename T>
52class BartlettKernel : public Kernel<T, BartlettKernel<T>> {
53 using Base = Kernel<T, BartlettKernel<T>>;
54 friend Base;
55
56public:
59
61 explicit constexpr BartlettKernel(double width) : Base(width) {}
62
67
68protected:
70 constexpr T eval(double t) const;
71};
72
74template<typename T>
75class LinearKernel : public BartlettKernel<T> {
76 using Base = BartlettKernel<T>;
77
78public:
81
83 constexpr LinearKernel() : Base(2.) {}
84
87};
88
94template<typename T>
95class KnabKernel : public Kernel<T, KnabKernel<T>> {
96 using Base = Kernel<T, KnabKernel<T>>;
97 friend Base;
98
99public:
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
120protected:
122 CUDA_HOSTDEV T eval(double t) const;
123
124private:
125 double _bandwidth;
126};
127
129template<typename T>
130class TabulatedKernelView : public Kernel<T, TabulatedKernelView<T>> {
132 friend Base;
133
134 friend class TabulatedKernel<T>;
135
136public:
138 using view_type = TabulatedKernelView<T>;
139
140 TabulatedKernelView(const TabulatedKernel<T>& kernel);
141
147 CUDA_DEV T operator()(double t) const { return eval(t); }
148
149protected:
151 CUDA_DEV T eval(double t) const;
152
153private:
154 const T* _table;
155 int _imax;
156 T _rdx;
157};
158
160template<typename T>
161class TabulatedKernel : public Kernel<T, TabulatedKernel<T>> {
162 using Base = Kernel<T, TabulatedKernel<T>>;
163 friend Base;
164
165 friend class TabulatedKernelView<T>;
166
167public:
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
192protected:
194 CUDA_DEV T eval(double t) const;
195
196private:
197 thrust::device_vector<T> _table;
198 int _imax;
199 T _rdx;
200};
201
203template<typename T>
204class ChebyKernelView : public Kernel<T, ChebyKernelView<T>> {
205 using Base = Kernel<T, ChebyKernelView<T>>;
206 friend Base;
207
208 friend class ChebyKernel<T>;
209
210public:
212 using view_type = ChebyKernelView<T>;
213
214 ChebyKernelView(const ChebyKernel<T>& kernel);
215
221 CUDA_DEV T operator()(double t) const { return eval(t); }
222
223protected:
225 CUDA_DEV T eval(double t) const;
226
227private:
228 const T* _coeffs;
229 int _n;
230 T _scale;
231};
232
234template<typename T>
235class ChebyKernel : public Kernel<T, ChebyKernel<T>> {
236 using Base = Kernel<T, ChebyKernel<T>>;
237 friend Base;
238
239 friend class ChebyKernelView<T>;
240
241public:
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
269protected:
271 CUDA_DEV T eval(double t) const;
272
273private:
274 T _scale;
275 thrust::device_vector<T> _coeffs;
276};
277
278}}} // namespace isce3::cuda::core
279
280#include "Kernels.icc"
Bartlett kernel (triangle function).
Definition Kernels.h:43
Polynomial Kernel.
Definition Kernels.h:155
Kernel based on the paper by Knab for interpolating band-limited signals.
Definition Kernels.h:65
Linear kernel, which is just a special case of Bartlett.
Definition Kernels.h:53
Tabulated Kernel.
Definition Kernels.h:133
constexpr BartlettKernel(double width)
Construct a new BartlettKernel object.
Definition Kernels.h:61
BartlettKernel(const isce3::core::BartlettKernel< T > &other)
Construct from corresponding host kernel object.
Definition Kernels.h:64
BartlettKernel< T > view_type
A non-owning kernel view type that can be passed to device code.
Definition Kernels.h:58
A non-owning reference to a ChebyKernel object.
Definition Kernels.h:204
ChebyKernelView< T > view_type
A non-owning kernel view type that can be passed to device code.
Definition Kernels.h:212
CUDA_DEV T operator()(double t) const
Evaluate the kernel at a given location in [-halfwidth, halfwidth].
Definition Kernels.h:221
Chebyshev polynomial kernel.
Definition Kernels.h:235
ChebyKernelView< T > view_type
A non-owning kernel view type that can be passed to device code.
Definition Kernels.h:243
CUDA_DEV T operator()(double t) const
Evaluate the kernel at a given location in [-halfwidth, halfwidth].
Definition Kernels.h:267
ChebyKernel(const isce3::core::ChebyKernel< T > &other)
Construct from corresponding host kernel object.
Definition Kernels.h:257
ChebyKernel(const OtherKernel &kernel, int n)
Construct a new ChebyKernel object by computing a fit to another kernel.
Definition Kernels.icc:155
constexpr Kernel(double width) noexcept
Construct a new Kernel object.
Definition Kernels.h:25
CUDA_HOSTDEV T operator()(double t) const
Evaluate the kernel at a given location in [-halfwidth, halfwidth].
Definition Kernels.icc:22
constexpr double width() const noexcept
Definition Kernels.h:41
T value_type
Kernel coefficients value type.
Definition Kernels.h:22
constexpr double halfwidth() const noexcept
Get the halfwidth of the kernel.
Definition Kernels.h:34
KnabKernel(const isce3::core::KnabKernel< T > &other)
Construct from corresponding host kernel object.
Definition Kernels.h:113
KnabKernel< T > view_type
A non-owning kernel view type that can be passed to device code.
Definition Kernels.h:101
constexpr KnabKernel(double width, double bandwidth)
Construct a new KnabKernel object.
Definition Kernels.icc:35
constexpr double bandwidth() const noexcept
Get bandwidth of the kernel.
Definition Kernels.h:118
LinearKernel(const isce3::core::LinearKernel< T > &)
Construct from corresponding host kernel object.
Definition Kernels.h:86
LinearKernel< T > view_type
A non-owning kernel view type that can be passed to device code.
Definition Kernels.h:80
constexpr LinearKernel()
Construct a new LinearKernel object.
Definition Kernels.h:83
A non-owning reference to a TabulatedKernel object.
Definition Kernels.h:130
CUDA_DEV T operator()(double t) const
Evaluate the kernel at a given location in [-halfwidth, halfwidth].
Definition Kernels.h:147
TabulatedKernelView< T > view_type
A non-owning kernel view type that can be passed to device code.
Definition Kernels.h:138
Tabulated kernel.
Definition Kernels.h:161
TabulatedKernel(const OtherKernel &kernel, int n)
Construct a new TabulatedKernel object.
Definition Kernels.icc:82
CUDA_DEV T operator()(double t) const
Evaluate the kernel at a given location in [-halfwidth, halfwidth].
Definition Kernels.h:190
TabulatedKernelView< T > view_type
A non-owning kernel view type that can be passed to device code.
Definition Kernels.h:169
base interpolator is an abstract base class
Definition BinarySearchFunc.cpp:5

Generated for ISCE3.0 by doxygen 1.13.2.