#include "SparseMatrix.h" main(){ SparseMatrix A, B; SparseRow FirstRow, SecondRow, Row; int i,j,k,nz; float z; // Decided the size and set up space for the pointers to the rows A.m = 2; A.n = 3; A.RowPointer = (SparseRow *) malloc(A.m * sizeof(SparseRow)); // Decided the number of non-zero entries in FirstRow and set up // space for the pointers to js and entries FirstRow.n = A.n; FirstRow.nz = 2; FirstRow.jVals = (int *) malloc(FirstRow.nz * sizeof(int)); FirstRow.matVals = (float *) malloc(FirstRow.nz * sizeof(float)); // Decided the number of non-zero entries in SecondRow and set up // space for the pointers to js and entries SecondRow.n = A.n; SecondRow.nz = 1; SecondRow.jVals = (int *) malloc(SecondRow.nz * sizeof(int)); SecondRow.matVals = (float *) malloc(SecondRow.nz * sizeof(float)); // Assigning values for FirstRow FirstRow.jVals[0]=0; FirstRow.matVals[0]=1.2; FirstRow.jVals[1]=2; FirstRow.matVals[1]=6.7; // Assigning values for SecondRow SecondRow.jVals[0]=2; SecondRow.matVals[0]=8.9; // Associate RowPointer in A with FirstRow and SecondRow *(A.RowPointer + 0) = FirstRow; *(A.RowPointer + 1) = SecondRow; printf("SparseMatrixTest: m=%i n=%i\n",A.m,A.n); for(i=0;i%f\n", i, Row.jVals[k], Row.matVals[k]); }; // Random Matrix. B.m = 10; B.n = 8; nz = 2; B.RowPointer = (SparseRow *) malloc(B.m * sizeof(SparseRow)); for(i=0;i%f\n", i, Row.jVals[k], Row.matVals[k]); }; };