/* test_sparse.c */ #include #include "sparse.h" #define min(a,b) ((a)<(b)?(a):(b)) #define abs(a) ((a)<0.0?(-(a)):(a)) #define nrow 6 int main(int argc, char * argv[]) { struct sparse A; /* the sparse simultaneous equations */ /* normal A matrix with Y as last column */ struct sparse Ac; /* copy for checking */ double val; double X[nrow]; /* solution of A*X=Y simultaneous equations */ double Y[nrow]; /* extracted Y */ double Yc[nrow]; /* for checking */ double AA[nrow][nrow]; /* for testing */ int i, j; printf("test_sparse.c nrow=%d \n",nrow); sparseInit(&A, nrow); sparseInit(&Ac, nrow); printf("test put(0,4,3.14) and get in A \n"); sparsePut(A,0,4,3.14); val = sparseGet(A,0,4); printf("test put in row, 3.14 should be %g \n",val); printf("test put(5,0,6.28) and get in A \n"); sparsePut(A,5,0,6.28); val = sparseGet(A,5,0); printf("test put in row, 6.28 should be %g \n",val); sparseWrite_All(A); sparseInit(&A, nrow); for(i=0; i=0 && j>=0 && i 0.00001) { printf("either multiply or simeq failed \n"); printf("i=%d, Y[i]=%g yet found \n",i,Yc[i]); } } printf("\n"); printf("simple test of setRHS, getRHS \n"); for(i=0; i