annotate Meerwald/cmp_zhu_sig.c @ 20:bd669312f068

suppress warnings, fix link errors
author Peter Meerwald-Stadler <pmeerw@pmeerw.net>
date Sat, 28 Jan 2023 23:54:58 +0100
parents f83ef905a63d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
1 #include "wm.h"
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
2
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
3 char *progname;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
4
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
5 void usage(void) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
6 fprintf(stderr, "usage: %s [-h] [-C] [-o file] [-v n] -s file file\n\n", progname);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
7 fprintf(stderr, "\t-C\t\toutput correlation only\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
8 fprintf(stderr, "\t-h\t\tprint usage\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
9 fprintf(stderr, "\t-o file\t\toutput file\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
10 fprintf(stderr, "\t-v n\t\tverbosity level\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
11 fprintf(stderr, "\t-s file\t\toriginal signature file\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
12 exit(0);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
13 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
14
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
15 int main(int argc, char *argv[]) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
16
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
17 FILE *in = stdin;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
18 FILE *out = stdout;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
19 FILE *sig = NULL;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
20
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
21 char signature_name[MAXPATHLEN];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
22 char output_name[MAXPATHLEN] = "(stdout)";
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
23 char input_name[MAXPATHLEN] = "(stdin)";
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
24
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
25 int c, i, j, n;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
26 int in_level;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
27 double *cumul_watermark, *orig_watermark;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
28 int *cumul_watermark_count;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
29 int sig_n, in_n;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
30 double sig_a;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
31 int sig_l;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
32 int sig_e, sig_f;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
33 char line[32];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
34 double correlation, maxcorrelation;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
35 double s1, s2, s3;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
36
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
37 int verbose = 0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
38 int correlation_only = 0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
39
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
40 progname = argv[0];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
41
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
42 while ((c = getopt(argc, argv, "h?Co:s:v:")) != EOF) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
43 switch (c) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
44 case 'h':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
45 case '?':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
46 usage();
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
47 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
48 case 'C':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
49 correlation_only = 1;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
50 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
51 case 'o':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
52 if ((out = fopen(optarg, "w")) == NULL) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
53 fprintf(stderr, "%s: unable to open output file %s\n", progname, optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
54 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
55 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
56 strcpy(output_name, optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
57 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
58 case 's':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
59 if ((sig = fopen(optarg, "r")) == NULL) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
60 fprintf(stderr, "%s: unable to open signature file %s\n", progname, optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
61 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
62 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
63 strcpy(signature_name, optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
64 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
65 case 'v':
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
66 verbose = atoi(optarg);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
67 if (verbose < 0) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
68 fprintf(stderr, "%s: verbosity level %d out of range\n", progname, verbose);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
69 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
70 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
71 break;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
72 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
73 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
74
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
75 argc -= optind;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
76 argv += optind;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
77
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
78 if (argc > 1) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
79 usage();
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
80 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
81 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
82
8
f83ef905a63d fixing many warnings
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 0
diff changeset
83 if (argc == 1 && *argv[0] != '-') {
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
84 if ((in = fopen(argv[0], "r")) == NULL) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
85 fprintf(stderr, "%s: unable to open input file %s\n", progname, argv[0]);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
86 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
87 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
88 else
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
89 strcpy(input_name, argv[0]);
8
f83ef905a63d fixing many warnings
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 0
diff changeset
90 }
f83ef905a63d fixing many warnings
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents: 0
diff changeset
91
0
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
92 if (!sig) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
93 fprintf(stderr, "%s: original signature file not specified, use -s file option\n", progname);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
94 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
95 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
96
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
97 fgets(line, sizeof(line), sig);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
98 if (strspn(line, "ZHSG") < 4) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
99 fprintf(stderr, "%s: original signature file %s invalid\n", progname, signature_name);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
100 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
101 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
102
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
103 fgets(line, sizeof(line), in);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
104 if (strspn(line, "ZHWM") < 4) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
105 fprintf(stderr, "%s: watermark file %s invalid\n", progname, input_name);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
106 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
107 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
108
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
109 fscanf(sig, "%d\n", &sig_n);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
110 fscanf(in, "%d\n", &in_n);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
111 if (sig_n != in_n) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
112 fprintf(stderr, "%s: watermark length mismatch (original %d, input %d)\n", progname, sig_n, in_n);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
113 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
114 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
115 if (sig_n <= 0 || sig_n > 32000) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
116 fprintf(stderr, "%s: invalid original watermark length %d\n", progname, sig_n);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
117 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
118 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
119 if (in_n != sig_n) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
120 fprintf(stderr, "%s: invalid watermark length %d, does not match signature length\n", progname, in_n);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
121 exit(1);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
122 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
123
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
124 fscanf(sig, "%lf\n", &sig_a);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
125 fscanf(sig, "%d\n", &sig_l);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
126 fscanf(sig, "%d\n", &sig_e);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
127 fscanf(sig, "%d\n", &sig_f);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
128 fscanf(sig, "%*[^\n\r]\n");
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
129
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
130 orig_watermark = malloc(sig_n * sizeof(double));
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
131 for (i = 0; i < sig_n; i++)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
132 fscanf(sig, "%lf\n", &orig_watermark[i]);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
133 fclose(sig);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
134
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
135 fscanf(in, "%d\n", &in_level);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
136
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
137 cumul_watermark = malloc(in_n * sizeof(double));
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
138 cumul_watermark_count = malloc(in_n * sizeof(int));
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
139
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
140 for (i = 0; i < in_n; i++) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
141 cumul_watermark_count[i] = 0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
142 cumul_watermark[i] = 0.0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
143 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
144
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
145 /*
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
146 * normalized correlation
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
147 * Craver, S., "Can Invisible Watermarks Resolve Rightful Ownership?", IBM Research Report, 1996, p. 5
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
148 */
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
149 maxcorrelation = -10000.0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
150 for (i = 0; i < in_level; i++) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
151 fscanf(in, "%d\n", &n);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
152
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
153 s1 = s2 = s3 = 0.0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
154 for (j = 0; j < n; j++) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
155 double in_x, sig_x;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
156
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
157 sig_x = orig_watermark[j];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
158 fscanf(in, "%lf\n", &in_x);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
159
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
160 s1 += sig_x * in_x;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
161 s2 += in_x * in_x;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
162 s3 += sig_x * sig_x;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
163
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
164 if (verbose > 2)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
165 fprintf(stderr, "%s: level %d; orig %f input %f\n", progname, i, sig_x, in_x);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
166
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
167 cumul_watermark[j % in_n] += in_x;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
168 cumul_watermark_count[j % in_n]++;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
169 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
170
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
171 correlation = s1 / sqrt(s2 * s3);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
172 if (correlation > maxcorrelation)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
173 maxcorrelation = correlation;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
174
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
175 if (!correlation_only)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
176 fprintf(out, "%s: correlation level %d: %f\n", progname, i, correlation);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
177 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
178
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
179 s1 = s2 = s3 = 0.0;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
180 for (i = 0; i < in_n; i++) {
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
181 double in_x, sig_x;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
182
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
183 in_x = cumul_watermark[i] / (double) cumul_watermark_count[i];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
184 sig_x = orig_watermark[i];
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
185
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
186 s1 += sig_x * in_x;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
187 s2 += in_x * in_x;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
188 s3 += sig_x * sig_x;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
189 }
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
190
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
191 correlation = s1 / sqrt(s2 * s3);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
192 if (!correlation_only)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
193 fprintf(out, "%s: cumultative correlation: %f\n", progname, correlation);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
194
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
195 if (correlation > maxcorrelation)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
196 maxcorrelation = correlation;
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
197
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
198 if (!correlation_only)
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
199 fprintf(out, "%s: max. correlation: %f\n", progname, maxcorrelation);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
200 else
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
201 fprintf(out, "%f\n", maxcorrelation);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
202
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
203 fclose(out);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
204 fclose(in);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
205
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
206 free(orig_watermark);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
207 free(cumul_watermark);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
208 free(cumul_watermark_count);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
209
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
210 exit(0);
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
211 }

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.