#include #include #include #define DIM 4 //Parameter DIM specifying the dimension of the x variable //Typedefs for vector and matrix types typedef struct {int n; float *fp;} Vector; //n vector typedef struct {int n; int m; float *fp;} Matrix; //n by m matrix flat storage typedef struct {int F; int dF; int ddF;} Int3; //Indicators for function F //derivative dF and second derivative evaluation //Also used for counting evaluations //BookKeeping prototypes Vector CreateVector(int); void DestroyVector(Vector); Matrix CreateMatrix(int, int); void DestroyMatrix(Matrix); //IO prototypes Vector ReadVector(void); Matrix ReadMatrix(void); void PrintVector(Vector); void PrintMatrix(Matrix); //Prototypes for optimization function //computes f(x) and returns values //in Fp as specified by the integer spec: // spec=0 compute f and return 0; // spec=1 skip evaluation and return current function count int fA(Vector x, float *Fp, int spec); //Prototypes for optimization function //computes f(x) and dF(X0 AND ddF(X) returns values //in Fp AND dFP AND ddFP as in an Int3 spec: // {0,0,0} compute em all; // {0,0,1} compute only f and Df // {1,1,1} return counters as an Int3 {nf, nDf, nDDf} Int3 fB(Vector x, float *Fp, Vector *Dfp, Matrix *DDfp, Int3 spec);