FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
interp::InterpFilter Class Reference

Provides methods to generate interpolation filters using Kaiser windows. More...

#include "interpolation_filter.h"

Public Member Functions

 InterpFilter (const InterpFilter &)=delete
 
 InterpFilter (InterpFilter &&)=delete
 
InterpFilteroperator= (const InterpFilter &)=delete
 
InterpFilteroperator= (InterpFilter &&)=delete
 
 ~InterpFilter ()=default
 
std::expected< RealType, std::string > kaiserWinCompute (RealType x) const noexcept
 Computes the Kaiser window function for a given input.
 
std::expected< RealType, std::string > interpFilter (RealType x) const noexcept
 Computes the interpolation filter value for a given input.
 
std::span< const RealTypegetFilter (RealType delay) const
 Retrieves a span of precomputed filter values for a given delay.
 

Static Public Member Functions

static constexpr RealType sinc (const RealType x) noexcept
 Computes the sinc function for a given input.
 
static InterpFiltergetInstance () noexcept
 Retrieves the singleton instance of the InterpFilter class.
 

Detailed Description

Provides methods to generate interpolation filters using Kaiser windows.

Definition at line 27 of file interpolation_filter.h.

Constructor & Destructor Documentation

◆ InterpFilter() [1/2]

interp::InterpFilter::InterpFilter ( const InterpFilter )
delete

◆ InterpFilter() [2/2]

interp::InterpFilter::InterpFilter ( InterpFilter &&  )
delete

◆ ~InterpFilter()

interp::InterpFilter::~InterpFilter ( )
default

Member Function Documentation

◆ getFilter()

std::span< const RealType > interp::InterpFilter::getFilter ( RealType  delay) const

Retrieves a span of precomputed filter values for a given delay.

Parameters
delayThe delay value for which the filter is retrieved.
Returns
A span of precomputed filter values.
Exceptions
std::runtime_errorIf the delay value is out of range.

Definition at line 138 of file interpolation_filter.cpp.

139 {
140 if (delay < -1 || delay > 1)
141 {
142 LOG(Level::FATAL, "Requested delay filter value out of range: {}", delay);
143 throw std::runtime_error("Requested delay filter value out of range");
144 }
145
146 const auto filt = static_cast<unsigned>((delay + 1) * (_table_filters / 2.0));
147 return std::span{&_filter_table[filt * _length], static_cast<size_t>(_length)};
148 }
#define LOG(level,...)
Definition logging.h:19

References LOG.

◆ getInstance()

InterpFilter & interp::InterpFilter::getInstance ( )
staticnoexcept

Retrieves the singleton instance of the InterpFilter class.

Returns
The singleton instance of the InterpFilter class.

Definition at line 63 of file interpolation_filter.cpp.

64 {
65 static InterpFilter instance;
66 return instance;
67 }
InterpFilter(const InterpFilter &)=delete

Referenced by fers_signal::Signal::render().

+ Here is the caller graph for this function:

◆ interpFilter()

std::expected< RealType, std::string > interp::InterpFilter::interpFilter ( RealType  x) const
noexcept

Computes the interpolation filter value for a given input.

Parameters
xThe input value for which the interpolation filter is computed.
Returns
The computed filter value, or an error message if computation fails.

Definition at line 85 of file interpolation_filter.cpp.

86 {
87 if (auto kaiser = kaiserWinCompute(x + _alpha); kaiser)
88 {
89 return *kaiser * sinc(x);
90 }
91 else
92 {
93 return std::unexpected(kaiser.error());
94 }
95 }
static constexpr RealType sinc(const RealType x) noexcept
Computes the sinc function for a given input.
std::expected< RealType, std::string > kaiserWinCompute(RealType x) const noexcept
Computes the Kaiser window function for a given input.

◆ kaiserWinCompute()

std::expected< RealType, std::string > interp::InterpFilter::kaiserWinCompute ( RealType  x) const
noexcept

Computes the Kaiser window function for a given input.

Parameters
xThe input value for the Kaiser window calculation.
Returns
The computed window value, or an error message if computation fails.

Definition at line 69 of file interpolation_filter.cpp.

70 {
71 if (x < 0 || x > _alpha * 2)
72 {
73 return 0;
74 }
75 if (auto bessel = besselI0(_beta * std::sqrt(1 - std::pow((x - _alpha) / _alpha, 2))); bessel)
76 {
77 return *bessel / _bessel_beta;
78 }
79 else
80 {
81 return std::unexpected(bessel.error());
82 }
83 }

◆ operator=() [1/2]

InterpFilter & interp::InterpFilter::operator= ( const InterpFilter )
delete

◆ operator=() [2/2]

InterpFilter & interp::InterpFilter::operator= ( InterpFilter &&  )
delete

◆ sinc()

static constexpr RealType interp::InterpFilter::sinc ( const RealType  x)
staticconstexprnoexcept

Computes the sinc function for a given input.

Parameters
xThe input value for which the sinc function is computed.
Returns
The computed sinc value.

Definition at line 42 of file interpolation_filter.h.

43 {
44 return x == 0.0 ? 1.0 : std::sin(x * PI) / (x * PI);
45 }
constexpr RealType PI
Mathematical constant π (pi).
Definition config.h:43

References PI.


The documentation for this class was generated from the following files: