stat.c
Go to the documentation of this file.
1 /*<html><pre> -<a href="qh-stat.htm"
2  >-------------------------------</a><a name="TOP">-</a>
3 
4  stat.c
5  contains all statistics that are collected for qhull
6 
7  see qh-stat.htm and stat.h
8 
9  Copyright (c) 1993-2015 The Geometry Center.
10  $Id: //main/2015/qhull/src/libqhull/stat.c#5 $$Change: 2062 $
11  $DateTime: 2016/01/17 13:13:18 $$Author: bbarber $
12 */
13 
14 #include "qhull_a.h"
15 
16 /*============ global data structure ==========*/
17 
18 #if qh_QHpointer
19 qhstatT *qh_qhstat=NULL; /* global data structure */
20 #else
21 qhstatT qh_qhstat; /* add "={0}" if this causes a compiler error */
22 #endif
23 
24 /*========== functions in alphabetic order ================*/
25 
26 /*-<a href="qh-stat.htm#TOC"
27  >-------------------------------</a><a name="allstatA">-</a>
28 
29  qh_allstatA()
30  define statistics in groups of 20
31 
32  notes:
33  (otherwise, 'gcc -O2' uses too much memory)
34  uses qhstat.next
35 */
36 void qh_allstatA(void) {
37 
38  /* zdef_(type,name,doc,average) */
39  zzdef_(zdoc, Zdoc2, "precision statistics", -1);
40  zdef_(zinc, Znewvertex, NULL, -1);
41  zdef_(wadd, Wnewvertex, "ave. distance of a new vertex to a facet(!0s)", Znewvertex);
42  zzdef_(wmax, Wnewvertexmax, "max. distance of a new vertex to a facet", -1);
43  zdef_(wmax, Wvertexmax, "max. distance of an output vertex to a facet", -1);
44  zdef_(wmin, Wvertexmin, "min. distance of an output vertex to a facet", -1);
45  zdef_(wmin, Wmindenom, "min. denominator in hyperplane computation", -1);
46 
47  qhstat precision= qhstat next; /* call qh_precision for each of these */
48  zzdef_(zdoc, Zdoc3, "precision problems (corrected unless 'Q0' or an error)", -1);
49  zzdef_(zinc, Zcoplanarridges, "coplanar half ridges in output", -1);
50  zzdef_(zinc, Zconcaveridges, "concave half ridges in output", -1);
51  zzdef_(zinc, Zflippedfacets, "flipped facets", -1);
52  zzdef_(zinc, Zcoplanarhorizon, "coplanar horizon facets for new vertices", -1);
53  zzdef_(zinc, Zcoplanarpart, "coplanar points during partitioning", -1);
54  zzdef_(zinc, Zminnorm, "degenerate hyperplanes recomputed with gaussian elimination", -1);
55  zzdef_(zinc, Znearlysingular, "nearly singular or axis-parallel hyperplanes", -1);
56  zzdef_(zinc, Zback0, "zero divisors during back substitute", -1);
57  zzdef_(zinc, Zgauss0, "zero divisors during gaussian elimination", -1);
58  zzdef_(zinc, Zmultiridge, "ridges with multiple neighbors", -1);
59 }
60 void qh_allstatB(void) {
61  zzdef_(zdoc, Zdoc1, "summary information", -1);
62  zdef_(zinc, Zvertices, "number of vertices in output", -1);
63  zdef_(zinc, Znumfacets, "number of facets in output", -1);
64  zdef_(zinc, Znonsimplicial, "number of non-simplicial facets in output", -1);
65  zdef_(zinc, Znowsimplicial, "number of simplicial facets that were merged", -1);
66  zdef_(zinc, Znumridges, "number of ridges in output", -1);
67  zdef_(zadd, Znumridges, "average number of ridges per facet", Znumfacets);
68  zdef_(zmax, Zmaxridges, "maximum number of ridges", -1);
69  zdef_(zadd, Znumneighbors, "average number of neighbors per facet", Znumfacets);
70  zdef_(zmax, Zmaxneighbors, "maximum number of neighbors", -1);
71  zdef_(zadd, Znumvertices, "average number of vertices per facet", Znumfacets);
72  zdef_(zmax, Zmaxvertices, "maximum number of vertices", -1);
73  zdef_(zadd, Znumvneighbors, "average number of neighbors per vertex", Zvertices);
74  zdef_(zmax, Zmaxvneighbors, "maximum number of neighbors", -1);
75  zdef_(wadd, Wcpu, "cpu seconds for qhull after input", -1);
76  zdef_(zinc, Ztotvertices, "vertices created altogether", -1);
77  zzdef_(zinc, Zsetplane, "facets created altogether", -1);
78  zdef_(zinc, Ztotridges, "ridges created altogether", -1);
79  zdef_(zinc, Zpostfacets, "facets before post merge", -1);
80  zdef_(zadd, Znummergetot, "average merges per facet(at most 511)", Znumfacets);
81  zdef_(zmax, Znummergemax, " maximum merges for a facet(at most 511)", -1);
82  zdef_(zinc, Zangle, NULL, -1);
83  zdef_(wadd, Wangle, "average angle(cosine) of facet normals for all ridges", Zangle);
84  zdef_(wmax, Wanglemax, " maximum angle(cosine) of facet normals across a ridge", -1);
85  zdef_(wmin, Wanglemin, " minimum angle(cosine) of facet normals across a ridge", -1);
86  zdef_(wadd, Wareatot, "total area of facets", -1);
87  zdef_(wmax, Wareamax, " maximum facet area", -1);
88  zdef_(wmin, Wareamin, " minimum facet area", -1);
89 }
90 void qh_allstatC(void) {
91  zdef_(zdoc, Zdoc9, "build hull statistics", -1);
92  zzdef_(zinc, Zprocessed, "points processed", -1);
93  zzdef_(zinc, Zretry, "retries due to precision problems", -1);
94  zdef_(wmax, Wretrymax, " max. random joggle", -1);
95  zdef_(zmax, Zmaxvertex, "max. vertices at any one time", -1);
96  zdef_(zinc, Ztotvisible, "ave. visible facets per iteration", Zprocessed);
97  zdef_(zinc, Zinsidevisible, " ave. visible facets without an horizon neighbor", Zprocessed);
98  zdef_(zadd, Zvisfacettot, " ave. facets deleted per iteration", Zprocessed);
99  zdef_(zmax, Zvisfacetmax, " maximum", -1);
100  zdef_(zadd, Zvisvertextot, "ave. visible vertices per iteration", Zprocessed);
101  zdef_(zmax, Zvisvertexmax, " maximum", -1);
102  zdef_(zinc, Ztothorizon, "ave. horizon facets per iteration", Zprocessed);
103  zdef_(zadd, Znewfacettot, "ave. new or merged facets per iteration", Zprocessed);
104  zdef_(zmax, Znewfacetmax, " maximum(includes initial simplex)", -1);
105  zdef_(wadd, Wnewbalance, "average new facet balance", Zprocessed);
106  zdef_(wadd, Wnewbalance2, " standard deviation", -1);
107  zdef_(wadd, Wpbalance, "average partition balance", Zpbalance);
108  zdef_(wadd, Wpbalance2, " standard deviation", -1);
109  zdef_(zinc, Zpbalance, " number of trials", -1);
110  zdef_(zinc, Zsearchpoints, "searches of all points for initial simplex", -1);
111  zdef_(zinc, Zdetsimplex, "determinants computed(area & initial hull)", -1);
112  zdef_(zinc, Znoarea, "determinants not computed because vertex too low", -1);
113  zdef_(zinc, Znotmax, "points ignored(!above max_outside)", -1);
114  zdef_(zinc, Znotgood, "points ignored(!above a good facet)", -1);
115  zdef_(zinc, Znotgoodnew, "points ignored(didn't create a good new facet)", -1);
116  zdef_(zinc, Zgoodfacet, "good facets found", -1);
117  zzdef_(zinc, Znumvisibility, "distance tests for facet visibility", -1);
118  zdef_(zinc, Zdistvertex, "distance tests to report minimum vertex", -1);
119  zzdef_(zinc, Ztotcheck, "points checked for facets' outer planes", -1);
120  zzdef_(zinc, Zcheckpart, " ave. distance tests per check", Ztotcheck);
121 }
122 void qh_allstatD(void) {
123  zdef_(zinc, Zvisit, "resets of visit_id", -1);
124  zdef_(zinc, Zvvisit, " resets of vertex_visit", -1);
125  zdef_(zmax, Zvisit2max, " max visit_id/2", -1);
126  zdef_(zmax, Zvvisit2max, " max vertex_visit/2", -1);
127 
128  zdef_(zdoc, Zdoc4, "partitioning statistics(see previous for outer planes)", -1);
129  zzdef_(zadd, Zdelvertextot, "total vertices deleted", -1);
130  zdef_(zmax, Zdelvertexmax, " maximum vertices deleted per iteration", -1);
131  zdef_(zinc, Zfindbest, "calls to findbest", -1);
132  zdef_(zadd, Zfindbesttot, " ave. facets tested", Zfindbest);
133  zdef_(zmax, Zfindbestmax, " max. facets tested", -1);
134  zdef_(zadd, Zfindcoplanar, " ave. coplanar search", Zfindbest);
135  zdef_(zinc, Zfindnew, "calls to findbestnew", -1);
136  zdef_(zadd, Zfindnewtot, " ave. facets tested", Zfindnew);
137  zdef_(zmax, Zfindnewmax, " max. facets tested", -1);
138  zdef_(zinc, Zfindnewjump, " ave. clearly better", Zfindnew);
139  zdef_(zinc, Zfindnewsharp, " calls due to qh_sharpnewfacets", -1);
140  zdef_(zinc, Zfindhorizon, "calls to findhorizon", -1);
141  zdef_(zadd, Zfindhorizontot, " ave. facets tested", Zfindhorizon);
142  zdef_(zmax, Zfindhorizonmax, " max. facets tested", -1);
143  zdef_(zinc, Zfindjump, " ave. clearly better", Zfindhorizon);
144  zdef_(zinc, Zparthorizon, " horizon facets better than bestfacet", -1);
145  zdef_(zinc, Zpartangle, "angle tests for repartitioned coplanar points", -1);
146  zdef_(zinc, Zpartflip, " repartitioned coplanar points for flipped orientation", -1);
147 }
148 void qh_allstatE(void) {
149  zdef_(zinc, Zpartinside, "inside points", -1);
150  zdef_(zinc, Zpartnear, " inside points kept with a facet", -1);
151  zdef_(zinc, Zcoplanarinside, " inside points that were coplanar with a facet", -1);
152  zdef_(zinc, Zbestlower, "calls to findbestlower", -1);
153  zdef_(zinc, Zbestlowerv, " with search of vertex neighbors", -1);
154  zdef_(zinc, Zbestlowerall, " with rare search of all facets", -1);
155  zdef_(zmax, Zbestloweralln, " facets per search of all facets", -1);
156  zdef_(wadd, Wmaxout, "difference in max_outside at final check", -1);
157  zzdef_(zinc, Zpartitionall, "distance tests for initial partition", -1);
158  zdef_(zinc, Ztotpartition, "partitions of a point", -1);
159  zzdef_(zinc, Zpartition, "distance tests for partitioning", -1);
160  zzdef_(zinc, Zdistcheck, "distance tests for checking flipped facets", -1);
161  zzdef_(zinc, Zdistconvex, "distance tests for checking convexity", -1);
162  zdef_(zinc, Zdistgood, "distance tests for checking good point", -1);
163  zdef_(zinc, Zdistio, "distance tests for output", -1);
164  zdef_(zinc, Zdiststat, "distance tests for statistics", -1);
165  zdef_(zinc, Zdistplane, "total number of distance tests", -1);
166  zdef_(zinc, Ztotpartcoplanar, "partitions of coplanar points or deleted vertices", -1);
167  zzdef_(zinc, Zpartcoplanar, " distance tests for these partitions", -1);
168  zdef_(zinc, Zcomputefurthest, "distance tests for computing furthest", -1);
169 }
170 void qh_allstatE2(void) {
171  zdef_(zdoc, Zdoc5, "statistics for matching ridges", -1);
172  zdef_(zinc, Zhashlookup, "total lookups for matching ridges of new facets", -1);
173  zdef_(zinc, Zhashtests, "average number of tests to match a ridge", Zhashlookup);
174  zdef_(zinc, Zhashridge, "total lookups of subridges(duplicates and boundary)", -1);
175  zdef_(zinc, Zhashridgetest, "average number of tests per subridge", Zhashridge);
176  zdef_(zinc, Zdupsame, "duplicated ridges in same merge cycle", -1);
177  zdef_(zinc, Zdupflip, "duplicated ridges with flipped facets", -1);
178 
179  zdef_(zdoc, Zdoc6, "statistics for determining merges", -1);
180  zdef_(zinc, Zangletests, "angles computed for ridge convexity", -1);
181  zdef_(zinc, Zbestcentrum, "best merges used centrum instead of vertices",-1);
182  zzdef_(zinc, Zbestdist, "distance tests for best merge", -1);
183  zzdef_(zinc, Zcentrumtests, "distance tests for centrum convexity", -1);
184  zzdef_(zinc, Zdistzero, "distance tests for checking simplicial convexity", -1);
185  zdef_(zinc, Zcoplanarangle, "coplanar angles in getmergeset", -1);
186  zdef_(zinc, Zcoplanarcentrum, "coplanar centrums in getmergeset", -1);
187  zdef_(zinc, Zconcaveridge, "concave ridges in getmergeset", -1);
188 }
189 void qh_allstatF(void) {
190  zdef_(zdoc, Zdoc7, "statistics for merging", -1);
191  zdef_(zinc, Zpremergetot, "merge iterations", -1);
192  zdef_(zadd, Zmergeinittot, "ave. initial non-convex ridges per iteration", Zpremergetot);
193  zdef_(zadd, Zmergeinitmax, " maximum", -1);
194  zdef_(zadd, Zmergesettot, " ave. additional non-convex ridges per iteration", Zpremergetot);
195  zdef_(zadd, Zmergesetmax, " maximum additional in one pass", -1);
196  zdef_(zadd, Zmergeinittot2, "initial non-convex ridges for post merging", -1);
197  zdef_(zadd, Zmergesettot2, " additional non-convex ridges", -1);
198  zdef_(wmax, Wmaxoutside, "max distance of vertex or coplanar point above facet(w/roundoff)", -1);
199  zdef_(wmin, Wminvertex, "max distance of merged vertex below facet(or roundoff)", -1);
200  zdef_(zinc, Zwidefacet, "centrums frozen due to a wide merge", -1);
201  zdef_(zinc, Zwidevertices, "centrums frozen due to extra vertices", -1);
202  zzdef_(zinc, Ztotmerge, "total number of facets or cycles of facets merged", -1);
203  zdef_(zinc, Zmergesimplex, "merged a simplex", -1);
204  zdef_(zinc, Zonehorizon, "simplices merged into coplanar horizon", -1);
205  zzdef_(zinc, Zcyclehorizon, "cycles of facets merged into coplanar horizon", -1);
206  zzdef_(zadd, Zcyclefacettot, " ave. facets per cycle", Zcyclehorizon);
207  zdef_(zmax, Zcyclefacetmax, " max. facets", -1);
208  zdef_(zinc, Zmergeintohorizon, "new facets merged into horizon", -1);
209  zdef_(zinc, Zmergenew, "new facets merged", -1);
210  zdef_(zinc, Zmergehorizon, "horizon facets merged into new facets", -1);
211  zdef_(zinc, Zmergevertex, "vertices deleted by merging", -1);
212  zdef_(zinc, Zcyclevertex, "vertices deleted by merging into coplanar horizon", -1);
213  zdef_(zinc, Zdegenvertex, "vertices deleted by degenerate facet", -1);
214  zdef_(zinc, Zmergeflipdup, "merges due to flipped facets in duplicated ridge", -1);
215  zdef_(zinc, Zneighbor, "merges due to redundant neighbors", -1);
216  zdef_(zadd, Ztestvneighbor, "non-convex vertex neighbors", -1);
217 }
218 void qh_allstatG(void) {
219  zdef_(zinc, Zacoplanar, "merges due to angle coplanar facets", -1);
220  zdef_(wadd, Wacoplanartot, " average merge distance", Zacoplanar);
221  zdef_(wmax, Wacoplanarmax, " maximum merge distance", -1);
222  zdef_(zinc, Zcoplanar, "merges due to coplanar facets", -1);
223  zdef_(wadd, Wcoplanartot, " average merge distance", Zcoplanar);
224  zdef_(wmax, Wcoplanarmax, " maximum merge distance", -1);
225  zdef_(zinc, Zconcave, "merges due to concave facets", -1);
226  zdef_(wadd, Wconcavetot, " average merge distance", Zconcave);
227  zdef_(wmax, Wconcavemax, " maximum merge distance", -1);
228  zdef_(zinc, Zavoidold, "coplanar/concave merges due to avoiding old merge", -1);
229  zdef_(wadd, Wavoidoldtot, " average merge distance", Zavoidold);
230  zdef_(wmax, Wavoidoldmax, " maximum merge distance", -1);
231  zdef_(zinc, Zdegen, "merges due to degenerate facets", -1);
232  zdef_(wadd, Wdegentot, " average merge distance", Zdegen);
233  zdef_(wmax, Wdegenmax, " maximum merge distance", -1);
234  zdef_(zinc, Zflipped, "merges due to removing flipped facets", -1);
235  zdef_(wadd, Wflippedtot, " average merge distance", Zflipped);
236  zdef_(wmax, Wflippedmax, " maximum merge distance", -1);
237  zdef_(zinc, Zduplicate, "merges due to duplicated ridges", -1);
238  zdef_(wadd, Wduplicatetot, " average merge distance", Zduplicate);
239  zdef_(wmax, Wduplicatemax, " maximum merge distance", -1);
240 }
241 void qh_allstatH(void) {
242  zdef_(zdoc, Zdoc8, "renamed vertex statistics", -1);
243  zdef_(zinc, Zrenameshare, "renamed vertices shared by two facets", -1);
244  zdef_(zinc, Zrenamepinch, "renamed vertices in a pinched facet", -1);
245  zdef_(zinc, Zrenameall, "renamed vertices shared by multiple facets", -1);
246  zdef_(zinc, Zfindfail, "rename failures due to duplicated ridges", -1);
247  zdef_(zinc, Zdupridge, " duplicate ridges detected", -1);
248  zdef_(zinc, Zdelridge, "deleted ridges due to renamed vertices", -1);
249  zdef_(zinc, Zdropneighbor, "dropped neighbors due to renamed vertices", -1);
250  zdef_(zinc, Zdropdegen, "degenerate facets due to dropped neighbors", -1);
251  zdef_(zinc, Zdelfacetdup, " facets deleted because of no neighbors", -1);
252  zdef_(zinc, Zremvertex, "vertices removed from facets due to no ridges", -1);
253  zdef_(zinc, Zremvertexdel, " deleted", -1);
254  zdef_(zinc, Zintersectnum, "vertex intersections for locating redundant vertices", -1);
255  zdef_(zinc, Zintersectfail, "intersections failed to find a redundant vertex", -1);
256  zdef_(zinc, Zintersect, "intersections found redundant vertices", -1);
257  zdef_(zadd, Zintersecttot, " ave. number found per vertex", Zintersect);
258  zdef_(zmax, Zintersectmax, " max. found for a vertex", -1);
259  zdef_(zinc, Zvertexridge, NULL, -1);
260  zdef_(zadd, Zvertexridgetot, " ave. number of ridges per tested vertex", Zvertexridge);
261  zdef_(zmax, Zvertexridgemax, " max. number of ridges per tested vertex", -1);
262 
263  zdef_(zdoc, Zdoc10, "memory usage statistics(in bytes)", -1);
264  zdef_(zadd, Zmemfacets, "for facets and their normals, neighbor and vertex sets", -1);
265  zdef_(zadd, Zmemvertices, "for vertices and their neighbor sets", -1);
266  zdef_(zadd, Zmempoints, "for input points and outside and coplanar sets",-1);
267  zdef_(zadd, Zmemridges, "for ridges and their vertex sets", -1);
268 } /* allstat */
269 
270 void qh_allstatI(void) {
271  qhstat vridges= qhstat next;
272  zzdef_(zdoc, Zdoc11, "Voronoi ridge statistics", -1);
273  zzdef_(zinc, Zridge, "non-simplicial Voronoi vertices for all ridges", -1);
274  zzdef_(wadd, Wridge, " ave. distance to ridge", Zridge);
275  zzdef_(wmax, Wridgemax, " max. distance to ridge", -1);
276  zzdef_(zinc, Zridgemid, "bounded ridges", -1);
277  zzdef_(wadd, Wridgemid, " ave. distance of midpoint to ridge", Zridgemid);
278  zzdef_(wmax, Wridgemidmax, " max. distance of midpoint to ridge", -1);
279  zzdef_(zinc, Zridgeok, "bounded ridges with ok normal", -1);
280  zzdef_(wadd, Wridgeok, " ave. angle to ridge", Zridgeok);
281  zzdef_(wmax, Wridgeokmax, " max. angle to ridge", -1);
282  zzdef_(zinc, Zridge0, "bounded ridges with near-zero normal", -1);
283  zzdef_(wadd, Wridge0, " ave. angle to ridge", Zridge0);
284  zzdef_(wmax, Wridge0max, " max. angle to ridge", -1);
285 
286  zdef_(zdoc, Zdoc12, "Triangulation statistics(Qt)", -1);
287  zdef_(zinc, Ztricoplanar, "non-simplicial facets triangulated", -1);
288  zdef_(zadd, Ztricoplanartot, " ave. new facets created(may be deleted)", Ztricoplanar);
289  zdef_(zmax, Ztricoplanarmax, " max. new facets created", -1);
290  zdef_(zinc, Ztrinull, "null new facets deleted(duplicated vertex)", -1);
291  zdef_(zinc, Ztrimirror, "mirrored pairs of new facets deleted(same vertices)", -1);
292  zdef_(zinc, Ztridegen, "degenerate new facets in output(same ridge)", -1);
293 } /* allstat */
294 
295 /*-<a href="qh-stat.htm#TOC"
296  >-------------------------------</a><a name="allstatistics">-</a>
297 
298  qh_allstatistics()
299  reset printed flag for all statistics
300 */
301 void qh_allstatistics(void) {
302  int i;
303 
304  for(i=ZEND; i--; )
305  qhstat printed[i]= False;
306 } /* allstatistics */
307 
308 #if qh_KEEPstatistics
309 /*-<a href="qh-stat.htm#TOC"
310  >-------------------------------</a><a name="collectstatistics">-</a>
311 
312  qh_collectstatistics()
313  collect statistics for qh.facet_list
314 
315 */
317  facetT *facet, *neighbor, **neighborp;
318  vertexT *vertex, **vertexp;
319  realT dotproduct, dist;
320  int sizneighbors, sizridges, sizvertices, i;
321 
322  qh old_randomdist= qh RANDOMdist;
323  qh RANDOMdist= False;
324  zval_(Zmempoints)= qh num_points * qh normal_size +
325  sizeof(qhT) + sizeof(qhstatT);
326  zval_(Zmemfacets)= 0;
327  zval_(Zmemridges)= 0;
328  zval_(Zmemvertices)= 0;
329  zval_(Zangle)= 0;
330  wval_(Wangle)= 0.0;
331  zval_(Znumridges)= 0;
332  zval_(Znumfacets)= 0;
333  zval_(Znumneighbors)= 0;
334  zval_(Znumvertices)= 0;
335  zval_(Znumvneighbors)= 0;
336  zval_(Znummergetot)= 0;
337  zval_(Znummergemax)= 0;
338  zval_(Zvertices)= qh num_vertices - qh_setsize(qh del_vertices);
339  if (qh MERGING || qh APPROXhull || qh JOGGLEmax < REALmax/2)
340  wmax_(Wmaxoutside, qh max_outside);
341  if (qh MERGING)
342  wmin_(Wminvertex, qh min_vertex);
344  facet->seen= False;
345  if (qh DELAUNAY) {
346  FORALLfacets {
347  if (facet->upperdelaunay != qh UPPERdelaunay)
348  facet->seen= True; /* remove from angle statistics */
349  }
350  }
351  FORALLfacets {
352  if (facet->visible && qh NEWfacets)
353  continue;
354  sizvertices= qh_setsize(facet->vertices);
355  sizneighbors= qh_setsize(facet->neighbors);
356  sizridges= qh_setsize(facet->ridges);
357  zinc_(Znumfacets);
358  zadd_(Znumvertices, sizvertices);
359  zmax_(Zmaxvertices, sizvertices);
360  zadd_(Znumneighbors, sizneighbors);
361  zmax_(Zmaxneighbors, sizneighbors);
362  zadd_(Znummergetot, facet->nummerge);
363  i= facet->nummerge; /* avoid warnings */
364  zmax_(Znummergemax, i);
365  if (!facet->simplicial) {
366  if (sizvertices == qh hull_dim) {
368  }else {
370  }
371  }
372  if (sizridges) {
373  zadd_(Znumridges, sizridges);
374  zmax_(Zmaxridges, sizridges);
375  }
376  zadd_(Zmemfacets, sizeof(facetT) + qh normal_size + 2*sizeof(setT)
377  + SETelemsize * (sizneighbors + sizvertices));
378  if (facet->ridges) {
380  sizeof(setT) + SETelemsize * sizridges + sizridges *
381  (sizeof(ridgeT) + sizeof(setT) + SETelemsize * (qh hull_dim-1))/2);
382  }
383  if (facet->outsideset)
384  zadd_(Zmempoints, sizeof(setT) + SETelemsize * qh_setsize(facet->outsideset));
385  if (facet->coplanarset)
386  zadd_(Zmempoints, sizeof(setT) + SETelemsize * qh_setsize(facet->coplanarset));
387  if (facet->seen) /* Delaunay upper envelope */
388  continue;
389  facet->seen= True;
390  FOREACHneighbor_(facet) {
391  if (neighbor == qh_DUPLICATEridge || neighbor == qh_MERGEridge
392  || neighbor->seen || !facet->normal || !neighbor->normal)
393  continue;
394  dotproduct= qh_getangle(facet->normal, neighbor->normal);
395  zinc_(Zangle);
396  wadd_(Wangle, dotproduct);
397  wmax_(Wanglemax, dotproduct)
398  wmin_(Wanglemin, dotproduct)
399  }
400  if (facet->normal) {
401  FOREACHvertex_(facet->vertices) {
402  zinc_(Zdiststat);
403  qh_distplane(vertex->point, facet, &dist);
404  wmax_(Wvertexmax, dist);
405  wmin_(Wvertexmin, dist);
406  }
407  }
408  }
410  if (vertex->deleted)
411  continue;
412  zadd_(Zmemvertices, sizeof(vertexT));
413  if (vertex->neighbors) {
414  sizneighbors= qh_setsize(vertex->neighbors);
415  zadd_(Znumvneighbors, sizneighbors);
416  zmax_(Zmaxvneighbors, sizneighbors);
417  zadd_(Zmemvertices, sizeof(vertexT) + SETelemsize * sizneighbors);
418  }
419  }
420  qh RANDOMdist= qh old_randomdist;
421 } /* collectstatistics */
422 #endif /* qh_KEEPstatistics */
423 
424 /*-<a href="qh-stat.htm#TOC"
425  >-------------------------------</a><a name="freestatistics">-</a>
426 
427  qh_freestatistics( )
428  free memory used for statistics
429 */
430 void qh_freestatistics(void) {
431 
432 #if qh_QHpointer
433  qh_free(qh_qhstat);
434  qh_qhstat= NULL;
435 #endif
436 } /* freestatistics */
437 
438 /*-<a href="qh-stat.htm#TOC"
439  >-------------------------------</a><a name="initstatistics">-</a>
440 
441  qh_initstatistics( )
442  allocate and initialize statistics
443 
444  notes:
445  uses qh_malloc() instead of qh_memalloc() since mem.c not set up yet
446  NOerrors -- qh_initstatistics can not use qh_errexit(), qh_fprintf, or qh.ferr
447  On first call, only qhmem.ferr is defined. qh_memalloc is not setup.
448  Also invoked by QhullQh().
449 */
450 void qh_initstatistics(void) {
451  int i;
452  realT realx;
453  int intx;
454 
455 #if qh_QHpointer
456  if(qh_qhstat){ /* qh_initstatistics may be called from Qhull::resetStatistics() */
457  qh_free(qh_qhstat);
458  qh_qhstat= 0;
459  }
460  if (!(qh_qhstat= (qhstatT *)qh_malloc(sizeof(qhstatT)))) {
461  qh_fprintf_stderr(6183, "qhull error (qh_initstatistics): insufficient memory\n");
462  qh_exit(qh_ERRmem); /* can not use qh_errexit() */
463  }
464 #endif
465 
466  qhstat next= 0;
467  qh_allstatA();
468  qh_allstatB();
469  qh_allstatC();
470  qh_allstatD();
471  qh_allstatE();
472  qh_allstatE2();
473  qh_allstatF();
474  qh_allstatG();
475  qh_allstatH();
476  qh_allstatI();
477  if (qhstat next > (int)sizeof(qhstat id)) {
478  qh_fprintf(qhmem.ferr, 6184, "qhull error (qh_initstatistics): increase size of qhstat.id[].\n\
479  qhstat.next %d should be <= sizeof(qhstat id) %d\n", qhstat next, (int)sizeof(qhstat id));
480 #if 0 /* for locating error, Znumridges should be duplicated */
481  for(i=0; i < ZEND; i++) {
482  int j;
483  for(j=i+1; j < ZEND; j++) {
484  if (qhstat id[i] == qhstat id[j]) {
485  qh_fprintf(qhmem.ferr, 6185, "qhull error (qh_initstatistics): duplicated statistic %d at indices %d and %d\n",
486  qhstat id[i], i, j);
487  }
488  }
489  }
490 #endif
491  qh_exit(qh_ERRqhull); /* can not use qh_errexit() */
492  }
493  qhstat init[zinc].i= 0;
494  qhstat init[zadd].i= 0;
495  qhstat init[zmin].i= INT_MAX;
496  qhstat init[zmax].i= INT_MIN;
497  qhstat init[wadd].r= 0;
498  qhstat init[wmin].r= REALmax;
499  qhstat init[wmax].r= -REALmax;
500  for(i=0; i < ZEND; i++) {
501  if (qhstat type[i] > ZTYPEreal) {
502  realx= qhstat init[(unsigned char)(qhstat type[i])].r;
503  qhstat stats[i].r= realx;
504  }else if (qhstat type[i] != zdoc) {
505  intx= qhstat init[(unsigned char)(qhstat type[i])].i;
506  qhstat stats[i].i= intx;
507  }
508  }
509 } /* initstatistics */
510 
511 /*-<a href="qh-stat.htm#TOC"
512  >-------------------------------</a><a name="newstats">-</a>
513 
514  qh_newstats( )
515  returns True if statistics for zdoc
516 
517  returns:
518  next zdoc
519 */
520 boolT qh_newstats(int idx, int *nextindex) {
521  boolT isnew= False;
522  int start, i;
523 
524  if (qhstat type[qhstat id[idx]] == zdoc)
525  start= idx+1;
526  else
527  start= idx;
528  for(i= start; i < qhstat next && qhstat type[qhstat id[i]] != zdoc; i++) {
529  if (!qh_nostatistic(qhstat id[i]) && !qhstat printed[qhstat id[i]])
530  isnew= True;
531  }
532  *nextindex= i;
533  return isnew;
534 } /* newstats */
535 
536 /*-<a href="qh-stat.htm#TOC"
537  >-------------------------------</a><a name="nostatistic">-</a>
538 
539  qh_nostatistic( index )
540  true if no statistic to print
541 */
543 
544  if ((qhstat type[i] > ZTYPEreal
545  &&qhstat stats[i].r == qhstat init[(unsigned char)(qhstat type[i])].r)
546  || (qhstat type[i] < ZTYPEreal
547  &&qhstat stats[i].i == qhstat init[(unsigned char)(qhstat type[i])].i))
548  return True;
549  return False;
550 } /* nostatistic */
551 
552 #if qh_KEEPstatistics
553 /*-<a href="qh-stat.htm#TOC"
554  >-------------------------------</a><a name="printallstatistics">-</a>
555 
556  qh_printallstatistics( fp, string )
557  print all statistics with header 'string'
558 */
559 void qh_printallstatistics(FILE *fp, const char *string) {
560 
563  qh_printstatistics(fp, string);
564  qh_memstatistics(fp);
565 }
566 
567 
568 /*-<a href="qh-stat.htm#TOC"
569  >-------------------------------</a><a name="printstatistics">-</a>
570 
571  qh_printstatistics( fp, string )
572  print statistics to a file with header 'string'
573  skips statistics with qhstat.printed[] (reset with qh_allstatistics)
574 
575  see:
576  qh_printallstatistics()
577 */
578 void qh_printstatistics(FILE *fp, const char *string) {
579  int i, k;
580  realT ave;
581 
582  if (qh num_points != qh num_vertices) {
583  wval_(Wpbalance)= 0;
584  wval_(Wpbalance2)= 0;
585  }else
587  wval_(Wpbalance2), &ave);
589  wval_(Wnewbalance2), &ave);
590  qh_fprintf(fp, 9350, "\n\
591 %s\n\
592  qhull invoked by: %s | %s\n%s with options:\n%s\n", string, qh rbox_command,
593  qh qhull_command, qh_version, qh qhull_options);
594  qh_fprintf(fp, 9351, "\nprecision constants:\n\
595  %6.2g max. abs. coordinate in the (transformed) input('Qbd:n')\n\
596  %6.2g max. roundoff error for distance computation('En')\n\
597  %6.2g max. roundoff error for angle computations\n\
598  %6.2g min. distance for outside points ('Wn')\n\
599  %6.2g min. distance for visible facets ('Vn')\n\
600  %6.2g max. distance for coplanar facets ('Un')\n\
601  %6.2g max. facet width for recomputing centrum and area\n\
602 ",
603  qh MAXabs_coord, qh DISTround, qh ANGLEround, qh MINoutside,
604  qh MINvisible, qh MAXcoplanar, qh WIDEfacet);
605  if (qh KEEPnearinside)
606  qh_fprintf(fp, 9352, "\
607  %6.2g max. distance for near-inside points\n", qh NEARinside);
608  if (qh premerge_cos < REALmax/2) qh_fprintf(fp, 9353, "\
609  %6.2g max. cosine for pre-merge angle\n", qh premerge_cos);
610  if (qh PREmerge) qh_fprintf(fp, 9354, "\
611  %6.2g radius of pre-merge centrum\n", qh premerge_centrum);
612  if (qh postmerge_cos < REALmax/2) qh_fprintf(fp, 9355, "\
613  %6.2g max. cosine for post-merge angle\n", qh postmerge_cos);
614  if (qh POSTmerge) qh_fprintf(fp, 9356, "\
615  %6.2g radius of post-merge centrum\n", qh postmerge_centrum);
616  qh_fprintf(fp, 9357, "\
617  %6.2g max. distance for merging two simplicial facets\n\
618  %6.2g max. roundoff error for arithmetic operations\n\
619  %6.2g min. denominator for divisions\n\
620  zero diagonal for Gauss: ", qh ONEmerge, REALepsilon, qh MINdenom);
621  for(k=0; k < qh hull_dim; k++)
622  qh_fprintf(fp, 9358, "%6.2e ", qh NEARzero[k]);
623  qh_fprintf(fp, 9359, "\n\n");
624  for(i=0 ; i < qhstat next; )
625  qh_printstats(fp, i, &i);
626 } /* printstatistics */
627 #endif /* qh_KEEPstatistics */
628 
629 /*-<a href="qh-stat.htm#TOC"
630  >-------------------------------</a><a name="printstatlevel">-</a>
631 
632  qh_printstatlevel( fp, id )
633  print level information for a statistic
634 
635  notes:
636  nop if id >= ZEND, printed, or same as initial value
637 */
638 void qh_printstatlevel(FILE *fp, int id) {
639 #define NULLfield " "
640 
641  if (id >= ZEND || qhstat printed[id])
642  return;
643  if (qhstat type[id] == zdoc) {
644  qh_fprintf(fp, 9360, "%s\n", qhstat doc[id]);
645  return;
646  }
647  if (qh_nostatistic(id) || !qhstat doc[id])
648  return;
649  qhstat printed[id]= True;
650  if (qhstat count[id] != -1
651  && qhstat stats[(unsigned char)(qhstat count[id])].i == 0)
652  qh_fprintf(fp, 9361, " *0 cnt*");
653  else if (qhstat type[id] >= ZTYPEreal && qhstat count[id] == -1)
654  qh_fprintf(fp, 9362, "%7.2g", qhstat stats[id].r);
655  else if (qhstat type[id] >= ZTYPEreal && qhstat count[id] != -1)
656  qh_fprintf(fp, 9363, "%7.2g", qhstat stats[id].r/ qhstat stats[(unsigned char)(qhstat count[id])].i);
657  else if (qhstat type[id] < ZTYPEreal && qhstat count[id] == -1)
658  qh_fprintf(fp, 9364, "%7d", qhstat stats[id].i);
659  else if (qhstat type[id] < ZTYPEreal && qhstat count[id] != -1)
660  qh_fprintf(fp, 9365, "%7.3g", (realT) qhstat stats[id].i / qhstat stats[(unsigned char)(qhstat count[id])].i);
661  qh_fprintf(fp, 9366, " %s\n", qhstat doc[id]);
662 } /* printstatlevel */
663 
664 
665 /*-<a href="qh-stat.htm#TOC"
666  >-------------------------------</a><a name="printstats">-</a>
667 
668  qh_printstats( fp, index, nextindex )
669  print statistics for a zdoc group
670 
671  returns:
672  next zdoc if non-null
673 */
674 void qh_printstats(FILE *fp, int idx, int *nextindex) {
675  int j, nexti;
676 
677  if (qh_newstats(idx, &nexti)) {
678  qh_fprintf(fp, 9367, "\n");
679  for (j=idx; j<nexti; j++)
680  qh_printstatlevel(fp, qhstat id[j]);
681  }
682  if (nextindex)
683  *nextindex= nexti;
684 } /* printstats */
685 
686 #if qh_KEEPstatistics
687 
688 /*-<a href="qh-stat.htm#TOC"
689  >-------------------------------</a><a name="stddev">-</a>
690 
691  qh_stddev( num, tot, tot2, ave )
692  compute the standard deviation and average from statistics
693 
694  tot2 is the sum of the squares
695  notes:
696  computes r.m.s.:
697  (x-ave)^2
698  == x^2 - 2x tot/num + (tot/num)^2
699  == tot2 - 2 tot tot/num + tot tot/num
700  == tot2 - tot ave
701 */
702 realT qh_stddev(int num, realT tot, realT tot2, realT *ave) {
703  realT stddev;
704 
705  *ave= tot/num;
706  stddev= sqrt(tot2/num - *ave * *ave);
707  return stddev;
708 } /* stddev */
709 
710 #endif /* qh_KEEPstatistics */
711 
712 #if !qh_KEEPstatistics
713 void qh_collectstatistics(void) {}
714 void qh_printallstatistics(FILE *fp, char *string) {};
715 void qh_printstatistics(FILE *fp, char *string) {}
716 #endif
717 
Definition: stat.h:131
Definition: stat.h:236
void qh_allstatC(void)
Definition: stat.c:90
void qh_printstatistics(FILE *fp, const char *string)
Definition: stat.c:578
Definition: stat.h:57
#define qh_ERRqhull
Definition: libqhull.h:198
void * qh_malloc(size_t size)
Definition: usermem.c:90
#define FORALLfacets
Definition: libqhull.h:840
Definition: stat.h:202
void qh_fprintf_stderr(int msgcode, const char *fmt,...)
Definition: usermem.c:57
void qh_free(void *mem)
Definition: usermem.c:77
#define zinc_(id)
Definition: stat.h:386
void qh_allstatD(void)
Definition: stat.c:122
#define wadd_(id, val)
Definition: stat.h:401
#define boolT
Definition: libqhull.h:121
setT * neighbors
Definition: libqhull.h:299
Definition: qset.h:83
Definition: stat.h:115
#define FOREACHvertex_(vertices)
Definition: libqhull.h:950
Definition: stat.h:67
qhmemT qhmem
Definition: mem.c:62
#define zadd_(id, val)
Definition: stat.h:400
Definition: stat.h:89
Definition: stat.h:162
Definition: stat.h:261
#define zzdef_(stype, name, string, cnt)
Definition: stat.h:369
Definition: stat.h:234
Definition: stat.h:99
Definition: stat.h:111
flagT deleted
Definition: libqhull.h:407
void qh_fprintf(FILE *fp, int msgcode, const char *fmt,...)
Definition: userprintf.c:42
const char qh_version[]
Definition: global.c:50
Definition: stat.h:125
Definition: stat.h:59
Definition: stat.h:122
Definition: stat.h:347
void qh_collectstatistics(void)
Definition: stat.c:316
setT * coplanarset
Definition: libqhull.h:305
Definition: stat.h:119
void qh_printstats(FILE *fp, int idx, int *nextindex)
Definition: stat.c:674
#define SETelemsize
Definition: qset.h:100
#define qh_MERGEridge
Definition: poly.h:57
Definition: stat.h:120
Definition: stat.h:347
setT * ridges
Definition: libqhull.h:297
#define qhstat
Definition: stat.h:500
Definition: stat.h:186
#define qh_DUPLICATEridge
Definition: poly.h:46
Definition: stat.h:347
#define REALmax
Definition: user.h:155
Definition: stat.h:113
Definition: stat.h:80
setT * vertices
Definition: libqhull.h:295
Definition: stat.h:65
void qh_allstatF(void)
Definition: stat.c:189
realT qh_getangle(pointT *vect1, pointT *vect2)
Definition: geom.c:644
setT * neighbors
Definition: libqhull.h:400
Definition: stat.h:114
#define True
Definition: libqhull.h:129
void qh_allstatistics(void)
Definition: stat.c:301
flagT simplicial
Definition: libqhull.h:324
Definition: stat.h:503
setT * outsideset
Definition: libqhull.h:302
void qh_allstatE2(void)
Definition: stat.c:170
Definition: stat.h:243
unsigned nummerge
Definition: libqhull.h:312
#define qh
Definition: libqhull.h:457
Definition: stat.h:347
Definition: stat.h:347
#define wval_(id)
Definition: stat.h:417
void qh_allstatB(void)
Definition: stat.c:60
Definition: stat.h:242
flagT upperdelaunay
Definition: libqhull.h:328
pointT * point
Definition: libqhull.h:399
Definition: stat.h:106
void qh_printallstatistics(FILE *fp, const char *string)
Definition: stat.c:559
void qh_freestatistics(void)
Definition: stat.c:430
Definition: stat.h:121
Definition: stat.h:149
#define REALepsilon
Definition: user.h:157
Definition: stat.h:112
void qh_exit(int exitcode)
Definition: stat.h:55
#define qh_ERRmem
Definition: libqhull.h:197
realT qh_stddev(int num, realT tot, realT tot2, realT *ave)
Definition: stat.c:702
void qh_allstatA(void)
Definition: stat.c:36
void qh_allstatI(void)
Definition: stat.c:270
Definition: stat.h:116
Definition: stat.h:118
#define FOREACHneighbor_(facet)
Definition: libqhull.h:908
Definition: stat.h:95
struct qhT qhT
Definition: libqhull.h:435
void qh_initstatistics(void)
Definition: stat.c:450
Definition: stat.h:62
void qh_printstatlevel(FILE *fp, int id)
Definition: stat.c:638
qhstatT qh_qhstat
Definition: stat.c:21
void qh_allstatE(void)
Definition: stat.c:148
flagT visible
Definition: libqhull.h:321
Definition: stat.h:347
Definition: stat.h:231
#define FORALLvertices
Definition: libqhull.h:877
Definition: stat.h:60
Definition: stat.h:75
#define wmin_(id, val)
Definition: stat.h:446
Definition: stat.h:278
Definition: stat.h:56
flagT seen
Definition: libqhull.h:325
boolT qh_newstats(int idx, int *nextindex)
Definition: stat.c:520
#define zval_(id)
Definition: stat.h:416
Definition: stat.h:130
Definition: stat.h:270
#define zmax_(id, val)
Definition: stat.h:431
FILE * ferr
Definition: mem.h:130
Definition: stat.h:54
Definition: stat.h:96
Definition: stat.h:200
Definition: stat.h:94
Definition: stat.h:347
Definition: stat.h:237
#define wmax_(id, val)
Definition: stat.h:432
Definition: stat.h:347
Definition: stat.h:117
#define False
Definition: libqhull.h:128
Definition: stat.h:197
Definition: stat.h:61
void qh_distplane(pointT *point, facetT *facet, realT *dist)
Definition: geom.c:36
int qh_setsize(setT *set)
Definition: qset.c:1111
#define zdef_(stype, name, string, cnt)
Definition: stat.h:372
boolT qh_nostatistic(int i)
Definition: stat.c:542
void qh_memstatistics(FILE *fp)
Definition: mem.c:431
Definition: stat.h:144
Definition: stat.h:274
#define realT
Definition: user.h:154
void qh_allstatH(void)
Definition: stat.c:241
coordT * normal
Definition: libqhull.h:274
void qh_allstatG(void)
Definition: stat.c:218
Definition: stat.h:233


hpp-fcl
Author(s):
autogenerated on Fri Jun 2 2023 02:39:02