|
muwerk Scheduler Library
A low-resource cooperative scheduler with MQTT-like queues for Arduinos, ATtiny up to ESP32
|
muwerk numericFunction class More...
#include <sensors.h>
Public Member Functions | |
| numericFunction (const T_FLOAT px[], const T_FLOAT py[], unsigned int count, bool _extrapolate=false) | |
| void | rescaleX (T_FLOAT newMin, T_FLOAT newMax) |
| void | rescaleY (T_FLOAT newMin, T_FLOAT newMax) |
| T_FLOAT | interpol (T_FLOAT xi) |
| T_FLOAT | operator() (T_FLOAT x) |
Static Public Member Functions | |
| static T_FLOAT | min (ustd::array< T_FLOAT > ar) |
| static T_FLOAT | max (ustd::array< T_FLOAT > ar) |
| static void | rescale (ustd::array< T_FLOAT > *par, T_FLOAT *pminX, T_FLOAT *pmaxX, T_FLOAT newMin, T_FLOAT newMax) |
| static int | linsearch (ustd::array< T_FLOAT > &ar, T_FLOAT x) |
muwerk numericFunction class
numericFunktion approximates arbitrary values x of a function f(x) defined by a number points (x,y) using linear approximation to nearest neighbour-points.
Example:
|
inline |
Instatiate a numericFunction with point px and py.
| px | array of length count of x-values. |
| py | corresponding array of y-values, f(px[i])=py[i] |
| count | array member count of both px and py |
| _extrapolate | false: if px is ouside of the defined points, x<min(px) gives py[0], x>max(px) gives py[count-1], on true linear approximation is used. |
|
inline |
Get interpolated value at point f(xi)
| xi | Value of x used to interpole f(x) |
|
inlinestatic |
Get largest index element in ar that is smaller than x using bineary search.
Note: ar must be strictly monotone rising. If x is outside of minX and maxX, the nearest array index (either 0 or length-1) is given.
| ar | ustd::array |
| x | value to be searched |
|
inlinestatic |
get maximum value of array ar
| ar | ustd::array |
|
inlinestatic |
get minimum value of array ar
| ar | ustd::array |
|
inline |
interpolate f(x), uses interpol()
| x | value to be approximated by f(x). |
|
inlinestatic |
inplace rescale an array so that it conforms to newMin and newMax
Note: current minimum and maximum must be given to pminX and pmaxX (see min(), max() ).
| par | point to ustd::array to be rescaled |
| pminX | pointer to mimimum value of array-members in ar, will be overwriten with new actual minimum. |
| pmaxX | pointer to maximum value of array-members in ar, will be overwriten with new actual maximum. |
| newMin | The entire array ar is transformed linearily so that the new minimum is newMin |
| newMax | The entire array ar is transformed linearily so that the new maximum is newMax. |
|
inline |
Rescale x-axis linearily
| newMin | new start of x-values |
| newMax | new end of x-values |
|
inline |
Rescale y-axis linearily
| newMin | new start of y-values |
| newMax | new end of y-values |