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


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