#include #include #define MAXFILELEN 80 #define TOLERANCE 10.0E-6 //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); //GSL Conversion prototypes //See GSL web documentation at http://www.gnu.org/software/gsl/manual gsl_vector_float to_gsl_vector_float(Vector x); //Prototypes for CG function // Solves A x = b for x (which is rturned) // Tolerance is the L1 norm of the residual // Max Iter is the maximum nuber of iterations // If it hits MaxIter it returns a vector with dimension listed as -n // and the storage is the current iterate Vector CG(Matrix A, Vector b, float Tol, int MaxIter);