class::calc::Lookup

class calc::Lookup
  : public api::CalcWorkObject

This class is for implementing lookup tables using linear extrapolation.

#include <sapi/calc.hpp>

#define ENTRIES 4

const float lookup_table[ENTRIES*2] = {  //for each entry there are 2 float values
   0.0, 2.0,  //this is an x,y pair where x is 0.0 and y is 2.0, list must have x values in ascending order
   1.0, 4.0,
   2.0, 16.0,
   3.0, 25.0
};

float lookup_value(float x){
   Lookup<float> lookup(lookup_table, ENTRIES);
   return lookup.calc_value(x);
}

Members

Lookup(

const T * table,
const arg::Size & size
)

T calculate(

T x
)

Details

Lookup(

const T * table,
const arg::Size & size
)

Constructs a lookup table object.

Parameters

  • table A pointer to a table with x and y values alternating, x values must be in ascending order

T calculate(

T x
)

Calculates the y value using linear interpolation.

Parameters

  • x Input value

Returns

y Value calculated using linear interpolation


X

Thanks for Coming!

Subscribe to news and updates