isce3 0.25.0
Loading...
Searching...
No Matches
Interp2d.icc
1#include <isce3/math/complexOperations.h>
2
3#include "Interp1d.h"
4#include "detail/Interp1d.h"
5#include "detail/SSOBuffer.h"
6
7namespace isce3 { namespace core {
8
9template<typename KernelType, typename DataType>
10DataType interp2d(const Kernel<KernelType>& kernelx,
11 const Kernel<KernelType>& kernely, const DataType* z, size_t nx,
12 size_t stridex, size_t ny, size_t stridey, double x, double y,
13 bool periodic)
14{
15 using namespace isce3::math::complex_operations;
16
17 // Small-size optimization to avoid heap allocation.
18 const int widthx = static_cast<int>(ceil(kernelx.width()));
19 const int widthy = static_cast<int>(ceil(kernely.width()));
20 detail::SSOBuffer<KernelType> coeffsx(widthx), coeffsy(widthy);
21 detail::SSOBuffer<DataType> datax(widthx), datay(widthy);
22
23 // Pre-compute (widthx + widthy) coefficients rather than calculating them
24 // (widthx * widthy) times inside the loop.
25 // In principle we could delay calculating coeffsy until after the loop, in
26 // which case we'd only need a single coefficient buffer. But we need lowy
27 // which comes from the same API call, and we're probably okay on stack
28 // space anyhow.
29 long lowx = 0, lowy = 0;
30 detail::interp1d_coeffs(kernelx, x, &lowx, coeffsx.data());
31 detail::interp1d_coeffs(kernely, y, &lowy, coeffsy.data());
32
33 // Do X interp at each Y index.
34 for (int i_kernely = 0; i_kernely < widthy; ++i_kernely) {
35 long i_datay = i_kernely + lowy;
36 if (periodic)
37 i_datay %= ny;
38 if ((i_datay >= 0) and (i_datay < ny)) {
39 const DataType* zi = &z[i_datay * stridey];
40 const DataType* px = detail::get_contiguous_view_or_copy(
41 datax.data(), widthx, lowx, zi, nx, stridex, periodic);
42 datay[i_kernely] = detail::inner_product(widthx, coeffsx.data(), px);
43 } else {
44 datay[i_kernely] = 0;
45 }
46 }
47 // Do Y interp.
48 return detail::inner_product(widthy, coeffsy.data(), datay.data());
49}
50
51}} // namespace isce3::core
Abstract base class for all kernels.
Definition Kernels.h:19
Small-size optimized (SSO) buffer.
Definition SSOBuffer.h:13
base interpolator is an abstract base class
Definition BinarySearchFunc.cpp:5

Generated for ISCE3.0 by doxygen 1.13.2.