#include "header.h" gsl_matrix_float GetMat(char matfile[MAXFILELEN]) { FILE *FIn; // to read a file // the vector b is n by 1; the matrix A is n by m int n, m; gsl_matrix_float A; FIn=fopen(matfile,"r"); // read the file of matrix fscanf(FIn,"%d",&n); // get the number of rows of the matrix fscanf(FIn,"%d",&m); // get the number of columns of the matrix A=*gsl_matrix_float_alloc(n,m); // A is n by m gsl_matrix_float_fscanf (FIn,&A); // read values from the file to A fclose(FIn); return A; } gsl_vector_float GetVec(char vecfile[MAXFILELEN]) { FILE *FIn; // to read a file // the vector b is n by 1; the matrix A is n by m int n; gsl_vector_float b; FIn=fopen(vecfile,"r"); // read the file of vector fscanf(FIn,"%d",&n); // get the size of the vector b=*gsl_vector_float_alloc(n); // b is n by 1 gsl_vector_float_fscanf (FIn,&b); // read values from the file to b fclose(FIn); return b; } gsl_vector_float CreatX(char matfile[MAXFILELEN]) { FILE *FIn; // to read a file // the vector x is m by 1 int n, m; gsl_vector_float x; FIn=fopen(matfile,"r"); // read the file of matrix fscanf(FIn,"%d",&n); // get the number of rows of the matrix fscanf(FIn,"%d",&m); // get the number of columns of the matrix x=*gsl_vector_float_alloc(m); // x is a m by 1 vector gsl_vector_float_set_zero(&x); // initialize x as a zero vector fclose(FIn); return x; }