#include #include #include #include #include #include #define TOLERANCE 1e-4 #define MAX_ITRN 20 struct Vector { int n; //dimension (number of items) float *p; //values }; typedef struct Vector Vec; struct Matrix { int n; //# of rows int m; //# of columns float *p; //values }; typedef struct Matrix Mat; // vector/matrix allocation and resources free Vec * createVec(int n); void destroyVec(Vec * vecP); Mat * createMat(int n, int m); void destroyMat(Mat * matP); // Vector/Matrix io Vec * readVec(FILE * vecInFile); void writeVec(Vec * vecWriteP, FILE * outFile); Mat * readMat(FILE * matInFile); void writeMat(Mat * matP, FILE * outFile); //computes the eigenvalues of A, return the ordered (from largest // to smallest) eigenvalues in v, with a maximum of n iterations, // untill it satisfies some error estimate less than Tol int QREvals(Mat * A, Vec * v, int n, float Tol); //function used by qsort for to compare two vectors of type Vec int vecCompare(const void * a, const void * b); //gsl function used by qsort to compare two vectors of type gsl_vector int gslVecCompare(const void * a, const void * b); //max, min functions double max(double a, double b); double min(double a, double b); //check if Matrix of type Mat is symmetric int isMatSymm(const Mat * A);