commit 389749abaad9bc4a007c0a11beb89452499bb331
parent 587e0ba4ad040fa7129032ddd52f1cdbfbed5959
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 13 Mar 2024 16:21:17 +0100
Rename swf_interpolation to swf_prediction
This list specifies the type of prediction to be made, either linear or
quadratic. But whereas the SWF_LINEAR constant actually leads to linear
interpolation, the SWF_QUADRATIC constant is used for quadratic
extrapolation of tabulated data. The term interpolation was therefore
inappropriate, hence the renaming.
Diffstat:
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/swf.h b/src/swf.h
@@ -31,7 +31,7 @@
#define SWF(Func) swf_ ## Func
#endif
-enum swf_interpolation {
+enum swf_prediction {
SWF_LINEAR,
SWF_QUADRATIC
};
@@ -137,7 +137,7 @@ swf_tabulation_ref_put
SWF_API double /* x */
swf_tabulation_inverse
(const struct swf_tabulation* tab,
- const enum swf_interpolation interpolation,
+ const enum swf_prediction prediction,
const double y); /* in [0, 1[ */
END_DECLS
diff --git a/src/swf_tabulation.c b/src/swf_tabulation.c
@@ -101,7 +101,7 @@ swf_tabulation_ref_put(struct swf_tabulation* tab)
double
swf_tabulation_inverse
(const struct swf_tabulation* tab,
- const enum swf_interpolation interpolation,
+ const enum swf_prediction prediction,
const double y)
{
const struct item* items = NULL;
@@ -109,7 +109,7 @@ swf_tabulation_inverse
double x = 0; /* Argument corresponding to input value y */
size_t nitems = 0;
ASSERT(tab && y >= 0 && y < 1);
- ASSERT(interpolation == SWF_LINEAR || interpolation == SWF_QUADRATIC);
+ ASSERT(prediction == SWF_LINEAR || prediction == SWF_QUADRATIC);
items = darray_item_cdata_get(&tab->items);
nitems = darray_item_size_get(&tab->items);
@@ -128,11 +128,10 @@ swf_tabulation_inverse
/* The input y correspond exactly to a tabulated argument */
if(find->fx == y) return find->x;
- /* Linear interpolation of tabulated arguments containing the argument
- * corresponding to the input value */
ASSERT(find > items && find[-1].fx < y);
- switch(interpolation) {
+ /* Predict x values from of tabulated arguments */
+ switch(prediction) {
case SWF_LINEAR:
x = linear_interpolation(y, &find[-1], &find[0]);
break;