#include "SparseMat.h" struct mat_sp ReadSparseMat(char FileName[]){ struct mat_sp A; struct row_sp * row; int i, j, m, n; int k; float z; FILE * fp; /* Opening File for Reading */ fp =fopen(FileName,"r"); /* Set Dimensions */ fscanf(fp,"5903SparseMatrix\n%d\t%d\tfloat\n", &m,&n); A.m = m; A.n = n; /* Initializing Spare Matrix */ A = InitializeSparseMat(m, n); /* Reading in values */ while(k=fscanf(fp,"%d\t%d\t%f\n", &i, &j, &z), k==3) { // Add checking for too many rows! row = A.row[i]; // Add checking for col dimension and storage AppendToSparseRow(row, j, z); } // Book keeping fclose(fp); return A; };