-
Notifications
You must be signed in to change notification settings - Fork 1
/
thintest.c
171 lines (154 loc) · 8.36 KB
/
thintest.c
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Copyright (C) 2011-2012 Gad Abraham and National ICT Australia (NICTA).
* All rights reserved.
*/
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "common.h"
#include "thin.h"
int main(void)
{
int i;
double *y = malloc(sizeof(double) * 15);
double x[25] = {
-0.827, -0.724, -1.278, -0.821, -2.3, -0.566, -0.123,
0.296, -0.093, -0.619, 1.602, 0.065, -0.549, -0.855, 0.055, -0.245,
-1.652, 0.547, 0.234, 0.908, -0.707, 1.665, 0.167, -2.399, -0.974
};
double y2[15] = {
-0.827, -0.724, -2.3, -0.566, -0.123, -0.619, 1.602,
0.065, 0.055, -0.245, -1.652, 0.908, -0.707, 1.665, -0.974
};
double x2[1000] = {
-0.46, -0.76, -1.09, -0.08, 0.01, 0.74, 1, 2.66, -1.08, 2.03,
0.86, 1.65, -1.38, -0.33, 0.66, -0.64, 1.79, -0.73, -1.1, -1.31,
1.06, 0.73, -0.17, 0.02, 1.17, 0.12, 0.11, -0.18, -0.49, 0.46,
-1.01, -0.62, -0.4, 0.12, 0.08, 0.27, 1.94, -0.91, -0.76, 0.9,
0.88, -0.58, -0.88, 0.37, 0.49, 0.73, 0.75, -1.22, -0.26, 0.08,
-0.48, 0.22, 0.36, -1.59, -1.4, 1.61, -0.03, 0.28, -0.75, 0.53,
0.95, -0.57, -0.97, 0.43, -1.99, -0.16, 1.01, -0.33, -0.59,
0.49, -0.62, -0.76, 0.21, -0.39, 0.74, -0.5, 1.34, 0.07, -0.3,
-0.36, 0.23, 0.55, -0.28, 0.56, 2.14, 0.01, -1.12, 1.87, 0.27,
-0.85, -0.66, 0.33, -1.04, 1.01, 0.87, 0.13, 1.05, 0.43, -0.23,
0.34, 0.26, 1.83, -0.65, -0.56, 0.66, 1.62, 0.23, -0.77, 1.87,
-0.25, 0.76, -1.07, 0.62, -0.34, 0.17, 0.43, -0.8, 0.92, 0.3,
0.15, 0.83, -2.08, 0.15, -0.81, 0.98, -0.04, 1.04, -0.99, -0.48,
0.54, 1.41, -0.44, -0.58, -0.07, -0.11, 1.77, 0.94, -0.77,
-0.46, 0.8, -0.15, 0.56, -2.49, 0.45, 0.26, -1.1, 0.44, -0.45,
-0.27, 0.37, 0.47, -0.49, -0.13, 0.85, 0.55, 0.68, 1.31, 0.43,
-0.53, -1.29, 1.16, -1.01, 0.57, 1.2, -1.21, -1.11, 0.26, -0.85,
-0.41, -2.42, 1.11, -0.36, 1.6, 0.6, -0.01, 2.39, 0.35, -0.51,
0.08, 0.33, -0.97, 0.55, -0.77, -1.08, -0.65, -0.97, -1.65,
-0.39, 0.86, 1.31, 1.28, -1.02, 0.63, 1.27, -0.8, 0.28, -0.28,
-0.42, 0.55, -0.8, 0.48, -1.98, 1.44, -2, 0.15, -1.69, 0.26,
-0.28, -0.08, -0.89, -0.42, -0.43, -0.16, 0.19, 0.12, -0.19,
-0.64, -0.09, 0.79, 2.42, 0.62, -1.03, 1.71, -2.23, -1.33, 1.33,
1.52, 0.23, 0.24, -0.24, -0.58, -0.84, -1.08, 0.75, -0.32,
-0.38, -0.22, 1.53, -0.53, 0.12, -0.06, -1.94, -1.2, -0.43,
0.96, -0.22, -0.34, -0.2, -1.21, 0.2, 0.63, 1.06, 0.39, 0.7,
0.39, -0.33, -1.21, 0.95, -1.08, -0.45, 0.67, 0.43, -1.51,
-1.33, -0.5, -0.42, -0.73, -0.41, -0.97, -1.32, 0.24, 0.11,
-0.31, -0.22, 1.18, 0.27, -0.22, -1.67, -0.11, 1.76, -0.07,
-1.27, 0.75, 0.13, -0.01, 1.42, -0.83, -0.9, -0.86, -0.6, -0.46,
0.14, 0.51, 1.65, -0.05, 0.06, 1.16, 0.94, -1.87, 0.14, -0.59,
-0.14, -0.61, 1.3, -1.06, 0.79, 0.48, -0.11, -1.21, -0.28, 0.06,
-0.35, 0.36, 1.08, -0.47, 1.13, 0.04, 1.59, -0.67, 0.93, 0.76,
-2.66, 0.63, -0.52, 0.88, -0.31, -1.69, 1.86, -0.16, -0.29,
-0.53, 0.9, -0.05, 0.54, -0.64, -0.61, 0.52, -0.61, 0.2, -1.04,
-0.41, -0.69, -1.29, -0.21, -0.64, 0.85, 0.34, -2.08, -0.31,
2.22, -0.08, -1.13, -0.4, 0.05, 0.3, 0.65, -0.37, 0.85, -2.67,
0.04, -0.64, 0.4, -0.22, 0.02, 1.7, -0.42, 0.76, -0.03, -0.04,
-0.86, 1.06, -0.54, -1.35, 0.66, 0.09, -0.3, -0.03, 0.26, 0.21,
-1, 1.15, -1, -1.53, -0.38, 1.77, -0.67, -0.27, -0.68, -0.03,
-0.39, 1.51, -0.27, -0.28, 0.47, 0.74, 1.01, 0.57, 0.44, -1.55,
-1.4, 0.58, 0.14, -1.67, -1.12, -0.74, -0.21, 0.69, 0.76, 0.78,
0.86, 0.04, 1.45, -1.53, 0.32, -1.72, 1.1, 1.66, 1.07, -1.01, 1,
0.29, 0.24, -0.61, 0.84, -0.93, 2.28, -0.75, -0.03, -1.13,
-1.23, 1.32, -0.63, 0.06, -1.45, -2.28, -1.98, -1.44, 0.74,
-0.78, -0.61, -0.03, -0.22, -1.43, 1.24, -0.17, -0.45, -0.49,
-0.45, 2.05, -0.5, -0.14, 0.59, -1.66, 1.63, -0.88, 1.45, -0.5,
-2.07, -1.7, 0.34, -0.54, 0.33, -0.35, 0.14, -0.02, -1.01, 0.7,
-0.58, 1.44, 0.52, 0.17, 0.53, -1.57, 0.93, -0.92, 0.2, -1.72,
-0.66, -0.95, -1.57, 1.53, 0.75, -0.01, 0.54, 0.2, 0.83, 0.3,
-1.25, -0.18, -0.01, 1.06, 0.51, 0.06, -0.5, -0.6, 0.86, 0.68,
0.74, -2.22, 0.44, -1.38, 0.73, -1.13, -1.14, -1.12, 0.51,
-0.63, 1.31, 0.32, 0.09, -1.44, 0.03, -0.05, 0.03, 0.81, 1.04,
0.14, 0.49, 0.42, 0.3, 0.91, -0.67, -2.32, -0.6, 0.79, -1.04,
1.4, -0.29, -1.39, -0.73, 0.53, -0.49, -0.28, -0.42, 0.35, 1.27,
-0.09, -1.18, 0.98, 0.27, 0.89, -0.62, 2.15, -0.81, -0.87,
-0.23, -0.83, 0.36, -0.38, 0.27, -1.55, -0.81, -0.24, 0.48,
-0.38, 0.32, 1.05, -0.08, -0.44, -0.92, 0.24, -0.12, 0.19, 0.01,
0.8, 0.11, 0.18, 0.73, 0.29, 0.56, -1.05, 0.37, 1.3, 0.85, -1.6,
0.15, -0.14, 0.1, 0.55, -1.36, 0.83, 0.45, 0.88, 0.23, 0.18,
-0.5, 0.21, 0.5, -0.15, 1.15, -1.12, -0.81, -1.13, -0.82, 0.89,
-0.99, -0.42, 1.08, 0.74, -1.18, -0.55, 0.12, 2.17, 1.82, -0.64,
-0.38, -0.23, -0.73, -0.97, 0.58, -0.48, 0.96, 0.37, 1.83,
-0.54, 0.69, -1.35, 0.58, 0.79, 1.32, -1.53, 0.37, -0.61, 0.9,
2.71, 0.4, -1.34, 0.1, 1.39, 0.29, -0.19, -0.91, -1.08, 0.81, 0,
-0.94, -1.49, -0.49, -0.34, 0.07, 1.69, -0.73, -0.04, 0.52,
-2.02, -0.37, -0.97, -0.71, -0.78, 0.25, -1.63, 0.76, -2.12,
-0.5, 0.93, 0.43, 1.7, -1.92, 0.75, -0.91, -0.4, -0.46, 0.77,
-1.38, -0.33, 1.4, 0.53, 1.62, 0.25, 0.37, 0.54, -0.06, -0.84,
0.75, -1.88, 0.49, 0.11, -0.17, 1.16, 0.67, 0.87, -1.74, 0.03,
1.54, -1.58, 0.35, 0.79, -0.13, 0.7, -0.13, -0.54, -2.17, -0.36,
-0.38, -0.74, -1.01, -1.2, 0.43, 0.6, 0.11, 0.76, 0.43, -0.74,
-1.59, 2.06, -0.33, -0.26, 0.78, -0.83, -1.57, 0.64, 0.41,
-0.92, -1.2, -0.87, 0.2, 1.11, -0.21, 1.15, 1.11, -0.75, 1.53,
0.38, -0.87, 2.24, -0.11, 0.45, 0.07, 0.41, -0.99, -0.71, -0.34,
-1.16, 0.76, 2.1, -2.24, 1.65, 0.29, 0.74, -0.62, 0.55, 0.03,
-0.12, -1.14, -1.95, -1.72, 1.31, 1.48, 0.46, -0.2, 0.24, -1.21,
0.25, 0.79, -0.51, -0.59, 0.02, 0.7, 0.77, 1.16, 1.11, 2.73,
-1.54, -1.26, -0.04, 0.39, 0.6, -0.86, 2.3, 0.59, -0.85, 1.6,
-0.02, 1.03, -0.08, -0.73, -0.23, 0.16, 0.01, -1.06, -0.11,
0.93, 0.59, -1.94, 0.33, -1.25, 0.01, 1.4, 1.07, 0.36, -1.41,
-0.36, -0.21, 0.16, 0.7, 0.78, 0.29, -0.64, 0.73, -1.01, -0.3,
1.42, -0.38, 0.14, -1.25, -1.26, 0.23, -0.81, 0.64, -0.66,
-0.71, -0.15, -0.8, 0.79, 0.46, 0.75, 0.5, -1.44, -0.81, 0.59,
1.02, 0.45, -0.53, -1.4, -0.64, 0.51, -0.99, 0.01, -1.52, -0.14,
-0.25, 1.81, -1.16, 0.66, -0.1, -0.54, 0.3, -1.05, -0.13, 1.54,
-0.56, 1.41, 0.01, 0.27, 0.99, 1.74, -0.4, -0.84, 0.72, 1.37,
1.77, 0.16, 2.33, -0.7, 1.64, -0.18, 0.46, 2.33, -1.35, -0.38,
0.41, -1.83, -0.73, 2, 0.76, 0.58, -0.81, -0.18, -0.85, 0.17,
0.65, -0.39, 1.37, -0.04, 0.86, 1.11, -0.16, -0.8, -0.47, -1.59,
-0.09, -1.21, -2.3, -2.7, -1.57, -0.12, 1.39, -0.79, 1.87, 0.9,
0.29, 0.88, -0.68, 0.29, -1.15, -0.32, 0.14, -0.31, -0.3, -0.62,
0.13, -0.33, 0.6, -1.12, 0.05, 0.13, 0.91, -0.85, 0.75, -0.54,
-0.33, 0.39, 1.38, -0.33, 0.51, 1.89, 1.02, 0.38, 0.37, 0.35,
-0.1, 0.69, 0.04, 0.01, -0.89, -0.9, -1.08, 0.02, -1.27, -0.92,
1.17, -0.66, 0.62, 0.01, -0.93, 1.01, 0.41, -0.29, 1.01, 0.01,
-0.85, 0.65, -0.9, 1.09, -0.2, 0.15, 2.72, -0.66, 0.57, 0.82,
-0.5, 0.76, 0.2, 0.63, -0.35, -0.52, 0.43, 1.99, 1.85, 0.35,
-1.56, 0.69, 1.07, 0.19, -0.51, 0.29, 0.22, -0.83, -0.2, 0.72,
1.52, -1.22, -0.68, -1.45, -0.5, -1.27, 0.33, 0.46, 0.42, 0.23,
-2.22, 0.2, 2.05, 1.3, 0.16, 0.79, 1.8, -0.93, -0.21, -0.54,
0.16, -0.16, 0.71, -0.06, -0.46, -0.31, 1.67, -0.18, 0.43, -1.56
};
int active[5] = {1, 1, 0, 0, 1};
int nactive = 3;
int active2[20] = {
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1
};
int thinned[20] = {
1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
1, 0, 0, 0, 0,
1, 0, 0, 0, 0
};
copyshrink(x, y, 5, 5, active, nactive);
for(i = 0 ; i < 9 ; i++)
printf("%d %.3f %.3f %.3f\n", i, y2[i], y[i], y2[i] - y[i]);
thin(x2, 50, 20, active2, 0.1, 8, 5);
for(i = 0 ; i < 20 ; i++)
printf("%d\t%d\t%d\t%d\n", i, thinned[i], active2[i], thinned[i] - active2[i]);
free(y);
return EXIT_SUCCESS;
}