由买买提看人间百态

topics

全部话题 - 话题: nxpts
(共0页)
n******0
发帖数: 61
1
google some introduction or read R extesion,
example cited from "An Introduction to the .C Interface to R":
#include
#include
void kernel_smooth(double *x, int *n, double *xpts, int *nxpts,
double *h, double *result)
{
int i, j;
double d, ksum;
for(i=0; i < *nxpts; i++) {
ksum = 0;
for(j=0; j < *n; j++) {
d = xpts[i] - x[j];
ksum += dnorm(d / *h, 0, 1, 0); // see use R function in C code
}
result[i] = ksum / ((*n) * (*h));
}
}
(共0页)