PER Firmware
Loading...
Searching...
No Matches
lerp_lut.h File Reference

Linear interpolation lookup table (LUT). More...

#include <stddef.h>
Include dependency graph for lerp_lut.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  lut_entry_t
 
struct  lerp_lut_t
 

Macros

#define LERP_LUT_INIT(name, _entries, _size)
 

Functions

float lut_lookup (const lerp_lut_t *lut, float key)
 Lookup a value in a linear interpolation lookup table (LUT).
 

Detailed Description

Linear interpolation lookup table (LUT).

Author
Irving Wang (irvin.nosp@m.gw@p.nosp@m.urdue.nosp@m..edu)

Macro Definition Documentation

◆ LERP_LUT_INIT

#define LERP_LUT_INIT ( name,
_entries,
_size )
Value:
const lerp_lut_t name = { \
.entries = _entries, \
.size = _size, \
}; \
static_assert(sizeof(_entries) / sizeof(lut_entry_t) == _size, \
"Entries array size must match _size"); \
static_assert(_size > 1, "LUT size must be greater than 1")
Definition lerp_lut.h:18
Definition lerp_lut.h:13

Function Documentation

◆ lut_lookup()

float lut_lookup ( const lerp_lut_t * lut,
float key )

Lookup a value in a linear interpolation lookup table (LUT).

This function performs a binary search to find the appropriate interval in the LUT and then linearly interpolates between the two nearest entries.

Parameters
lutPointer to the LUT.
keyThe key to look up.
Returns
The interpolated value.
Here is the caller graph for this function: