MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / LanczosKernelFunc

Class LanczosKernelFunc

tensorflow/core/kernels/sampling_kernels.h:68–84  ·  view source on GitHub ↗

A function object for a Lanczos kernel.

Source from the content-addressed store, hash-verified

66
67// A function object for a Lanczos kernel.
68struct LanczosKernelFunc {
69 // Pass 1 for Lanczos1 kernel, 3 for Lanczos3 etc.
70 explicit LanczosKernelFunc(float _radius) : radius(_radius) {}
71 float operator()(float x) const {
72 constexpr float kPI = 3.14159265359;
73 x = std::abs(x);
74 if (x > radius) return 0.0;
75 // Need to special case the limit case of sin(x) / x when x is zero.
76 if (x <= 1e-3) {
77 return 1.0;
78 }
79 return radius * std::sin(kPI * x) * std::sin(kPI * x / radius) /
80 (kPI * kPI * x * x);
81 }
82 float Radius() const { return radius; }
83 const float radius;
84};
85
86struct GaussianKernelFunc {
87 static constexpr float kRadiusMultiplier = 3.0f;

Callers 3

CreateLanczos1KernelFunction · 0.85
CreateLanczos3KernelFunction · 0.85
CreateLanczos5KernelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected