Debian Codegraph @

meryl/unaryOp.C

raw symbols SCIP
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 #include "meryl.H"
6 #include "libmeryl.H"
7
8
9 void
10 unaryOperations(merylArgs *args) {
11
12 if (args->mergeFilesLen != 1) {
13 fprintf(stderr, "ERROR - must have exactly one file!\n");
14 exit(1);
15 }
16 if (args->outputFile == 0L) {
17 fprintf(stderr, "ERROR - no output file specified.\n");
18 exit(1);
19 }
20 if ((args->personality != PERSONALITY_LEQ) &&
21 (args->personality != PERSONALITY_GEQ) &&
22 (args->personality != PERSONALITY_EQ)) {
23 fprintf(stderr, "ERROR - only personalities lessthan, lessthanorequal,\n");
24 fprintf(stderr, "ERROR - greaterthan, greaterthanorequal, and equal\n");
25 fprintf(stderr, "ERROR - are supported in unaryOperations().\n");
26 fprintf(stderr, "ERROR - this is a coding error, not a user error.\n");
27 exit(1);
28 }
29
30 // Open the input and output files -- we don't know the number
31 // unique, distinct, and total until after the operation, so we
32 // leave them zero.
33 //
34 merylStreamReader *R = new merylStreamReader(args->mergeFiles[0]);
35 merylStreamWriter *W = new merylStreamWriter(args->outputFile, R->merSize(), R->merCompression(), R->prefixSize(), R->hasPositions());
36
37 switch (args->personality) {
38 case PERSONALITY_LEQ:
39 while (R->nextMer())
40 if (R->theCount() <= args->desiredCount)
41 W->addMer(R->theFMer(), R->theCount(), R->thePositions());
42 break;
43
44 case PERSONALITY_GEQ:
45 while (R->nextMer())
46 if (R->theCount() >= args->desiredCount)
47 W->addMer(R->theFMer(), R->theCount(), R->thePositions());
48 break;
49
50 case PERSONALITY_EQ:
51 while (R->nextMer())
52 if (R->theCount() == args->desiredCount)
53 W->addMer(R->theFMer(), R->theCount(), R->thePositions());
54 break;
55 }
56
57 delete R;
58 delete W;
59 }