0
|
1 /*
|
|
2 for i in $IMS/_distribution; do ./covident $i computed/$(basename $i); done
|
|
3 gcc -O3 -D_FILE_OFFSET_BITS=64 covident.c -o covident
|
|
4 **********/
|
|
5
|
|
6 #include <stdio.h>
|
|
7 #include <stdlib.h>
|
|
8 #include <string.h>
|
|
9 #include <inttypes.h>
|
|
10
|
|
11 #define MAXLID 200
|
|
12 #define OUT_MATSIZE 101
|
|
13
|
|
14
|
|
15
|
|
16 int main(int argc, char ** av){
|
|
17
|
|
18 if(argc != 3){ printf("USE:covident in output.MAT\n"); exit(-1); }
|
|
19
|
|
20
|
|
21 FILE * f, * g;
|
|
22 f = fopen(av[1], "rt");
|
|
23 if(f == NULL){
|
|
24 printf("Error opening input file\n");
|
|
25 exit(-1);
|
|
26 }
|
|
27 g = fopen(av[2], "wt");
|
|
28 if(g == NULL){
|
|
29 printf(" Error opening output file %s\n", av[2]);
|
|
30 exit(-1);
|
|
31 }
|
|
32
|
|
33
|
|
34 uint64_t matrix[OUT_MATSIZE][OUT_MATSIZE];
|
|
35 uint64_t i,j;
|
|
36 for(i=0;i<OUT_MATSIZE;i++){
|
|
37 for(j=0;j<OUT_MATSIZE;j++){
|
|
38 matrix[i][j] = 0;
|
|
39 }
|
|
40 }
|
|
41 uint64_t cov, ident, len;
|
|
42 while(!feof(f)){
|
|
43
|
|
44 if(3 != fscanf(f, "%"PRIu64" %"PRIu64" %"PRIu64, &cov, &ident, &len) && !feof(f)){ printf("Did not read 3\n"); exit(-1);}
|
|
45 matrix[cov][ident]++;
|
|
46
|
|
47
|
|
48 }
|
|
49
|
|
50
|
|
51 for(i=0;i<OUT_MATSIZE;i++){
|
|
52 for(j=0;j<OUT_MATSIZE;j++){
|
|
53 fprintf(g, "%"PRIu64"\t", matrix[i][j]);
|
|
54 }
|
|
55 fprintf(g, "\n");
|
|
56 }
|
|
57
|
|
58 fclose(f);
|
|
59 fclose(g);
|
|
60 return 0;
|
|
61 }
|
|
62
|
|
63
|
|
64
|
|
65
|