LCOV - code coverage report
Current view: top level - alg/internal_libqhull - stat_r.c (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 322 478 67.4 %
Date: 2024-05-02 00:41:30 Functions: 15 20 75.0 %

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

Generated by: LCOV version 1.14