#include "header.h" // Function for Optimization Function A // Compute f(x) and return it in fp int fA(Vector x,float *fp,int spec) { int i; static int c=0; // a counter, static variable, always in the same place float fsum=0.0; if(spec==1) // spec=1 for give the count of the current number of evaluations { return c; } else // spec=0 for compute the function { c++; for(i=1; i<=(x.n)-2; i++) { fsum+=(float) sin(x.fp[i]*x.fp[i+1]+cos(x.fp[i-1]-x.fp[i])); // calculate the value of f(x) } *fp=fsum; } return 0; }