[an error occurred while processing this directive]
[an error occurred while processing this directive]#include <stdio.h> #include <math.h> #define NMAX 8 float x[NMAX]; int set_original(float *x, int len){ for(int i = 0; i < len; i++){ x[i] = i*i; printf("%f\n",x[i]); } } float lag(float *X, int len, float target){ int i, j; int begin = (int)target; > 2 ? nearest - 2: 0; int end = begin + 4 < len ? begin + 4 : len - 1; float ret_y = 0; for(i = begin; i < end; i++){ float upper = 1.0f, lower = 1.0f; for(j = begin; j < end; j++){ if(i != j){ upper *= target - j; lower *= i - j; } } ret_y += (upper / lower) * X[i]; } return ret_y; } void main(void){ set_original(x, NMAX); for(int i = 2; i < 6; i++){ float tgt = i * 0.5f; printf("%f:%f\n",tgt, lag(x,NMAX, tgt)); } }