radial_evaluate
Evaluates a radial-basis fit.
Synopsis
#include <imsl.h>
float *imsl_f_radial_evaluate (int n, float x[], Imsl_d_radial_basis_fit *radial_fit, , 0)
The type double function is imsl_d_evaluate.
Required Arguments
int n (Input)
The number of points at which the fit will be evaluated.
float x[] (Input)
Array of size (radial_fit -dimension× n containing the abscissae of the data points at which the fit will be evaluated. The argument x[i][j] is the abscissa value of the (i+1)-th data point in the (j+1)-th dimension.
Imsl_f_radial_basis_fit *radial_fit (Input)
A pointer to radial-basis structure to be used for the evaluation. (Input).
Return Value
A pointer to an array of length n containing the values of the radial-basis fit at the desired values. If no value can be computed, then NULL is returned. To release this space, use imsl_free.
Synopsis with Optional Arguments
#include <imsl.h>
float *imsl_f_radial_evaluate (int n, float x[], Imsl_f_radial_basis_fit *radial_fit
IMSL_RETURN_USER, float value[],
0)
Optional Arguments
IMSL_RETURN_USER, float value[] (Input)
A user-allocated array of length n containing the returned values.
Description
The function imsl_f_radial_evaluate evaluates a radial-basis fit from data generated by imsl_f_radial_scattered_fit.
Example
 
#include <imsl.h>
#include <math.h>
 
#define NDATA 10
#define NUM_CENTERS 5
#define NOISE_SIZE 0.25
#define F(x) ((float)(sin(2*pi*x)))
 
int main ()
{
int i;
int dim = 1;
float fdata[NDATA];
float *fdata2;
float xdata[NDATA];
float xdata2[2*NDATA];
float pi;
float *noise;
Imsl_f_radial_basis_fit *radial_fit;
 
pi = imsl_f_constant ("pi", 0);
 
imsl_random_seed_set (234579);
noise = imsl_f_random_uniform(NDATA, 0);
 
/* Set up the sampled data points with noise */
 
for (i = 0; i < NDATA; ++i) {
xdata[i] = (float)(i)/(float)(NDATA-1);
fdata[i] = F(xdata[i]) + NOISE_SIZE*(1.0 - 2.0*noise[i]);
}
/* Compute the radial fit */
 
radial_fit = imsl_f_radial_scattered_fit (dim, NDATA, xdata,
fdata, NUM_CENTERS, 0);
/* Compare result to the original function at twice as many values as there
were original data points */
 
for (i = 0; i < 2*NDATA; ++i)
xdata2[i] = (float)(i/(float)(2*(NDATA-1)));
 
/* Evaluate the fit at these new points */
fdata2 = imsl_f_radial_evaluate(2*NDATA, xdata2, radial_fit, 0);
 
printf(" I TRUE APPROX ERROR\n");
for (i = 0; i < 2*NDATA; ++i)
printf("%5d %10.5f %10.5f %10.5f\n",i+1,F(xdata2[i]), fdata2[i],
F(xdata2[i])-fdata2[i]);
}
Output
 
I TRUE APPROX ERROR
1 0.00000 -0.08980 0.08980
2 0.34202 0.38795 -0.04593
3 0.64279 0.75470 -0.11191
4 0.86603 0.99915 -0.13312
5 0.98481 1.11597 -0.13116
6 0.98481 1.10692 -0.12211
7 0.86603 0.98183 -0.11580
8 0.64279 0.75826 -0.11547
9 0.34202 0.46078 -0.11876
10 -0.00000 0.11996 -0.11996
11 -0.34202 -0.23007 -0.11195
12 -0.64279 -0.55348 -0.08931
13 -0.86603 -0.81624 -0.04979
14 -0.98481 -0.98752 0.00271
15 -0.98481 -1.04276 0.05795
16 -0.86603 -0.96471 0.09868
17 -0.64279 -0.74472 0.10193
18 -0.34202 -0.38203 0.04001
19 0.00000 0.11600 -0.11600
20 0.34202 0.73553 -0.39351