class::calc::Lookup

class calc::Lookup
  : public api::WorkObject

This class is for implementing lookup tables using linear extrapolation.

//md2code:include
#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
};
//md2code:main
Lookup<float> lookup(lookup_table, ENTRIES);
printf("Value is %0.2f\n", lookup.calculate(1.5f));

Summary

[Lookup](#classcalc_1_1_lookup_1ad6dad48fcc352a05a0f1d35575c925ff)(  

const T * table,
const arg::Count & count
)

T calculate(

T x
)

Members

Lookup(

const T * table,
const arg::Count & count
)

Constructs a lookup table object.

Parameters

  • table

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