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
62
63
#include "SparseMatrix.h"
int main(int argc, char **argv) {
long m, n, nz, t, sumi, sumj ;
double sumre, sumim ;
int P ;
struct sparsematrix A ;
printf("Test MMSparseMatrixAllocateMemory: ");
m = 24 ;
n = 17 ;
nz = 10 ;
P = 4 ;
A.m = m ;
A.n = n ;
A.NrNzElts = nz ;
A.NrProcs = P ;
A.MMTypeCode[2] = 'C' ; /* complex matrix */
A.MMTypeCode[0] = 'D' ; /* distributed matrix, we do not test
a weighted matrix */
MMSparseMatrixAllocateMemory(&A) ;
if ( A.i == NULL || A.j == NULL || A.ReValue == NULL ||
A.ImValue == NULL || A.Pstart == NULL ){
printf("Error\n") ;
exit(1);
}
for (t=0; t<nz; t++){
A.i[t] = t ;
A.j[t] = -t ;
A.ReValue[t] = t ;
A.ImValue[t] = -t ;
}
/* Compute sum */
sumi = 0;
sumj = 0;
sumre = 0.0;
sumim = 0.0;
for (t=0; t<nz; t++){
sumi += A.i[t] ;
sumj += A.j[t] ;
sumre += A.ReValue[t] ;
sumim += A.ImValue[t] ;
}
/* Check sum of array elements */
if (sumi != (nz-1)*nz/2 ||
sumj != -sumi ||
sumi != (long)(sumre+0.5) ||
sumi != (long)(-sumim+0.5) ){
printf("Error\n") ;
exit(1);
}
printf("OK\n") ;
exit(0);
} /* end main */