Zephyr Scientific Library (zscilib)
interp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2020 Kevin Townsend (KTOWN)
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
21 #ifndef ZEPHYR_INCLUDE_ZSL_INTERP_H_
22 #define ZEPHYR_INCLUDE_ZSL_INTERP_H_
23 
24 #include <stdint.h>
25 #include <zsl/zsl.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
40 struct zsl_interp_xy {
43 };
44 
50 };
51  /* End of INTERP_STRUCTS group */
53 
93 
107 int zsl_interp_find_x(struct zsl_interp_xy xy[], size_t n, zsl_real_t x,
108  int *idx);
109 
121 int zsl_interp_nn(struct zsl_interp_xy *xy1, struct zsl_interp_xy *xy3,
122  zsl_real_t x2, zsl_real_t *y2);
123 
135 int zsl_interp_nn_arr(struct zsl_interp_xy xy[], size_t n, zsl_real_t x,
136  zsl_real_t *y);
137 
149 int zsl_interp_lin_y(struct zsl_interp_xy *xy1, struct zsl_interp_xy *xy3,
150  zsl_real_t x2, zsl_real_t *y2);
151 
163 int zsl_interp_lin_y_arr(struct zsl_interp_xy xy[], size_t n, zsl_real_t x,
164  zsl_real_t *y);
165 
177 int zsl_interp_lin_x(struct zsl_interp_xy *xy1, struct zsl_interp_xy *xy3,
178  zsl_real_t y2, zsl_real_t *x2);
179 
191 int zsl_interp_cubic_calc(struct zsl_interp_xyc xyc[], size_t n,
192  zsl_real_t yp1, zsl_real_t ypn);
193 
205 int zsl_interp_cubic_arr(struct zsl_interp_xyc xyc[], size_t n,
206  zsl_real_t x, zsl_real_t *y);
207  /* End of INTERP_FUNCS group */
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #endif /* ZEPHYR_INCLUDE_ZSL_INTERP_H_ */
215  /* End of interpolation group */
zsl_interp_lin_y
int zsl_interp_lin_y(struct zsl_interp_xy *xy1, struct zsl_interp_xy *xy3, zsl_real_t x2, zsl_real_t *y2)
Linear (AKA 'piecewise linear') interpolation for Y between two points, based on zsl_real_ts.
Definition: interp.c:155
zsl_interp_lin_x
int zsl_interp_lin_x(struct zsl_interp_xy *xy1, struct zsl_interp_xy *xy3, zsl_real_t y2, zsl_real_t *x2)
Linear (AKA 'piecewise linear') interpolation for X between two points, based on zsl_real_ts.
Definition: interp.c:216
zsl_interp_cubic_arr
int zsl_interp_cubic_arr(struct zsl_interp_xyc xyc[], size_t n, zsl_real_t x, zsl_real_t *y)
Natural cubic spline interpolation between two points, based on zsl_real_ts.
Definition: interp.c:322
zsl_interp_nn
int zsl_interp_nn(struct zsl_interp_xy *xy1, struct zsl_interp_xy *xy3, zsl_real_t x2, zsl_real_t *y2)
Nearest neighbour (AKA 'piecewise constant') interpolation based on zsl_real_ts.
Definition: interp.c:100
zsl_interp_cubic_calc
int zsl_interp_cubic_calc(struct zsl_interp_xyc xyc[], size_t n, zsl_real_t yp1, zsl_real_t ypn)
Calculates xyc[n].y2 for natural cubic spline interpolation, based on the assigned xyc[n]....
Definition: interp.c:254
zsl_interp_xyc
XY struct for cubic spline interpolation.
Definition: interp.h:46
zsl_interp_xyc::y
zsl_real_t y
Definition: interp.h:48
zsl_interp_lerp
int zsl_interp_lerp(zsl_real_t v0, zsl_real_t v1, zsl_real_t t, zsl_real_t *v)
Calculates a number between two numbers using linear interpolation, where 't' is the interpolation fa...
Definition: interp.c:14
zsl_interp_xyc::y2
zsl_real_t y2
Second derivative from the spline.
Definition: interp.h:49
zsl_interp_xy::x
zsl_real_t x
Definition: interp.h:41
zsl_interp_find_x
int zsl_interp_find_x(struct zsl_interp_xy xy[], size_t n, zsl_real_t x, int *idx)
Uses bisection to search the zsl_interp_xy array for the closest array position to 'x',...
Definition: interp.c:33
zsl.h
API header file for zscilib.
zsl_interp_nn_arr
int zsl_interp_nn_arr(struct zsl_interp_xy xy[], size_t n, zsl_real_t x, zsl_real_t *y)
Nearest neighbour (AKA 'piecewise constant') interpolation based on an array of zsl_real_ts.
Definition: interp.c:129
zsl_interp_lin_y_arr
int zsl_interp_lin_y_arr(struct zsl_interp_xy xy[], size_t n, zsl_real_t x, zsl_real_t *y)
Linear (AKA 'piecewise linear') interpolation for Y between two points, based on zsl_real_ts.
Definition: interp.c:190
zsl_real_t
double zsl_real_t
Definition: zsl.h:51
zsl_interp_xy
XY struct for nearest neighbour and linear interpolation.
Definition: interp.h:40
zsl_interp_xyc::x
zsl_real_t x
Definition: interp.h:47
zsl_interp_xy::y
zsl_real_t y
Definition: interp.h:42