1 |
/*<html><pre> -<a href="qh-stat.htm" |
2 |
>-------------------------------</a><a name="TOP">-</a> |
3 |
|
4 |
stat.h |
5 |
contains all statistics that are collected for qhull |
6 |
|
7 |
see qh-stat.htm and stat.c |
8 |
|
9 |
copyright (c) 1993-2003, The Geometry Center |
10 |
|
11 |
recompile qhull if you change this file |
12 |
|
13 |
Integer statistics are Z* while real statistics are W*. |
14 |
|
15 |
define maydebugx to call a routine at every statistic event |
16 |
|
17 |
*/ |
18 |
|
19 |
#ifndef qhDEFstat |
20 |
#define qhDEFstat 1 |
21 |
|
22 |
|
23 |
/*-<a href="qh-stat.htm#TOC" |
24 |
>-------------------------------</a><a name="KEEPstatistics">-</a> |
25 |
|
26 |
qh_KEEPstatistics |
27 |
0 turns off statistic gathering (except zzdef/zzinc/zzadd/zzval/wwval) |
28 |
*/ |
29 |
#ifndef qh_KEEPstatistics |
30 |
#define qh_KEEPstatistics 1 |
31 |
#endif |
32 |
|
33 |
/*-<a href="qh-stat.htm#TOC" |
34 |
>-------------------------------</a><a name="statistics">-</a> |
35 |
|
36 |
Zxxx for integers, Wxxx for reals |
37 |
|
38 |
notes: |
39 |
be sure that all statistics are defined in stat.c |
40 |
otherwise initialization may core dump |
41 |
can pick up all statistics by: |
42 |
grep '[zw].*_[(][ZW]' *.c >z.x |
43 |
remove trailers with query">-</a> |
44 |
remove leaders with query-replace-regexp [ ^I]+ ( |
45 |
*/ |
46 |
#if qh_KEEPstatistics |
47 |
enum statistics { /* alphabetical after Z/W */ |
48 |
Zacoplanar, |
49 |
Wacoplanarmax, |
50 |
Wacoplanartot, |
51 |
Zangle, |
52 |
Wangle, |
53 |
Wanglemax, |
54 |
Wanglemin, |
55 |
Zangletests, |
56 |
Wareatot, |
57 |
Wareamax, |
58 |
Wareamin, |
59 |
Zavoidold, |
60 |
Wavoidoldmax, |
61 |
Wavoidoldtot, |
62 |
Zback0, |
63 |
Zbestcentrum, |
64 |
Zbestdist, |
65 |
Zbestlower, |
66 |
Zbestlowerv, |
67 |
Zcentrumtests, |
68 |
Zcheckpart, |
69 |
Zcomputefurthest, |
70 |
Zconcave, |
71 |
Wconcavemax, |
72 |
Wconcavetot, |
73 |
Zconcaveridges, |
74 |
Zconcaveridge, |
75 |
Zcoplanar, |
76 |
Wcoplanarmax, |
77 |
Wcoplanartot, |
78 |
Zcoplanarangle, |
79 |
Zcoplanarcentrum, |
80 |
Zcoplanarhorizon, |
81 |
Zcoplanarinside, |
82 |
Zcoplanarpart, |
83 |
Zcoplanarridges, |
84 |
Wcpu, |
85 |
Zcyclefacetmax, |
86 |
Zcyclefacettot, |
87 |
Zcyclehorizon, |
88 |
Zcyclevertex, |
89 |
Zdegen, |
90 |
Wdegenmax, |
91 |
Wdegentot, |
92 |
Zdegenvertex, |
93 |
Zdelfacetdup, |
94 |
Zdelridge, |
95 |
Zdelvertextot, |
96 |
Zdelvertexmax, |
97 |
Zdetsimplex, |
98 |
Zdistcheck, |
99 |
Zdistconvex, |
100 |
Zdistgood, |
101 |
Zdistio, |
102 |
Zdistplane, |
103 |
Zdiststat, |
104 |
Zdistvertex, |
105 |
Zdistzero, |
106 |
Zdoc1, |
107 |
Zdoc2, |
108 |
Zdoc3, |
109 |
Zdoc4, |
110 |
Zdoc5, |
111 |
Zdoc6, |
112 |
Zdoc7, |
113 |
Zdoc8, |
114 |
Zdoc9, |
115 |
Zdoc10, |
116 |
Zdoc11, |
117 |
Zdoc12, |
118 |
Zdropdegen, |
119 |
Zdropneighbor, |
120 |
Zdupflip, |
121 |
Zduplicate, |
122 |
Wduplicatemax, |
123 |
Wduplicatetot, |
124 |
Zdupridge, |
125 |
Zdupsame, |
126 |
Zflipped, |
127 |
Wflippedmax, |
128 |
Wflippedtot, |
129 |
Zflippedfacets, |
130 |
Zfindbest, |
131 |
Zfindbestmax, |
132 |
Zfindbesttot, |
133 |
Zfindcoplanar, |
134 |
Zfindfail, |
135 |
Zfindhorizon, |
136 |
Zfindhorizonmax, |
137 |
Zfindhorizontot, |
138 |
Zfindjump, |
139 |
Zfindnew, |
140 |
Zfindnewmax, |
141 |
Zfindnewtot, |
142 |
Zfindnewjump, |
143 |
Zfindnewsharp, |
144 |
Zgauss0, |
145 |
Zgoodfacet, |
146 |
Zhashlookup, |
147 |
Zhashridge, |
148 |
Zhashridgetest, |
149 |
Zhashtests, |
150 |
Zinsidevisible, |
151 |
Zintersect, |
152 |
Zintersectfail, |
153 |
Zintersectmax, |
154 |
Zintersectnum, |
155 |
Zintersecttot, |
156 |
Zmaxneighbors, |
157 |
Wmaxout, |
158 |
Wmaxoutside, |
159 |
Zmaxridges, |
160 |
Zmaxvertex, |
161 |
Zmaxvertices, |
162 |
Zmaxvneighbors, |
163 |
Zmemfacets, |
164 |
Zmempoints, |
165 |
Zmemridges, |
166 |
Zmemvertices, |
167 |
Zmergeflipdup, |
168 |
Zmergehorizon, |
169 |
Zmergeinittot, |
170 |
Zmergeinitmax, |
171 |
Zmergeinittot2, |
172 |
Zmergeintohorizon, |
173 |
Zmergenew, |
174 |
Zmergesettot, |
175 |
Zmergesetmax, |
176 |
Zmergesettot2, |
177 |
Zmergesimplex, |
178 |
Zmergevertex, |
179 |
Wmindenom, |
180 |
Wminvertex, |
181 |
Zminnorm, |
182 |
Zmultiridge, |
183 |
Znearlysingular, |
184 |
Zneighbor, |
185 |
Wnewbalance, |
186 |
Wnewbalance2, |
187 |
Znewfacettot, |
188 |
Znewfacetmax, |
189 |
Znewvertex, |
190 |
Wnewvertex, |
191 |
Wnewvertexmax, |
192 |
Znoarea, |
193 |
Znonsimplicial, |
194 |
Znowsimplicial, |
195 |
Znotgood, |
196 |
Znotgoodnew, |
197 |
Znotmax, |
198 |
Znumfacets, |
199 |
Znummergemax, |
200 |
Znummergetot, |
201 |
Znumneighbors, |
202 |
Znumridges, |
203 |
Znumvertices, |
204 |
Znumvisibility, |
205 |
Znumvneighbors, |
206 |
Zonehorizon, |
207 |
Zpartangle, |
208 |
Zpartcoplanar, |
209 |
Zpartflip, |
210 |
Zparthorizon, |
211 |
Zpartinside, |
212 |
Zpartition, |
213 |
Zpartitionall, |
214 |
Zpartnear, |
215 |
Zpbalance, |
216 |
Wpbalance, |
217 |
Wpbalance2, |
218 |
Zpostfacets, |
219 |
Zpremergetot, |
220 |
Zprocessed, |
221 |
Zremvertex, |
222 |
Zremvertexdel, |
223 |
Zrenameall, |
224 |
Zrenamepinch, |
225 |
Zrenameshare, |
226 |
Zretry, |
227 |
Wretrymax, |
228 |
Zridge, |
229 |
Wridge, |
230 |
Wridgemax, |
231 |
Zridge0, |
232 |
Wridge0, |
233 |
Wridge0max, |
234 |
Zridgemid, |
235 |
Wridgemid, |
236 |
Wridgemidmax, |
237 |
Zridgeok, |
238 |
Wridgeok, |
239 |
Wridgeokmax, |
240 |
Zsearchpoints, |
241 |
Zsetplane, |
242 |
Ztestvneighbor, |
243 |
Ztotcheck, |
244 |
Ztothorizon, |
245 |
Ztotmerge, |
246 |
Ztotpartcoplanar, |
247 |
Ztotpartition, |
248 |
Ztotridges, |
249 |
Ztotvertices, |
250 |
Ztotvisible, |
251 |
Ztricoplanar, |
252 |
Ztricoplanarmax, |
253 |
Ztricoplanartot, |
254 |
Ztridegen, |
255 |
Ztrimirror, |
256 |
Ztrinull, |
257 |
Wvertexmax, |
258 |
Wvertexmin, |
259 |
Zvertexridge, |
260 |
Zvertexridgetot, |
261 |
Zvertexridgemax, |
262 |
Zvertices, |
263 |
Zvisfacettot, |
264 |
Zvisfacetmax, |
265 |
Zvisvertextot, |
266 |
Zvisvertexmax, |
267 |
Zwidefacet, |
268 |
Zwidevertices, |
269 |
ZEND}; |
270 |
|
271 |
/*-<a href="qh-stat.htm#TOC" |
272 |
>-------------------------------</a><a name="ZZstat">-</a> |
273 |
|
274 |
Zxxx/Wxxx statistics that remain defined if qh_KEEPstatistics=0 |
275 |
|
276 |
notes: |
277 |
be sure to use zzdef, zzinc, etc. with these statistics (no double checking!) |
278 |
*/ |
279 |
#else |
280 |
enum statistics { /* for zzdef etc. macros */ |
281 |
Zback0, |
282 |
Zbestdist, |
283 |
Zcentrumtests, |
284 |
Zcheckpart, |
285 |
Zconcaveridges, |
286 |
Zcoplanarhorizon, |
287 |
Zcoplanarpart, |
288 |
Zcoplanarridges, |
289 |
Zcyclefacettot, |
290 |
Zcyclehorizon, |
291 |
Zdelvertextot, |
292 |
Zdistcheck, |
293 |
Zdistconvex, |
294 |
Zdistzero, |
295 |
Zdoc1, |
296 |
Zdoc2, |
297 |
Zdoc3, |
298 |
Zdoc11, |
299 |
Zflippedfacets, |
300 |
Zgauss0, |
301 |
Zminnorm, |
302 |
Zmultiridge, |
303 |
Znearlysingular, |
304 |
Wnewvertexmax, |
305 |
Znumvisibility, |
306 |
Zpartcoplanar, |
307 |
Zpartition, |
308 |
Zpartitionall, |
309 |
Zprocessed, |
310 |
Zretry, |
311 |
Zridge, |
312 |
Wridge, |
313 |
Wridgemax, |
314 |
Zridge0, |
315 |
Wridge0, |
316 |
Wridge0max, |
317 |
Zridgemid, |
318 |
Wridgemid, |
319 |
Wridgemidmax, |
320 |
Zridgeok, |
321 |
Wridgeok, |
322 |
Wridgeokmax, |
323 |
Zsetplane, |
324 |
Ztotmerge, |
325 |
ZEND}; |
326 |
#endif |
327 |
|
328 |
/*-<a href="qh-stat.htm#TOC" |
329 |
>-------------------------------</a><a name="ztype">-</a> |
330 |
|
331 |
ztype |
332 |
the type of a statistic sets its initial value. |
333 |
|
334 |
notes: |
335 |
The type should be the same as the macro for collecting the statistic |
336 |
*/ |
337 |
enum ztypes {zdoc,zinc,zadd,zmax,zmin,ZTYPEreal,wadd,wmax,wmin,ZTYPEend}; |
338 |
|
339 |
/*========== macros and constants =============*/ |
340 |
|
341 |
/*-<a href="qh-stat.htm#TOC" |
342 |
>--------------------------------</a><a name="MAYdebugx">-</a> |
343 |
|
344 |
MAYdebugx |
345 |
define as maydebug() to be called frequently for error trapping |
346 |
*/ |
347 |
#define MAYdebugx |
348 |
|
349 |
/*-<a href="qh-stat.htm#TOC" |
350 |
>--------------------------------</a><a name="zdef_">-</a> |
351 |
|
352 |
zzdef_, zdef_( type, name, doc, -1) |
353 |
define a statistic (assumes 'qhstat.next= 0;') |
354 |
|
355 |
zdef_( type, name, doc, count) |
356 |
define an averaged statistic |
357 |
printed as name/count |
358 |
*/ |
359 |
#define zzdef_(stype,name,string,cnt) qhstat id[qhstat next++]=name; \ |
360 |
qhstat doc[name]= string; qhstat count[name]= cnt; qhstat type[name]= stype |
361 |
#if qh_KEEPstatistics |
362 |
#define zdef_(stype,name,string,cnt) qhstat id[qhstat next++]=name; \ |
363 |
qhstat doc[name]= string; qhstat count[name]= cnt; qhstat type[name]= stype |
364 |
#else |
365 |
#define zdef_(type,name,doc,count) |
366 |
#endif |
367 |
|
368 |
/*-<a href="qh-stat.htm#TOC" |
369 |
>--------------------------------</a><a name="zinc_">-</a> |
370 |
|
371 |
zzinc_( name ), zinc_( name) |
372 |
increment an integer statistic |
373 |
*/ |
374 |
#define zzinc_(id) {MAYdebugx; qhstat stats[id].i++;} |
375 |
#if qh_KEEPstatistics |
376 |
#define zinc_(id) {MAYdebugx; qhstat stats[id].i++;} |
377 |
#else |
378 |
#define zinc_(id) {} |
379 |
#endif |
380 |
|
381 |
/*-<a href="qh-stat.htm#TOC" |
382 |
>--------------------------------</a><a name="zadd_">-</a> |
383 |
|
384 |
zzadd_( name, value ), zadd_( name, value ), wadd_( name, value ) |
385 |
add value to an integer or real statistic |
386 |
*/ |
387 |
#define zzadd_(id, val) {MAYdebugx; qhstat stats[id].i += (val);} |
388 |
#define wwadd_(id, val) {MAYdebugx; qhstat stats[id].r += (val);} |
389 |
#if qh_KEEPstatistics |
390 |
#define zadd_(id, val) {MAYdebugx; qhstat stats[id].i += (val);} |
391 |
#define wadd_(id, val) {MAYdebugx; qhstat stats[id].r += (val);} |
392 |
#else |
393 |
#define zadd_(id, val) {} |
394 |
#define wadd_(id, val) {} |
395 |
#endif |
396 |
|
397 |
/*-<a href="qh-stat.htm#TOC" |
398 |
>--------------------------------</a><a name="zval_">-</a> |
399 |
|
400 |
zzval_( name ), zval_( name ), wwval_( name ) |
401 |
set or return value of a statistic |
402 |
*/ |
403 |
#define zzval_(id) ((qhstat stats[id]).i) |
404 |
#define wwval_(id) ((qhstat stats[id]).r) |
405 |
#if qh_KEEPstatistics |
406 |
#define zval_(id) ((qhstat stats[id]).i) |
407 |
#define wval_(id) ((qhstat stats[id]).r) |
408 |
#else |
409 |
#define zval_(id) qhstat tempi |
410 |
#define wval_(id) qhstat tempr |
411 |
#endif |
412 |
|
413 |
/*-<a href="qh-stat.htm#TOC" |
414 |
>--------------------------------</a><a name="zmax_">-</a> |
415 |
|
416 |
zmax_( id, val ), wmax_( id, value ) |
417 |
maximize id with val |
418 |
*/ |
419 |
#define wwmax_(id, val) {MAYdebugx; maximize_(qhstat stats[id].r,(val));} |
420 |
#if qh_KEEPstatistics |
421 |
#define zmax_(id, val) {MAYdebugx; maximize_(qhstat stats[id].i,(val));} |
422 |
#define wmax_(id, val) {MAYdebugx; maximize_(qhstat stats[id].r,(val));} |
423 |
#else |
424 |
#define zmax_(id, val) {} |
425 |
#define wmax_(id, val) {} |
426 |
#endif |
427 |
|
428 |
/*-<a href="qh-stat.htm#TOC" |
429 |
>--------------------------------</a><a name="zmin_">-</a> |
430 |
|
431 |
zmin_( id, val ), wmin_( id, value ) |
432 |
minimize id with val |
433 |
*/ |
434 |
#if qh_KEEPstatistics |
435 |
#define zmin_(id, val) {MAYdebugx; minimize_(qhstat stats[id].i,(val));} |
436 |
#define wmin_(id, val) {MAYdebugx; minimize_(qhstat stats[id].r,(val));} |
437 |
#else |
438 |
#define zmin_(id, val) {} |
439 |
#define wmin_(id, val) {} |
440 |
#endif |
441 |
|
442 |
/*================== stat.h types ==============*/ |
443 |
|
444 |
|
445 |
/*-<a href="qh-stat.htm#TOC" |
446 |
>--------------------------------</a><a name="intrealT">-</a> |
447 |
|
448 |
intrealT |
449 |
union of integer and real, used for statistics |
450 |
*/ |
451 |
typedef union intrealT intrealT; /* union of int and realT */ |
452 |
union intrealT { |
453 |
int i; |
454 |
realT r; |
455 |
}; |
456 |
|
457 |
/*-<a href="qh-stat.htm#TOC" |
458 |
>--------------------------------</a><a name="qhstat">-</a> |
459 |
|
460 |
qhstat |
461 |
global data structure for statistics |
462 |
|
463 |
notes: |
464 |
access to qh_qhstat is via the "qhstat" macro. There are two choices |
465 |
qh_QHpointer = 1 access globals via a pointer |
466 |
enables qh_saveqhull() and qh_restoreqhull() |
467 |
= 0 qh_qhstat is a static data structure |
468 |
only one instance of qhull() can be active at a time |
469 |
default value |
470 |
qh_QHpointer is defined in qhull.h |
471 |
|
472 |
allocated in stat.c |
473 |
*/ |
474 |
typedef struct qhstatT qhstatT; |
475 |
#if qh_QHpointer |
476 |
#define qhstat qh_qhstat-> |
477 |
extern qhstatT *qh_qhstat; |
478 |
#else |
479 |
#define qhstat qh_qhstat. |
480 |
extern qhstatT qh_qhstat; |
481 |
#endif |
482 |
struct qhstatT { |
483 |
intrealT stats[ZEND]; /* integer and real statistics */ |
484 |
unsigned char id[ZEND+10]; /* id's in print order */ |
485 |
char *doc[ZEND]; /* array of documentation strings */ |
486 |
short int count[ZEND]; /* -1 if none, else index of count to use */ |
487 |
char type[ZEND]; /* type, see ztypes above */ |
488 |
char printed[ZEND]; /* true, if statistic has been printed */ |
489 |
intrealT init[ZTYPEend]; /* initial values by types, set initstatistics */ |
490 |
|
491 |
int next; /* next index for zdef_ */ |
492 |
int precision; /* index for precision problems */ |
493 |
int vridges; /* index for Voronoi ridges */ |
494 |
int tempi; |
495 |
realT tempr; |
496 |
}; |
497 |
|
498 |
/*========== function prototypes ===========*/ |
499 |
|
500 |
void qh_allstatA(void); |
501 |
void qh_allstatB(void); |
502 |
void qh_allstatC(void); |
503 |
void qh_allstatD(void); |
504 |
void qh_allstatE(void); |
505 |
void qh_allstatE2(void); |
506 |
void qh_allstatF(void); |
507 |
void qh_allstatG(void); |
508 |
void qh_allstatH(void); |
509 |
void qh_allstatI(void); |
510 |
void qh_allstatistics (void); |
511 |
void qh_collectstatistics (void); |
512 |
void qh_freestatistics (void); |
513 |
void qh_initstatistics (void); |
514 |
boolT qh_newstats (int index, int *nextindex); |
515 |
boolT qh_nostatistic (int i); |
516 |
void qh_printallstatistics (FILE *fp, char *string); |
517 |
void qh_printstatistics (FILE *fp, char *string); |
518 |
void qh_printstatlevel (FILE *fp, int id, int start); |
519 |
void qh_printstats (FILE *fp, int index, int *nextindex); |
520 |
realT qh_stddev (int num, realT tot, realT tot2, realT *ave); |
521 |
|
522 |
#endif /* qhDEFstat */ |