KIPL_Csval
计算三次样条拟合函数在位置x的值。
接口定义
float KIPL_Csval(float xi, int initv, float *xData, float *coef)
参数
| 参数名 | 类型 | 描述 | 输入/输出 | 
|---|---|---|---|
| xi | 单精度浮点数 | 需要计算三次样条拟合值的位置。 | 输入 | 
| initv | 整型数 | 表示拟合得到三次多项式个数,等于nData-1。 | 输入 | 
| xData | 单精度浮点数组 | 长度为initv+1的数组,表示数据点的横坐标。 | 输入 | 
| coef | 单精度浮点数组 | 长度为4*(initv+1)的数组,表示生成的系数序列。 | 输出 | 
依赖
#include "kipl.h"
示例
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #include <stdio.h> #include <math.h> #include "kipl.h" int main() { int data_n = 11; float data_x[data_n]; float data_y[data_n]; for (int i = 0; i < data_n; i++) { data_x[i] = (float)(i) / (data_n - 1); data_y[i] = sin(15.0 * data_x[i]); } int test_n = 2 * data_n - 1; float test_x[test_n]; float test_y[test_n]; for (int i = 0; i < test_n; i++) { test_x[i] = (float)(i) / (test_n - 1); test_y[i] = sin(15.0 * test_x[i]); } float b[data_n], cscoef[4 * data_n]; KIPL_Csint(data_n, data_x, data_y, cscoef); int nintv = data_n - 1; for (int i = 0; i < test_n; i++) { float y; float x = test_x[i]; y = KIPL_Csval(x, nintv, data_x, cscoef); printf("%f %f\n", x, y); } return 0; } | 
父主题: 三次样条函数