Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "SparseMatrix.h"
#include "Options.h"
int main(int argc, char **argv) {
FILE *fp;
char filename[MAX_WORD_LENGTH];
struct sparsematrix A;
long nzp;
int q, P;
printf("Test MMSparseMatrixReadPstart: ");
strcpy(filename,"test_MMSparseMatrixReadPstart.inp");
fp = fopen(filename, "r");
if (!fp) {
printf("Error\n");
exit(1);
}
nzp = 10; /* number of nonzeros per processor */
P = 10;
A.MMTypeCode[0] = 'D'; /* distributed matrix */
A.NrNzElts = P * nzp;
A.NrProcs = P;
/* Allocate matrix arrays */
A.Pstart = (long *) malloc((A.NrProcs+1)* sizeof(long));
if (A.Pstart == NULL){
printf("Error\n");
exit(1);
}
MMSparseMatrixReadPstart(&A, fp);
fclose(fp);
/* Check that matrix dimensions and type are the same */
if (A.MMTypeCode[0] != 'D' ||
A.NrNzElts != P * nzp ||
A.NrProcs != P) {
printf("Error\n");
exit(1);
}
/* Check that matrix entries have been read correctly */
for (q = 0; q <= A.NrProcs; q++) {
if (A.Pstart[q] != q * nzp) {
printf("Error\n");
exit(1);
}
}
printf("OK\n");
exit(0);
} /* end main */