The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
MHATableLookup::xy_table_t Class Reference

Class for interpolation with non-equidistant x values. More...

Inheritance diagram for MHATableLookup::xy_table_t:
Inheritance graph

Public Member Functions

 xy_table_t ()
 
mha_real_t lookup (mha_real_t x) const
 Return the y-value at the position of the nearest x value below input. More...
 
mha_real_t interp (mha_real_t x) const
 Linear interpolation function. More...
 
void add_entry (mha_real_t x, mha_real_t y)
 Add a single x-y pair entry. More...
 
void add_entry (mha_real_t *pVX, mha_real_t *pVY, unsigned int len)
 Add multiple entries at once. More...
 
void clear ()
 Clear the table and transformation functions. More...
 
void set_xfun (float(*pXFun)(float))
 Set transformation function for x values. More...
 
void set_yfun (float(*pYFun)(float))
 Set transformation function for y values during insertion. More...
 
void set_xyfun (float(*pYFun)(float, float))
 Set transformation function for y values during insertion, based on x and y values. More...
 
std::pair< mha_real_t, mha_real_tget_xlimits () const
 returns the min and max x of all mesh points that are stored in the lookup table, i.e. More...
 
- Public Member Functions inherited from MHATableLookup::table_t
 table_t (void)
 
virtual ~table_t (void)
 

Private Attributes

std::map< mha_real_t, mha_real_tmXY
 
float(* xfun )(float)
 
float(* yfun )(float)
 
float(* xyfun )(float, float)
 

Additional Inherited Members

Detailed Description

Class for interpolation with non-equidistant x values.

Linear interpolation of the x-y table is performed. A transformation of x and y-values is possible; if a transformation function is provided for the x-values, the same function is applied to the argument of xy_table_t::interp() and xy_table_t::lookup(). The transformation of y values is applied only during insertion into the table. Two functions for y-transformation can be provided: a simple transformation which depends only on the y values, or a transformation which takes both (non-transformed) x and y value as an argument. The two-argument transformation is applied before the one-argument transformation.

Constructor & Destructor Documentation

◆ xy_table_t()

xy_table_t::xy_table_t ( )

Member Function Documentation

◆ lookup()

mha_real_t xy_table_t::lookup ( mha_real_t  x) const
virtual

Return the y-value at the position of the nearest x value below input.

Parameters
xInput value
Returns
y value at nearest x value below input.

Implements MHATableLookup::table_t.

◆ interp()

mha_real_t xy_table_t::interp ( mha_real_t  x) const
virtual

Linear interpolation function.

Parameters
xx value
Returns
interpolated y value

Implements MHATableLookup::table_t.

◆ add_entry() [1/2]

void xy_table_t::add_entry ( mha_real_t  x,
mha_real_t  y 
)

Add a single x-y pair entry.

Parameters
xx value
ycorresponding y value

◆ add_entry() [2/2]

void xy_table_t::add_entry ( mha_real_t pVX,
mha_real_t pVY,
unsigned int  uLength 
)

Add multiple entries at once.

Parameters
pVXarray of x values
pVYarray of y values
uLengthLength of x and y arrays

◆ clear()

void xy_table_t::clear ( void  )
virtual

Clear the table and transformation functions.

Implements MHATableLookup::table_t.

◆ set_xfun()

void xy_table_t::set_xfun ( float(*)(float)  fun)

Set transformation function for x values.

Parameters
funTransformation function.

◆ set_yfun()

void xy_table_t::set_yfun ( float(*)(float)  fun)

Set transformation function for y values during insertion.

Parameters
funTransformation function.

◆ set_xyfun()

void xy_table_t::set_xyfun ( float(*)(float, float)  fun)

Set transformation function for y values during insertion, based on x and y values.

Parameters
funTransformation function.

◆ get_xlimits()

std::pair<mha_real_t,mha_real_t> MHATableLookup::xy_table_t::get_xlimits ( ) const
inline

returns the min and max x of all mesh points that are stored in the lookup table, i.e.

after transformation with xfun, if any. Not real-time safe

Member Data Documentation

◆ mXY

std::map<mha_real_t,mha_real_t> MHATableLookup::xy_table_t::mXY
private

◆ xfun

float(* MHATableLookup::xy_table_t::xfun) (float)
private

◆ yfun

float(* MHATableLookup::xy_table_t::yfun) (float)
private

◆ xyfun

float(* MHATableLookup::xy_table_t::xyfun) (float, float)
private

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