我要评分
获取效率
正确性
完整性
易理解

kml_?_interp_eval

This function returns the interpolated value y at a given point x. The interpolation object interp, data arrays xarr and yarr, and accelerator xacc are used in the calculation. If x is outside the range of xarr, an error message is returned.

Interface Definition

int kml_float_interp_eval_e(const kml_float_interp *interp, const float xa[],

const float ya[], float x, kml_interp_accel *a, float *y)

float kml_float_interp_eval(const kml_float_interp *interp, const float xa[], const float ya[], float x,

kml_interp_accel *a)

int kml_double_interp_eval_e(const kml_double_interp *interp, const double xa[], const double ya[], double x,

kml_interp_accel *a, double *y);

double kml_double_interp_eval(const kml_double_interp *interp, const double xa[], const double ya[], double x,

kml_interp_accel *a);

Parameters

Parameter

Type

Description

Input/Output

interp

kml_float_interp*, kml_double_interp*

Pointer to an interpolation object.

Input

xa

float, double

Array that stores the value of x.

Input

ya

float, double

Array that stores the value of y.

Input

x

float, double

Value of the solution point x.

Input

y

float, double

Value of the solution point y

Input

a

kml_interp_accel *

Pointer to an accelerator object.

Input

Dependencies

#include "kipl.h"

Examples

const size_t xMin = 4;
const size_t xMax = 2048;
const size_t xSize = 4;
const float xValLo = 1;
const float xValHi = 2;
float xArr[4] = {1,1.33,1.67,2};
float* yArr = (float*)malloc(xSize * sizeof(float));
float x = 1;
float y = 0;
kml_float_interp *interp = kml_float_interp_alloc(kml_float_interp_cspline, xSize);
kml_interp_accel *xacc = kml_interp_accel_alloc();
kml_float_interp_init(interp, xSize, xArr, yArr);
y = kml_float_interp_eval(interp, xArr, yArr, x, xacc);
kml_float_interp_free(interp);
kml_interp_accel_free(xacc);