The Open Master Hearing Aid (openMHA)
openMHA
Open community platform for hearing aid algorithm research
|
Class for interpolation with equidistant x values. More...
Public Member Functions | |
linear_table_t (void) | |
contructor creates an empty linear_table_t object. More... | |
mha_real_t | lookup (mha_real_t x) const |
look up the y value that is stored for the mesh point where x is lower than or equal to the x value given here. More... | |
mha_real_t | interp (mha_real_t x) const |
interpolate y value for the given x value. More... | |
~linear_table_t (void) | |
destructor More... | |
void | set_xmin (mha_real_t xmin) |
set the x value for the first mesh point. More... | |
void | add_entry (mha_real_t y) |
set the y value for the next mesh point. More... | |
void | set_xmax (mha_real_t xmax) |
this sets the x value for a past-the-end, not added mesh point. More... | |
void | prepare (void) |
prepare computes the x distance of the mesh points based on the values given to set_xmin, set_xmax, and the number of times that add_entry was called. More... | |
void | clear (void) |
clear resets the state of this object to the state directly after construction. More... | |
Public Member Functions inherited from MHATableLookup::table_t | |
table_t (void) | |
virtual | ~table_t (void) |
Protected Attributes | |
mha_real_t * | vy |
unsigned int | len |
Private Attributes | |
vector< mha_real_t > | vec_y |
mha_real_t | xmin |
mha_real_t | xmax |
mha_real_t | scalefac |
Additional Inherited Members |
Class for interpolation with equidistant x values.
This class can be used for linear interpolation tasks where the mesh points are known for equidistant x values.
Before the class can be used for interpolation, it has to be filled with the y values for the mesh points, the x range has to be specified, and when all values are given, the prepare method has to be called so that the object can determine the distance between x values from the range and the number of mesh points given.
Only after prepare has returned, the object may be used for interpolation.
linear_table_t::linear_table_t | ( | void | ) |
contructor creates an empty linear_table_t object.
add_entry, set_xmin, set_xmax and prepare methods have to be called before the object can be used to lookup and interpolate values.
linear_table_t::~linear_table_t | ( | void | ) |
destructor
|
virtual |
look up the y value that is stored for the mesh point where x is lower than or equal to the x value given here.
This method does not extrapolate, so for x < xmin, the y value for xmin is returned. For all x greater than the x of the last mesh point, the y value of the last mesh point is returned.
Implements MHATableLookup::table_t.
|
virtual |
interpolate y value for the given x value.
The y values for the neighbouring mesh points are looked up and linearly interpolated. For x values outside the range of mesh points, the y value is extrapolated from the nearest two mesh points.
Implements MHATableLookup::table_t.
void linear_table_t::set_xmin | ( | mha_real_t | xmin | ) |
set the x value for the first mesh point.
Must be called before prepare can be called.
void linear_table_t::add_entry | ( | mha_real_t | y | ) |
set the y value for the next mesh point.
Must be called at least twice before prepare can be called.
void linear_table_t::set_xmax | ( | mha_real_t | xmax | ) |
this sets the x value for a past-the-end, not added mesh point.
Example:
t.set_xmin(100); t.add_entry(0); // mesh point {100,0} t.add_entry(1); // mesh point {110,1} // the next mesh point would be at x=120, but we do not add this t.set_xmax(120); // the x where the next mesh point would be t.prepare();
now, t.interp(100) == 0; t.interp(110) == 1; t.interp(105) == 0.5;
void linear_table_t::prepare | ( | void | ) |
prepare computes the x distance of the mesh points based on the values given to set_xmin, set_xmax, and the number of times that add_entry was called.
Only after this method has been called, interp or lookup may be called.
|
virtual |
clear resets the state of this object to the state directly after construction.
mesh entries and x range are deleted.
interp and lookup may not be called after this function has been called unless prepare and before that its precondition methods are called again.
Implements MHATableLookup::table_t.
|
protected |
|
protected |
|
private |
|
private |
|
private |
|
private |