stat.c
Go to the documentation of this file.
00001 /*<html><pre>  -<a                             href="qh-stat.htm"
00002   >-------------------------------</a><a name="TOP">-</a>
00003 
00004    stat.c
00005    contains all statistics that are collected for qhull
00006 
00007    see qh-stat.htm and stat.h
00008 
00009    Copyright (c) 1993-2011 The Geometry Center.
00010    $Id: //main/2011/qhull/src/libqhull/stat.c#2 $$Change: 1342 $
00011    $DateTime: 2011/03/07 21:55:47 $$Author: bbarber $
00012 */
00013 
00014 #include "qhull_a.h"
00015 
00016 /*============ global data structure ==========*/
00017 
00018 #if qh_QHpointer
00019 qhstatT *qh_qhstat=NULL;  /* global data structure */
00020 #else
00021 qhstatT qh_qhstat;   /* add "={0}" if this causes a compiler error */
00022 #endif
00023 
00024 /*========== functions in alphabetic order ================*/
00025 
00026 /*-<a                             href="qh-stat.htm#TOC"
00027   >-------------------------------</a><a name="allstatA">-</a>
00028 
00029   qh_allstatA()
00030     define statistics in groups of 20
00031 
00032   notes:
00033     (otherwise, 'gcc -O2' uses too much memory)
00034     uses qhstat.next
00035 */
00036 void qh_allstatA(void) {
00037 
00038    /* zdef_(type,name,doc,average) */
00039   zzdef_(zdoc, Zdoc2, "precision statistics", -1);
00040   zdef_(zinc, Znewvertex, NULL, -1);
00041   zdef_(wadd, Wnewvertex, "ave. distance of a new vertex to a facet(!0s)", Znewvertex);
00042   zzdef_(wmax, Wnewvertexmax, "max. distance of a new vertex to a facet", -1);
00043   zdef_(wmax, Wvertexmax, "max. distance of an output vertex to a facet", -1);
00044   zdef_(wmin, Wvertexmin, "min. distance of an output vertex to a facet", -1);
00045   zdef_(wmin, Wmindenom, "min. denominator in hyperplane computation", -1);
00046 
00047   qhstat precision= qhstat next;  /* call qh_precision for each of these */
00048   zzdef_(zdoc, Zdoc3, "precision problems (corrected unless 'Q0' or an error)", -1);
00049   zzdef_(zinc, Zcoplanarridges, "coplanar half ridges in output", -1);
00050   zzdef_(zinc, Zconcaveridges, "concave half ridges in output", -1);
00051   zzdef_(zinc, Zflippedfacets, "flipped facets", -1);
00052   zzdef_(zinc, Zcoplanarhorizon, "coplanar horizon facets for new vertices", -1);
00053   zzdef_(zinc, Zcoplanarpart, "coplanar points during partitioning", -1);
00054   zzdef_(zinc, Zminnorm, "degenerate hyperplanes recomputed with gaussian elimination", -1);
00055   zzdef_(zinc, Znearlysingular, "nearly singular or axis-parallel hyperplanes", -1);
00056   zzdef_(zinc, Zback0, "zero divisors during back substitute", -1);
00057   zzdef_(zinc, Zgauss0, "zero divisors during gaussian elimination", -1);
00058   zzdef_(zinc, Zmultiridge, "ridges with multiple neighbors", -1);
00059 }
00060 void qh_allstatB(void) {
00061   zzdef_(zdoc, Zdoc1, "summary information", -1);
00062   zdef_(zinc, Zvertices, "number of vertices in output", -1);
00063   zdef_(zinc, Znumfacets, "number of facets in output", -1);
00064   zdef_(zinc, Znonsimplicial, "number of non-simplicial facets in output", -1);
00065   zdef_(zinc, Znowsimplicial, "number of simplicial facets that were merged", -1);
00066   zdef_(zinc, Znumridges, "number of ridges in output", -1);
00067   zdef_(zadd, Znumridges, "average number of ridges per facet", Znumfacets);
00068   zdef_(zmax, Zmaxridges, "maximum number of ridges", -1);
00069   zdef_(zadd, Znumneighbors, "average number of neighbors per facet", Znumfacets);
00070   zdef_(zmax, Zmaxneighbors, "maximum number of neighbors", -1);
00071   zdef_(zadd, Znumvertices, "average number of vertices per facet", Znumfacets);
00072   zdef_(zmax, Zmaxvertices, "maximum number of vertices", -1);
00073   zdef_(zadd, Znumvneighbors, "average number of neighbors per vertex", Zvertices);
00074   zdef_(zmax, Zmaxvneighbors, "maximum number of neighbors", -1);
00075   zdef_(wadd, Wcpu, "cpu seconds for qhull after input", -1);
00076   zdef_(zinc, Ztotvertices, "vertices created altogether", -1);
00077   zzdef_(zinc, Zsetplane, "facets created altogether", -1);
00078   zdef_(zinc, Ztotridges, "ridges created altogether", -1);
00079   zdef_(zinc, Zpostfacets, "facets before post merge", -1);
00080   zdef_(zadd, Znummergetot, "average merges per facet(at most 511)", Znumfacets);
00081   zdef_(zmax, Znummergemax, "  maximum merges for a facet(at most 511)", -1);
00082   zdef_(zinc, Zangle, NULL, -1);
00083   zdef_(wadd, Wangle, "average angle(cosine) of facet normals for all ridges", Zangle);
00084   zdef_(wmax, Wanglemax, "  maximum angle(cosine) of facet normals across a ridge", -1);
00085   zdef_(wmin, Wanglemin, "  minimum angle(cosine) of facet normals across a ridge", -1);
00086   zdef_(wadd, Wareatot, "total area of facets", -1);
00087   zdef_(wmax, Wareamax, "  maximum facet area", -1);
00088   zdef_(wmin, Wareamin, "  minimum facet area", -1);
00089 }
00090 void qh_allstatC(void) {
00091   zdef_(zdoc, Zdoc9, "build hull statistics", -1);
00092   zzdef_(zinc, Zprocessed, "points processed", -1);
00093   zzdef_(zinc, Zretry, "retries due to precision problems", -1);
00094   zdef_(wmax, Wretrymax, "  max. random joggle", -1);
00095   zdef_(zmax, Zmaxvertex, "max. vertices at any one time", -1);
00096   zdef_(zinc, Ztotvisible, "ave. visible facets per iteration", Zprocessed);
00097   zdef_(zinc, Zinsidevisible, "  ave. visible facets without an horizon neighbor", Zprocessed);
00098   zdef_(zadd, Zvisfacettot,  "  ave. facets deleted per iteration", Zprocessed);
00099   zdef_(zmax, Zvisfacetmax,  "    maximum", -1);
00100   zdef_(zadd, Zvisvertextot, "ave. visible vertices per iteration", Zprocessed);
00101   zdef_(zmax, Zvisvertexmax, "    maximum", -1);
00102   zdef_(zinc, Ztothorizon, "ave. horizon facets per iteration", Zprocessed);
00103   zdef_(zadd, Znewfacettot,  "ave. new or merged facets per iteration", Zprocessed);
00104   zdef_(zmax, Znewfacetmax,  "    maximum(includes initial simplex)", -1);
00105   zdef_(wadd, Wnewbalance, "average new facet balance", Zprocessed);
00106   zdef_(wadd, Wnewbalance2, "  standard deviation", -1);
00107   zdef_(wadd, Wpbalance, "average partition balance", Zpbalance);
00108   zdef_(wadd, Wpbalance2, "  standard deviation", -1);
00109   zdef_(zinc, Zpbalance, "  number of trials", -1);
00110   zdef_(zinc, Zsearchpoints, "searches of all points for initial simplex", -1);
00111   zdef_(zinc, Zdetsimplex, "determinants computed(area & initial hull)", -1);
00112   zdef_(zinc, Znoarea, "determinants not computed because vertex too low", -1);
00113   zdef_(zinc, Znotmax, "points ignored(!above max_outside)", -1);
00114   zdef_(zinc, Znotgood, "points ignored(!above a good facet)", -1);
00115   zdef_(zinc, Znotgoodnew, "points ignored(didn't create a good new facet)", -1);
00116   zdef_(zinc, Zgoodfacet, "good facets found", -1);
00117   zzdef_(zinc, Znumvisibility, "distance tests for facet visibility", -1);
00118   zdef_(zinc, Zdistvertex, "distance tests to report minimum vertex", -1);
00119   zzdef_(zinc, Ztotcheck, "points checked for facets' outer planes", -1);
00120   zzdef_(zinc, Zcheckpart, "  ave. distance tests per check", Ztotcheck);
00121 }
00122 void qh_allstatD(void) {
00123   zdef_(zinc, Zvisit, "resets of visit_id", -1);
00124   zdef_(zinc, Zvvisit, "  resets of vertex_visit", -1);
00125   zdef_(zmax, Zvisit2max, "  max visit_id/2", -1);
00126   zdef_(zmax, Zvvisit2max, "  max vertex_visit/2", -1);
00127 
00128   zdef_(zdoc, Zdoc4, "partitioning statistics(see previous for outer planes)", -1);
00129   zzdef_(zadd, Zdelvertextot, "total vertices deleted", -1);
00130   zdef_(zmax, Zdelvertexmax, "    maximum vertices deleted per iteration", -1);
00131   zdef_(zinc, Zfindbest, "calls to findbest", -1);
00132   zdef_(zadd, Zfindbesttot, " ave. facets tested", Zfindbest);
00133   zdef_(zmax, Zfindbestmax, " max. facets tested", -1);
00134   zdef_(zadd, Zfindcoplanar, " ave. coplanar search", Zfindbest);
00135   zdef_(zinc, Zfindnew, "calls to findbestnew", -1);
00136   zdef_(zadd, Zfindnewtot, " ave. facets tested", Zfindnew);
00137   zdef_(zmax, Zfindnewmax, " max. facets tested", -1);
00138   zdef_(zinc, Zfindnewjump, " ave. clearly better", Zfindnew);
00139   zdef_(zinc, Zfindnewsharp, " calls due to qh_sharpnewfacets", -1);
00140   zdef_(zinc, Zfindhorizon, "calls to findhorizon", -1);
00141   zdef_(zadd, Zfindhorizontot, " ave. facets tested", Zfindhorizon);
00142   zdef_(zmax, Zfindhorizonmax, " max. facets tested", -1);
00143   zdef_(zinc, Zfindjump,       " ave. clearly better", Zfindhorizon);
00144   zdef_(zinc, Zparthorizon, " horizon facets better than bestfacet", -1);
00145   zdef_(zinc, Zpartangle, "angle tests for repartitioned coplanar points", -1);
00146   zdef_(zinc, Zpartflip, "  repartitioned coplanar points for flipped orientation", -1);
00147 }
00148 void qh_allstatE(void) {
00149   zdef_(zinc, Zpartinside, "inside points", -1);
00150   zdef_(zinc, Zpartnear, "  inside points kept with a facet", -1);
00151   zdef_(zinc, Zcoplanarinside, "  inside points that were coplanar with a facet", -1);
00152   zdef_(zinc, Zbestlower, "calls to findbestlower", -1);
00153   zdef_(zinc, Zbestlowerv, "  with search of vertex neighbors", -1);
00154   zdef_(wadd, Wmaxout, "difference in max_outside at final check", -1);
00155   zzdef_(zinc, Zpartitionall, "distance tests for initial partition", -1);
00156   zdef_(zinc, Ztotpartition, "partitions of a point", -1);
00157   zzdef_(zinc, Zpartition, "distance tests for partitioning", -1);
00158   zzdef_(zinc, Zdistcheck, "distance tests for checking flipped facets", -1);
00159   zzdef_(zinc, Zdistconvex, "distance tests for checking convexity", -1);
00160   zdef_(zinc, Zdistgood, "distance tests for checking good point", -1);
00161   zdef_(zinc, Zdistio, "distance tests for output", -1);
00162   zdef_(zinc, Zdiststat, "distance tests for statistics", -1);
00163   zdef_(zinc, Zdistplane, "total number of distance tests", -1);
00164   zdef_(zinc, Ztotpartcoplanar, "partitions of coplanar points or deleted vertices", -1);
00165   zzdef_(zinc, Zpartcoplanar, "   distance tests for these partitions", -1);
00166   zdef_(zinc, Zcomputefurthest, "distance tests for computing furthest", -1);
00167 }
00168 void qh_allstatE2(void) {
00169   zdef_(zdoc, Zdoc5, "statistics for matching ridges", -1);
00170   zdef_(zinc, Zhashlookup, "total lookups for matching ridges of new facets", -1);
00171   zdef_(zinc, Zhashtests, "average number of tests to match a ridge", Zhashlookup);
00172   zdef_(zinc, Zhashridge, "total lookups of subridges(duplicates and boundary)", -1);
00173   zdef_(zinc, Zhashridgetest, "average number of tests per subridge", Zhashridge);
00174   zdef_(zinc, Zdupsame, "duplicated ridges in same merge cycle", -1);
00175   zdef_(zinc, Zdupflip, "duplicated ridges with flipped facets", -1);
00176 
00177   zdef_(zdoc, Zdoc6, "statistics for determining merges", -1);
00178   zdef_(zinc, Zangletests, "angles computed for ridge convexity", -1);
00179   zdef_(zinc, Zbestcentrum, "best merges used centrum instead of vertices",-1);
00180   zzdef_(zinc, Zbestdist, "distance tests for best merge", -1);
00181   zzdef_(zinc, Zcentrumtests, "distance tests for centrum convexity", -1);
00182   zzdef_(zinc, Zdistzero, "distance tests for checking simplicial convexity", -1);
00183   zdef_(zinc, Zcoplanarangle, "coplanar angles in getmergeset", -1);
00184   zdef_(zinc, Zcoplanarcentrum, "coplanar centrums in getmergeset", -1);
00185   zdef_(zinc, Zconcaveridge, "concave ridges in getmergeset", -1);
00186 }
00187 void qh_allstatF(void) {
00188   zdef_(zdoc, Zdoc7, "statistics for merging", -1);
00189   zdef_(zinc, Zpremergetot, "merge iterations", -1);
00190   zdef_(zadd, Zmergeinittot, "ave. initial non-convex ridges per iteration", Zpremergetot);
00191   zdef_(zadd, Zmergeinitmax, "  maximum", -1);
00192   zdef_(zadd, Zmergesettot, "  ave. additional non-convex ridges per iteration", Zpremergetot);
00193   zdef_(zadd, Zmergesetmax, "  maximum additional in one pass", -1);
00194   zdef_(zadd, Zmergeinittot2, "initial non-convex ridges for post merging", -1);
00195   zdef_(zadd, Zmergesettot2, "  additional non-convex ridges", -1);
00196   zdef_(wmax, Wmaxoutside, "max distance of vertex or coplanar point above facet(w/roundoff)", -1);
00197   zdef_(wmin, Wminvertex, "max distance of merged vertex below facet(or roundoff)", -1);
00198   zdef_(zinc, Zwidefacet, "centrums frozen due to a wide merge", -1);
00199   zdef_(zinc, Zwidevertices, "centrums frozen due to extra vertices", -1);
00200   zzdef_(zinc, Ztotmerge, "total number of facets or cycles of facets merged", -1);
00201   zdef_(zinc, Zmergesimplex, "merged a simplex", -1);
00202   zdef_(zinc, Zonehorizon, "simplices merged into coplanar horizon", -1);
00203   zzdef_(zinc, Zcyclehorizon, "cycles of facets merged into coplanar horizon", -1);
00204   zzdef_(zadd, Zcyclefacettot, "  ave. facets per cycle", Zcyclehorizon);
00205   zdef_(zmax, Zcyclefacetmax, "  max. facets", -1);
00206   zdef_(zinc, Zmergeintohorizon, "new facets merged into horizon", -1);
00207   zdef_(zinc, Zmergenew, "new facets merged", -1);
00208   zdef_(zinc, Zmergehorizon, "horizon facets merged into new facets", -1);
00209   zdef_(zinc, Zmergevertex, "vertices deleted by merging", -1);
00210   zdef_(zinc, Zcyclevertex, "vertices deleted by merging into coplanar horizon", -1);
00211   zdef_(zinc, Zdegenvertex, "vertices deleted by degenerate facet", -1);
00212   zdef_(zinc, Zmergeflipdup, "merges due to flipped facets in duplicated ridge", -1);
00213   zdef_(zinc, Zneighbor, "merges due to redundant neighbors", -1);
00214   zdef_(zadd, Ztestvneighbor, "non-convex vertex neighbors", -1);
00215 }
00216 void qh_allstatG(void) {
00217   zdef_(zinc, Zacoplanar, "merges due to angle coplanar facets", -1);
00218   zdef_(wadd, Wacoplanartot, "  average merge distance", Zacoplanar);
00219   zdef_(wmax, Wacoplanarmax, "  maximum merge distance", -1);
00220   zdef_(zinc, Zcoplanar, "merges due to coplanar facets", -1);
00221   zdef_(wadd, Wcoplanartot, "  average merge distance", Zcoplanar);
00222   zdef_(wmax, Wcoplanarmax, "  maximum merge distance", -1);
00223   zdef_(zinc, Zconcave, "merges due to concave facets", -1);
00224   zdef_(wadd, Wconcavetot, "  average merge distance", Zconcave);
00225   zdef_(wmax, Wconcavemax, "  maximum merge distance", -1);
00226   zdef_(zinc, Zavoidold, "coplanar/concave merges due to avoiding old merge", -1);
00227   zdef_(wadd, Wavoidoldtot, "  average merge distance", Zavoidold);
00228   zdef_(wmax, Wavoidoldmax, "  maximum merge distance", -1);
00229   zdef_(zinc, Zdegen, "merges due to degenerate facets", -1);
00230   zdef_(wadd, Wdegentot, "  average merge distance", Zdegen);
00231   zdef_(wmax, Wdegenmax, "  maximum merge distance", -1);
00232   zdef_(zinc, Zflipped, "merges due to removing flipped facets", -1);
00233   zdef_(wadd, Wflippedtot, "  average merge distance", Zflipped);
00234   zdef_(wmax, Wflippedmax, "  maximum merge distance", -1);
00235   zdef_(zinc, Zduplicate, "merges due to duplicated ridges", -1);
00236   zdef_(wadd, Wduplicatetot, "  average merge distance", Zduplicate);
00237   zdef_(wmax, Wduplicatemax, "  maximum merge distance", -1);
00238 }
00239 void qh_allstatH(void) {
00240   zdef_(zdoc, Zdoc8, "renamed vertex statistics", -1);
00241   zdef_(zinc, Zrenameshare, "renamed vertices shared by two facets", -1);
00242   zdef_(zinc, Zrenamepinch, "renamed vertices in a pinched facet", -1);
00243   zdef_(zinc, Zrenameall, "renamed vertices shared by multiple facets", -1);
00244   zdef_(zinc, Zfindfail, "rename failures due to duplicated ridges", -1);
00245   zdef_(zinc, Zdupridge, "  duplicate ridges detected", -1);
00246   zdef_(zinc, Zdelridge, "deleted ridges due to renamed vertices", -1);
00247   zdef_(zinc, Zdropneighbor, "dropped neighbors due to renamed vertices", -1);
00248   zdef_(zinc, Zdropdegen, "degenerate facets due to dropped neighbors", -1);
00249   zdef_(zinc, Zdelfacetdup, "  facets deleted because of no neighbors", -1);
00250   zdef_(zinc, Zremvertex, "vertices removed from facets due to no ridges", -1);
00251   zdef_(zinc, Zremvertexdel, "  deleted", -1);
00252   zdef_(zinc, Zintersectnum, "vertex intersections for locating redundant vertices", -1);
00253   zdef_(zinc, Zintersectfail, "intersections failed to find a redundant vertex", -1);
00254   zdef_(zinc, Zintersect, "intersections found redundant vertices", -1);
00255   zdef_(zadd, Zintersecttot, "   ave. number found per vertex", Zintersect);
00256   zdef_(zmax, Zintersectmax, "   max. found for a vertex", -1);
00257   zdef_(zinc, Zvertexridge, NULL, -1);
00258   zdef_(zadd, Zvertexridgetot, "  ave. number of ridges per tested vertex", Zvertexridge);
00259   zdef_(zmax, Zvertexridgemax, "  max. number of ridges per tested vertex", -1);
00260 
00261   zdef_(zdoc, Zdoc10, "memory usage statistics(in bytes)", -1);
00262   zdef_(zadd, Zmemfacets, "for facets and their normals, neighbor and vertex sets", -1);
00263   zdef_(zadd, Zmemvertices, "for vertices and their neighbor sets", -1);
00264   zdef_(zadd, Zmempoints, "for input points and outside and coplanar sets",-1);
00265   zdef_(zadd, Zmemridges, "for ridges and their vertex sets", -1);
00266 } /* allstat */
00267 
00268 void qh_allstatI(void) {
00269   qhstat vridges= qhstat next;
00270   zzdef_(zdoc, Zdoc11, "Voronoi ridge statistics", -1);
00271   zzdef_(zinc, Zridge, "non-simplicial Voronoi vertices for all ridges", -1);
00272   zzdef_(wadd, Wridge, "  ave. distance to ridge", Zridge);
00273   zzdef_(wmax, Wridgemax, "  max. distance to ridge", -1);
00274   zzdef_(zinc, Zridgemid, "bounded ridges", -1);
00275   zzdef_(wadd, Wridgemid, "  ave. distance of midpoint to ridge", Zridgemid);
00276   zzdef_(wmax, Wridgemidmax, "  max. distance of midpoint to ridge", -1);
00277   zzdef_(zinc, Zridgeok, "bounded ridges with ok normal", -1);
00278   zzdef_(wadd, Wridgeok, "  ave. angle to ridge", Zridgeok);
00279   zzdef_(wmax, Wridgeokmax, "  max. angle to ridge", -1);
00280   zzdef_(zinc, Zridge0, "bounded ridges with near-zero normal", -1);
00281   zzdef_(wadd, Wridge0, "  ave. angle to ridge", Zridge0);
00282   zzdef_(wmax, Wridge0max, "  max. angle to ridge", -1);
00283 
00284   zdef_(zdoc, Zdoc12, "Triangulation statistics(Qt)", -1);
00285   zdef_(zinc, Ztricoplanar, "non-simplicial facets triangulated", -1);
00286   zdef_(zadd, Ztricoplanartot, "  ave. new facets created(may be deleted)", Ztricoplanar);
00287   zdef_(zmax, Ztricoplanarmax, "  max. new facets created", -1);
00288   zdef_(zinc, Ztrinull, "null new facets deleted(duplicated vertex)", -1);
00289   zdef_(zinc, Ztrimirror, "mirrored pairs of new facets deleted(same vertices)", -1);
00290   zdef_(zinc, Ztridegen, "degenerate new facets in output(same ridge)", -1);
00291 } /* allstat */
00292 
00293 /*-<a                             href="qh-stat.htm#TOC"
00294   >-------------------------------</a><a name="allstatistics">-</a>
00295 
00296   qh_allstatistics()
00297     reset printed flag for all statistics
00298 */
00299 void qh_allstatistics(void) {
00300   int i;
00301 
00302   for(i=ZEND; i--; )
00303     qhstat printed[i]= False;
00304 } /* allstatistics */
00305 
00306 #if qh_KEEPstatistics
00307 /*-<a                             href="qh-stat.htm#TOC"
00308   >-------------------------------</a><a name="collectstatistics">-</a>
00309 
00310   qh_collectstatistics()
00311     collect statistics for qh.facet_list
00312 
00313 */
00314 void qh_collectstatistics(void) {
00315   facetT *facet, *neighbor, **neighborp;
00316   vertexT *vertex, **vertexp;
00317   realT dotproduct, dist;
00318   int sizneighbors, sizridges, sizvertices, i;
00319 
00320   qh old_randomdist= qh RANDOMdist;
00321   qh RANDOMdist= False;
00322   zval_(Zmempoints)= qh num_points * qh normal_size +
00323                              sizeof(qhT) + sizeof(qhstatT);
00324   zval_(Zmemfacets)= 0;
00325   zval_(Zmemridges)= 0;
00326   zval_(Zmemvertices)= 0;
00327   zval_(Zangle)= 0;
00328   wval_(Wangle)= 0.0;
00329   zval_(Znumridges)= 0;
00330   zval_(Znumfacets)= 0;
00331   zval_(Znumneighbors)= 0;
00332   zval_(Znumvertices)= 0;
00333   zval_(Znumvneighbors)= 0;
00334   zval_(Znummergetot)= 0;
00335   zval_(Znummergemax)= 0;
00336   zval_(Zvertices)= qh num_vertices - qh_setsize(qh del_vertices);
00337   if (qh MERGING || qh APPROXhull || qh JOGGLEmax < REALmax/2)
00338     wmax_(Wmaxoutside, qh max_outside);
00339   if (qh MERGING)
00340     wmin_(Wminvertex, qh min_vertex);
00341   FORALLfacets
00342     facet->seen= False;
00343   if (qh DELAUNAY) {
00344     FORALLfacets {
00345       if (facet->upperdelaunay != qh UPPERdelaunay)
00346         facet->seen= True; /* remove from angle statistics */
00347     }
00348   }
00349   FORALLfacets {
00350     if (facet->visible && qh NEWfacets)
00351       continue;
00352     sizvertices= qh_setsize(facet->vertices);
00353     sizneighbors= qh_setsize(facet->neighbors);
00354     sizridges= qh_setsize(facet->ridges);
00355     zinc_(Znumfacets);
00356     zadd_(Znumvertices, sizvertices);
00357     zmax_(Zmaxvertices, sizvertices);
00358     zadd_(Znumneighbors, sizneighbors);
00359     zmax_(Zmaxneighbors, sizneighbors);
00360     zadd_(Znummergetot, facet->nummerge);
00361     i= facet->nummerge; /* avoid warnings */
00362     zmax_(Znummergemax, i);
00363     if (!facet->simplicial) {
00364       if (sizvertices == qh hull_dim) {
00365         zinc_(Znowsimplicial);
00366       }else {
00367         zinc_(Znonsimplicial);
00368       }
00369     }
00370     if (sizridges) {
00371       zadd_(Znumridges, sizridges);
00372       zmax_(Zmaxridges, sizridges);
00373     }
00374     zadd_(Zmemfacets, sizeof(facetT) + qh normal_size + 2*sizeof(setT)
00375        + SETelemsize * (sizneighbors + sizvertices));
00376     if (facet->ridges) {
00377       zadd_(Zmemridges,
00378          sizeof(setT) + SETelemsize * sizridges + sizridges *
00379          (sizeof(ridgeT) + sizeof(setT) + SETelemsize * (qh hull_dim-1))/2);
00380     }
00381     if (facet->outsideset)
00382       zadd_(Zmempoints, sizeof(setT) + SETelemsize * qh_setsize(facet->outsideset));
00383     if (facet->coplanarset)
00384       zadd_(Zmempoints, sizeof(setT) + SETelemsize * qh_setsize(facet->coplanarset));
00385     if (facet->seen) /* Delaunay upper envelope */
00386       continue;
00387     facet->seen= True;
00388     FOREACHneighbor_(facet) {
00389       if (neighbor == qh_DUPLICATEridge || neighbor == qh_MERGEridge
00390           || neighbor->seen || !facet->normal || !neighbor->normal)
00391         continue;
00392       dotproduct= qh_getangle(facet->normal, neighbor->normal);
00393       zinc_(Zangle);
00394       wadd_(Wangle, dotproduct);
00395       wmax_(Wanglemax, dotproduct)
00396       wmin_(Wanglemin, dotproduct)
00397     }
00398     if (facet->normal) {
00399       FOREACHvertex_(facet->vertices) {
00400         zinc_(Zdiststat);
00401         qh_distplane(vertex->point, facet, &dist);
00402         wmax_(Wvertexmax, dist);
00403         wmin_(Wvertexmin, dist);
00404       }
00405     }
00406   }
00407   FORALLvertices {
00408     if (vertex->deleted)
00409       continue;
00410     zadd_(Zmemvertices, sizeof(vertexT));
00411     if (vertex->neighbors) {
00412       sizneighbors= qh_setsize(vertex->neighbors);
00413       zadd_(Znumvneighbors, sizneighbors);
00414       zmax_(Zmaxvneighbors, sizneighbors);
00415       zadd_(Zmemvertices, sizeof(vertexT) + SETelemsize * sizneighbors);
00416     }
00417   }
00418   qh RANDOMdist= qh old_randomdist;
00419 } /* collectstatistics */
00420 #endif /* qh_KEEPstatistics */
00421 
00422 /*-<a                             href="qh-stat.htm#TOC"
00423   >-------------------------------</a><a name="freestatistics">-</a>
00424 
00425   qh_freestatistics(  )
00426     free memory used for statistics
00427 */
00428 void qh_freestatistics(void) {
00429 
00430 #if qh_QHpointer
00431   qh_free(qh_qhstat);
00432   qh_qhstat= NULL;
00433 #endif
00434 } /* freestatistics */
00435 
00436 /*-<a                             href="qh-stat.htm#TOC"
00437   >-------------------------------</a><a name="initstatistics">-</a>
00438 
00439   qh_initstatistics(  )
00440     allocate and initialize statistics
00441 
00442   notes:
00443     uses qh_malloc() instead of qh_memalloc() since mem.c not set up yet
00444     NOerrors -- qh_initstatistics can not use qh_errexit().  One first call, qh_memalloc is not initialized.  Also invoked by QhullQh().
00445 */
00446 void qh_initstatistics(void) {
00447   int i;
00448   realT realx;
00449   int intx;
00450 
00451 #if qh_QHpointer
00452   if(qh_qhstat){  /* qh_initstatistics may be called from Qhull::resetStatistics() */
00453       qh_free(qh_qhstat);
00454       qh_qhstat= 0;
00455   }
00456   if (!(qh_qhstat= (qhstatT *)qh_malloc(sizeof(qhstatT)))) {
00457     qh_fprintf(qhmem.ferr, 6183, "qhull error (qh_initstatistics): insufficient memory\n");
00458     qh_exit(qh_ERRmem);  /* can not use qh_errexit() */
00459   }
00460 #endif
00461 
00462   qhstat next= 0;
00463   qh_allstatA();
00464   qh_allstatB();
00465   qh_allstatC();
00466   qh_allstatD();
00467   qh_allstatE();
00468   qh_allstatE2();
00469   qh_allstatF();
00470   qh_allstatG();
00471   qh_allstatH();
00472   qh_allstatI();
00473   if (qhstat next > (int)sizeof(qhstat id)) {
00474     qh_fprintf(qhmem.ferr, 6184, "qhull error (qh_initstatistics): increase size of qhstat.id[].\n\
00475       qhstat.next %d should be <= sizeof(qhstat id) %d\n", qhstat next, (int)sizeof(qhstat id));
00476 #if 0 /* for locating error, Znumridges should be duplicated */
00477     for(i=0; i < ZEND; i++) {
00478       int j;
00479       for(j=i+1; j < ZEND; j++) {
00480         if (qhstat id[i] == qhstat id[j]) {
00481           qh_fprintf(qhmem.ferr, 6185, "qhull error (qh_initstatistics): duplicated statistic %d at indices %d and %d\n",
00482               qhstat id[i], i, j);
00483         }
00484       }
00485     }
00486 #endif
00487     qh_exit(qh_ERRqhull);  /* can not use qh_errexit() */
00488   }
00489   qhstat init[zinc].i= 0;
00490   qhstat init[zadd].i= 0;
00491   qhstat init[zmin].i= INT_MAX;
00492   qhstat init[zmax].i= INT_MIN;
00493   qhstat init[wadd].r= 0;
00494   qhstat init[wmin].r= REALmax;
00495   qhstat init[wmax].r= -REALmax;
00496   for(i=0; i < ZEND; i++) {
00497     if (qhstat type[i] > ZTYPEreal) {
00498       realx= qhstat init[(unsigned char)(qhstat type[i])].r;
00499       qhstat stats[i].r= realx;
00500     }else if (qhstat type[i] != zdoc) {
00501       intx= qhstat init[(unsigned char)(qhstat type[i])].i;
00502       qhstat stats[i].i= intx;
00503     }
00504   }
00505 } /* initstatistics */
00506 
00507 /*-<a                             href="qh-stat.htm#TOC"
00508   >-------------------------------</a><a name="newstats">-</a>
00509 
00510   qh_newstats(  )
00511     returns True if statistics for zdoc
00512 
00513   returns:
00514     next zdoc
00515 */
00516 boolT qh_newstats(int idx, int *nextindex) {
00517   boolT isnew= False;
00518   int start, i;
00519 
00520   if (qhstat type[qhstat id[idx]] == zdoc)
00521     start= idx+1;
00522   else
00523     start= idx;
00524   for(i= start; i < qhstat next && qhstat type[qhstat id[i]] != zdoc; i++) {
00525     if (!qh_nostatistic(qhstat id[i]) && !qhstat printed[qhstat id[i]])
00526         isnew= True;
00527   }
00528   *nextindex= i;
00529   return isnew;
00530 } /* newstats */
00531 
00532 /*-<a                             href="qh-stat.htm#TOC"
00533   >-------------------------------</a><a name="nostatistic">-</a>
00534 
00535   qh_nostatistic( index )
00536     true if no statistic to print
00537 */
00538 boolT qh_nostatistic(int i) {
00539 
00540   if ((qhstat type[i] > ZTYPEreal
00541        &&qhstat stats[i].r == qhstat init[(unsigned char)(qhstat type[i])].r)
00542       || (qhstat type[i] < ZTYPEreal
00543           &&qhstat stats[i].i == qhstat init[(unsigned char)(qhstat type[i])].i))
00544     return True;
00545   return False;
00546 } /* nostatistic */
00547 
00548 #if qh_KEEPstatistics
00549 /*-<a                             href="qh-stat.htm#TOC"
00550   >-------------------------------</a><a name="printallstatistics">-</a>
00551 
00552   qh_printallstatistics( fp, string )
00553     print all statistics with header 'string'
00554 */
00555 void qh_printallstatistics(FILE *fp, const char *string) {
00556 
00557   qh_allstatistics();
00558   qh_collectstatistics();
00559   qh_printstatistics(fp, string);
00560   qh_memstatistics(fp);
00561 }
00562 
00563 
00564 /*-<a                             href="qh-stat.htm#TOC"
00565   >-------------------------------</a><a name="printstatistics">-</a>
00566 
00567   qh_printstatistics( fp, string )
00568     print statistics to a file with header 'string'
00569     skips statistics with qhstat.printed[] (reset with qh_allstatistics)
00570 
00571   see:
00572     qh_printallstatistics()
00573 */
00574 void qh_printstatistics(FILE *fp, const char *string) {
00575   int i, k;
00576   realT ave;
00577 
00578   if (qh num_points != qh num_vertices) {
00579     wval_(Wpbalance)= 0;
00580     wval_(Wpbalance2)= 0;
00581   }else
00582     wval_(Wpbalance2)= qh_stddev(zval_(Zpbalance), wval_(Wpbalance),
00583                                  wval_(Wpbalance2), &ave);
00584   wval_(Wnewbalance2)= qh_stddev(zval_(Zprocessed), wval_(Wnewbalance),
00585                                  wval_(Wnewbalance2), &ave);
00586   qh_fprintf(fp, 9350, "\n\
00587 %s\n\
00588  qhull invoked by: %s | %s\n%s with options:\n%s\n", string, qh rbox_command,
00589      qh qhull_command, qh_version, qh qhull_options);
00590   qh_fprintf(fp, 9351, "\nprecision constants:\n\
00591  %6.2g max. abs. coordinate in the (transformed) input('Qbd:n')\n\
00592  %6.2g max. roundoff error for distance computation('En')\n\
00593  %6.2g max. roundoff error for angle computations\n\
00594  %6.2g min. distance for outside points ('Wn')\n\
00595  %6.2g min. distance for visible facets ('Vn')\n\
00596  %6.2g max. distance for coplanar facets ('Un')\n\
00597  %6.2g max. facet width for recomputing centrum and area\n\
00598 ",
00599   qh MAXabs_coord, qh DISTround, qh ANGLEround, qh MINoutside,
00600         qh MINvisible, qh MAXcoplanar, qh WIDEfacet);
00601   if (qh KEEPnearinside)
00602     qh_fprintf(fp, 9352, "\
00603  %6.2g max. distance for near-inside points\n", qh NEARinside);
00604   if (qh premerge_cos < REALmax/2) qh_fprintf(fp, 9353, "\
00605  %6.2g max. cosine for pre-merge angle\n", qh premerge_cos);
00606   if (qh PREmerge) qh_fprintf(fp, 9354, "\
00607  %6.2g radius of pre-merge centrum\n", qh premerge_centrum);
00608   if (qh postmerge_cos < REALmax/2) qh_fprintf(fp, 9355, "\
00609  %6.2g max. cosine for post-merge angle\n", qh postmerge_cos);
00610   if (qh POSTmerge) qh_fprintf(fp, 9356, "\
00611  %6.2g radius of post-merge centrum\n", qh postmerge_centrum);
00612   qh_fprintf(fp, 9357, "\
00613  %6.2g max. distance for merging two simplicial facets\n\
00614  %6.2g max. roundoff error for arithmetic operations\n\
00615  %6.2g min. denominator for divisions\n\
00616   zero diagonal for Gauss: ", qh ONEmerge, REALepsilon, qh MINdenom);
00617   for(k=0; k < qh hull_dim; k++)
00618     qh_fprintf(fp, 9358, "%6.2e ", qh NEARzero[k]);
00619   qh_fprintf(fp, 9359, "\n\n");
00620   for(i=0 ; i < qhstat next; )
00621     qh_printstats(fp, i, &i);
00622 } /* printstatistics */
00623 #endif /* qh_KEEPstatistics */
00624 
00625 /*-<a                             href="qh-stat.htm#TOC"
00626   >-------------------------------</a><a name="printstatlevel">-</a>
00627 
00628   qh_printstatlevel( fp, id )
00629     print level information for a statistic
00630 
00631   notes:
00632     nop if id >= ZEND, printed, or same as initial value
00633 */
00634 void qh_printstatlevel(FILE *fp, int id, int start) {
00635 #define NULLfield "       "
00636 
00637   if (id >= ZEND || qhstat printed[id])
00638     return;
00639   if (qhstat type[id] == zdoc) {
00640     qh_fprintf(fp, 9360, "%s\n", qhstat doc[id]);
00641     return;
00642   }
00643   start= 0; /* not used */
00644   if (qh_nostatistic(id) || !qhstat doc[id])
00645     return;
00646   qhstat printed[id]= True;
00647   if (qhstat count[id] != -1
00648       && qhstat stats[(unsigned char)(qhstat count[id])].i == 0)
00649     qh_fprintf(fp, 9361, " *0 cnt*");
00650   else if (qhstat type[id] >= ZTYPEreal && qhstat count[id] == -1)
00651     qh_fprintf(fp, 9362, "%7.2g", qhstat stats[id].r);
00652   else if (qhstat type[id] >= ZTYPEreal && qhstat count[id] != -1)
00653     qh_fprintf(fp, 9363, "%7.2g", qhstat stats[id].r/ qhstat stats[(unsigned char)(qhstat count[id])].i);
00654   else if (qhstat type[id] < ZTYPEreal && qhstat count[id] == -1)
00655     qh_fprintf(fp, 9364, "%7d", qhstat stats[id].i);
00656   else if (qhstat type[id] < ZTYPEreal && qhstat count[id] != -1)
00657     qh_fprintf(fp, 9365, "%7.3g", (realT) qhstat stats[id].i / qhstat stats[(unsigned char)(qhstat count[id])].i);
00658   qh_fprintf(fp, 9366, " %s\n", qhstat doc[id]);
00659 } /* printstatlevel */
00660 
00661 
00662 /*-<a                             href="qh-stat.htm#TOC"
00663   >-------------------------------</a><a name="printstats">-</a>
00664 
00665   qh_printstats( fp, index, nextindex )
00666     print statistics for a zdoc group
00667 
00668   returns:
00669     next zdoc if non-null
00670 */
00671 void qh_printstats(FILE *fp, int idx, int *nextindex) {
00672   int j, nexti;
00673 
00674   if (qh_newstats(idx, &nexti)) {
00675     qh_fprintf(fp, 9367, "\n");
00676     for (j=idx; j<nexti; j++)
00677       qh_printstatlevel(fp, qhstat id[j], 0);
00678   }
00679   if (nextindex)
00680     *nextindex= nexti;
00681 } /* printstats */
00682 
00683 #if qh_KEEPstatistics
00684 
00685 /*-<a                             href="qh-stat.htm#TOC"
00686   >-------------------------------</a><a name="stddev">-</a>
00687 
00688   qh_stddev( num, tot, tot2, ave )
00689     compute the standard deviation and average from statistics
00690 
00691     tot2 is the sum of the squares
00692   notes:
00693     computes r.m.s.:
00694       (x-ave)^2
00695       == x^2 - 2x tot/num +   (tot/num)^2
00696       == tot2 - 2 tot tot/num + tot tot/num
00697       == tot2 - tot ave
00698 */
00699 realT qh_stddev(int num, realT tot, realT tot2, realT *ave) {
00700   realT stddev;
00701 
00702   *ave= tot/num;
00703   stddev= sqrt(tot2/num - *ave * *ave);
00704   return stddev;
00705 } /* stddev */
00706 
00707 #endif /* qh_KEEPstatistics */
00708 
00709 #if !qh_KEEPstatistics
00710 void    qh_collectstatistics(void) {}
00711 void    qh_printallstatistics(FILE *fp, char *string) {};
00712 void    qh_printstatistics(FILE *fp, char *string) {}
00713 #endif
00714 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


libqhull
Author(s): Robert Krug
autogenerated on Tue Jun 18 2013 12:38:50