00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "qhull_a.h"
00013
00014 #ifdef USE_DMALLOC
00015 #include "dmalloc.h"
00016 #endif
00017
00018
00019
00020 #if qh_QHpointer
00021 qhstatT *qh_qhstat=NULL;
00022 #else
00023 qhstatT qh_qhstat;
00024 #endif
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 void qh_allstatA (void) {
00039
00040
00041 zzdef_(zdoc, Zdoc2, "precision statistics", -1);
00042 zdef_(zinc, Znewvertex, NULL, -1);
00043 zdef_(wadd, Wnewvertex, "ave. distance of a new vertex to a facet (not 0s)", Znewvertex);
00044 zzdef_(wmax, Wnewvertexmax, "max. distance of a new vertex to a facet", -1);
00045 zdef_(wmax, Wvertexmax, "max. distance of an output vertex to a facet", -1);
00046 zdef_(wmin, Wvertexmin, "min. distance of an output vertex to a facet", -1);
00047 zdef_(wmin, Wmindenom, "min. denominator in hyperplane computation", -1);
00048
00049 qhstat precision= qhstat next;
00050 zzdef_(zdoc, Zdoc3, "precision problems", -1);
00051 zzdef_(zinc, Zcoplanarridges, "coplanar half ridges in output", -1);
00052 zzdef_(zinc, Zconcaveridges, "concave half ridges in output", -1);
00053 zzdef_(zinc, Zflippedfacets, "flipped facets", -1);
00054 zzdef_(zinc, Zcoplanarhorizon, "coplanar horizon facets for new vertices", -1);
00055 zzdef_(zinc, Zcoplanarpart, "coplanar points during partitioning", -1);
00056 zzdef_(zinc, Zminnorm, "degenerate hyperplanes recomputed with gaussian elimination", -1);
00057 zzdef_(zinc, Znearlysingular, "nearly singular or axis-parallel hyperplanes", -1);
00058 zzdef_(zinc, Zback0, "zero divisors during back substitute", -1);
00059 zzdef_(zinc, Zgauss0, "zero divisors during gaussian elimination", -1);
00060 zzdef_(zinc, Zmultiridge, "ridges with multiple neighbors", -1);
00061 }
00062 void qh_allstatB (void) {
00063 zzdef_(zdoc, Zdoc1, "summary information", -1);
00064 zdef_(zinc, Zvertices, "number of vertices in output", -1);
00065 zdef_(zinc, Znumfacets, "number of facets in output", -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) for all ridges", Zangle);
00084 zdef_(wmax, Wanglemax, " maximum angle (cosine) of a ridge", -1);
00085 zdef_(wmin, Wanglemin, " minimum angle (cosine) of 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_(zadd, Zdelvertextot, " ave. vertices deleted per iteration", Zprocessed);
00103 zdef_(zmax, Zdelvertexmax, " maximum vertices deleted", -1);
00104 zdef_(zinc, Ztothorizon, "ave. horizon facets per iteration", Zprocessed);
00105 zdef_(zadd, Znewfacettot, "ave. new or merged facets per iteration", Zprocessed);
00106 zdef_(zmax, Znewfacetmax, " maximum (includes initial simplex)", -1);
00107 zdef_(wadd, Wnewbalance, "average new facet balance", Zprocessed);
00108 zdef_(wadd, Wnewbalance2, " standard deviation", -1);
00109 zdef_(wadd, Wpbalance, "average partition balance", Zpbalance);
00110 zdef_(wadd, Wpbalance2, " standard deviation", -1);
00111 zdef_(zinc, Zpbalance, " number of trials", -1);
00112 zdef_(zinc, Zsearchpoints, "searches of all points for initial simplex", -1);
00113 zdef_(zinc, Zdetsimplex, "determinants computed (area & initial hull)", -1);
00114 zdef_(zinc, Znoarea, "determinants not computed because vertex too low", -1);
00115 zdef_(zinc, Znotmax, "points ignored (not above max_outside)", -1);
00116 zdef_(zinc, Znotgood, "points ignored (not above a good facet)", -1);
00117 zdef_(zinc, Znotgoodnew, "points ignored (didn't create a good new facet)", -1);
00118 zdef_(zinc, Zgoodfacet, "good facets found", -1);
00119 zzdef_(zinc, Znumvisibility, "distance tests for facet visibility", -1);
00120 zdef_(zinc, Zdistvertex, "distance tests to report minimum vertex", -1);
00121 zdef_(zinc, Ztotcheck, "points checked for facets' outer planes", -1);
00122 zdef_(zinc, Zcheckpart, " ave. distance tests per check", Ztotcheck);
00123 }
00124 void qh_allstatD(void) {
00125 zdef_(zdoc, Zdoc4, "partitioning statistics", -1);
00126 zdef_(zinc, Zpartinside, "inside points", -1);
00127 zdef_(zinc, Zpartnear, " inside points kept with a facet", -1);
00128 zdef_(zinc, Zcoplanarinside, " inside points that were coplanar with a facet", -1);
00129 zdef_(wadd, Wmaxout, "difference in max_outside at final check", -1);
00130
00131 zzdef_(zinc, Zpartitionall, "distance tests for initial partition", -1);
00132 zdef_(zinc, Ztotpartition, "partitions of a point", -1);
00133 zzdef_(zinc, Zpartition, "distance tests for partitioning", -1);
00134 zzdef_(zinc, Zdistcheck, "distance tests for checking flipped facets", -1);
00135 zzdef_(zinc, Zdistconvex, "distance tests for checking convexity", -1);
00136 zdef_(zinc, Zdistgood, "distance tests for checking good point", -1);
00137 zdef_(zinc, Zdistio, "distance tests for output", -1);
00138 zdef_(zinc, Zdiststat, "distance tests for statistics", -1);
00139 zdef_(zinc, Zdistplane, "total number of distance tests", -1);
00140 zdef_(zinc, Ztotpartcoplanar, "partitions of coplanar points or deleted vertices", -1);
00141 zzdef_(zinc, Zpartcoplanar, " distance tests for these partitions", -1);
00142 zdef_(zinc, Zcomputefurthest, "distance tests for computing furthest", -1);
00143 }
00144 void qh_allstatE(void) {
00145 zdef_(zdoc, Zdoc5, "statistics for matching ridges", -1);
00146 zdef_(zinc, Zhashlookup, "total lookups for matching ridges of new facets", -1);
00147 zdef_(zinc, Zhashtests, "average number of tests to match a ridge", Zhashlookup);
00148 zdef_(zinc, Zhashridge, "total lookups of subridges (duplicates and boundary)", -1);
00149 zdef_(zinc, Zhashridgetest, "average number of tests per subridge", Zhashridge);
00150 zdef_(zinc, Zdupsame, "duplicated ridges in same merge cycle", -1);
00151 zdef_(zinc, Zdupflip, "duplicated ridges with flipped facets", -1);
00152
00153 zdef_(zdoc, Zdoc6, "statistics for determining merges", -1);
00154 zdef_(zinc, Zangletests, "angles computed for ridge convexity", -1);
00155 zdef_(zinc, Zbestcentrum, "best merges used centrum instead of vertices",-1);
00156 zzdef_(zinc, Zbestdist, "distance tests for best merge", -1);
00157 zzdef_(zinc, Zcentrumtests, "distance tests for centrum convexity", -1);
00158 zzdef_(zinc, Zdistzero, "distance tests for checking simplicial convexity", -1);
00159 zdef_(zinc, Zcoplanarangle, "coplanar angles in getmergeset", -1);
00160 zdef_(zinc, Zcoplanarcentrum, "coplanar centrums in getmergeset", -1);
00161 zdef_(zinc, Zconcaveridge, "concave ridges in getmergeset", -1);
00162 }
00163 void qh_allstatF(void) {
00164 zdef_(zdoc, Zdoc7, "statistics for merging", -1);
00165 zdef_(zinc, Zpremergetot, "merge iterations", -1);
00166 zdef_(zadd, Zmergeinittot, "ave. initial non-convex ridges per iteration", Zpremergetot);
00167 zdef_(zadd, Zmergeinitmax, " maximum", -1);
00168 zdef_(zadd, Zmergesettot, " ave. additional non-convex ridges per iteration", Zpremergetot);
00169 zdef_(zadd, Zmergesetmax, " maximum additional in one pass", -1);
00170 zdef_(zadd, Zmergeinittot2, "initial non-convex ridges for post merging", -1);
00171 zdef_(zadd, Zmergesettot2, " additional non-convex ridges", -1);
00172 zdef_(wmax, Wmaxoutside, "max distance of vertex or coplanar point above facet (w/roundoff)", -1);
00173 zdef_(wmin, Wminvertex, "max distance of merged vertex below facet (or roundoff)", -1);
00174 zdef_(zinc, Zwidefacet, "centrums frozen due to a wide merge", -1);
00175 zdef_(zinc, Zwidevertices, "centrums frozen due to extra vertices", -1);
00176 zzdef_(zinc, Ztotmerge, "total number of facets or cycles of facets merged", -1);
00177 zdef_(zinc, Zmergesimplex, "merged a simplex", -1);
00178 zdef_(zinc, Zonehorizon, "simplices merged into coplanar horizon", -1);
00179 zzdef_(zinc, Zcyclehorizon, "cycles of facets merged into coplanar horizon", -1);
00180 zzdef_(zadd, Zcyclefacettot, " ave. facets per cycle", Zcyclehorizon);
00181 zdef_(zmax, Zcyclefacetmax, " max. facets", -1);
00182 zdef_(zinc, Zmergeintohorizon, "new facets merged into horizon", -1);
00183 zdef_(zinc, Zmergenew, "new facets merged", -1);
00184 zdef_(zinc, Zmergehorizon, "horizon facets merged into new facets", -1);
00185 zdef_(zinc, Zmergevertex, "vertices deleted by merging", -1);
00186 zdef_(zinc, Zcyclevertex, "vertices deleted by merging into coplanar horizon", -1);
00187 zdef_(zinc, Zdegenvertex, "vertices deleted by degenerate facet", -1);
00188 zdef_(zinc, Zmergeflipdup, "merges due to flipped facets in duplicated ridge", -1);
00189 zdef_(zinc, Zneighbor, "merges due to redundant neighbors", -1);
00190 zdef_(zadd, Ztestvneighbor, "non-convex vertex neighbors", -1);
00191 }
00192 void qh_allstatG(void) {
00193 zdef_(zinc, Zacoplanar, "merges due to angle coplanar facets", -1);
00194 zdef_(wadd, Wacoplanartot, " average merge distance", Zacoplanar);
00195 zdef_(wmax, Wacoplanarmax, " maximum merge distance", -1);
00196 zdef_(zinc, Zcoplanar, "merges due to coplanar facets", -1);
00197 zdef_(wadd, Wcoplanartot, " average merge distance", Zcoplanar);
00198 zdef_(wmax, Wcoplanarmax, " maximum merge distance", -1);
00199 zdef_(zinc, Zconcave, "merges due to concave facets", -1);
00200 zdef_(wadd, Wconcavetot, " average merge distance", Zconcave);
00201 zdef_(wmax, Wconcavemax, " maximum merge distance", -1);
00202 zdef_(zinc, Zavoidold, "coplanar/concave merges due to avoiding old merge", -1);
00203 zdef_(wadd, Wavoidoldtot, " average merge distance", Zavoidold);
00204 zdef_(wmax, Wavoidoldmax, " maximum merge distance", -1);
00205 zdef_(zinc, Zdegen, "merges due to degenerate facets", -1);
00206 zdef_(wadd, Wdegentot, " average merge distance", Zdegen);
00207 zdef_(wmax, Wdegenmax, " maximum merge distance", -1);
00208 zdef_(zinc, Zflipped, "merges due to removing flipped facets", -1);
00209 zdef_(wadd, Wflippedtot, " average merge distance", Zflipped);
00210 zdef_(wmax, Wflippedmax, " maximum merge distance", -1);
00211 zdef_(zinc, Zduplicate, "merges due to duplicated ridges", -1);
00212 zdef_(wadd, Wduplicatetot, " average merge distance", Zduplicate);
00213 zdef_(wmax, Wduplicatemax, " maximum merge distance", -1);
00214
00215 }
00216 void qh_allstatH(void) {
00217 zdef_(zdoc, Zdoc8, "renamed vertex statistics", -1);
00218 zdef_(zinc, Zrenameshare, "renamed vertices shared by two facets", -1);
00219 zdef_(zinc, Zrenamepinch, "renamed vertices in a pinched facet", -1);
00220 zdef_(zinc, Zrenameall, "renamed vertices shared by multiple facets", -1);
00221 zdef_(zinc, Zfindfail, "rename failures due to duplicated ridges", -1);
00222 zdef_(zinc, Zdupridge, " duplicate ridges detected", -1);
00223 zdef_(zinc, Zdelridge, "deleted ridges due to renamed vertices", -1);
00224 zdef_(zinc, Zdropneighbor, "dropped neighbors due to renamed vertices", -1);
00225 zdef_(zinc, Zdropdegen, "degenerate facets due to dropped neighbors", -1);
00226 zdef_(zinc, Zdelfacetdup, " facets deleted because of no neighbors", -1);
00227 zdef_(zinc, Zremvertex, "vertices removed from facets due to no ridges", -1);
00228 zdef_(zinc, Zremvertexdel, " deleted", -1);
00229 zdef_(zinc, Zintersectnum, "vertex intersections for locating redundant vertices", -1);
00230 zdef_(zinc, Zintersectfail, "intersections failed to find a redundant vertex", -1);
00231 zdef_(zinc, Zintersect, "intersections found redundant vertices", -1);
00232 zdef_(zadd, Zintersecttot, " ave. number found per vertex", Zintersect);
00233 zdef_(zmax, Zintersectmax, " max. found for a vertex", -1);
00234 zdef_(zinc, Zvertexridge, NULL, -1);
00235 zdef_(zadd, Zvertexridgetot, " ave. number of ridges per tested vertex", Zvertexridge);
00236 zdef_(zmax, Zvertexridgemax, " max. number of ridges per tested vertex", -1);
00237
00238 zdef_(zdoc, Zdoc10, "memory usage statistics (in bytes)", -1);
00239 zdef_(zadd, Zmemfacets, "for facets and their normals, neighbor and vertex sets", -1);
00240 zdef_(zadd, Zmemvertices, "for vertices and their neighbor sets", -1);
00241 zdef_(zadd, Zmempoints, "for input points and outside and coplanar sets",-1);
00242 zdef_(zadd, Zmemridges, "for ridges and their vertex sets", -1);
00243 }
00244
00245 void qh_allstatI(void) {
00246 qhstat vridges= qhstat next;
00247 zzdef_(zdoc, Zdoc11, "Voronoi ridge statistics", -1);
00248 zzdef_(zinc, Zridge, "non-simplicial Voronoi vertices for all ridges", -1);
00249 zzdef_(wadd, Wridge, " ave. distance to ridge", Zridge);
00250 zzdef_(wmax, Wridgemax, " max. distance to ridge", -1);
00251 zzdef_(zinc, Zridgemid, "bounded ridges", -1);
00252 zzdef_(wadd, Wridgemid, " ave. distance of midpoint to ridge", Zridgemid);
00253 zzdef_(wmax, Wridgemidmax, " max. distance of midpoint to ridge", -1);
00254 zzdef_(zinc, Zridgeok, "bounded ridges with ok normal", -1);
00255 zzdef_(wadd, Wridgeok, " ave. angle to ridge", Zridgeok);
00256 zzdef_(wmax, Wridgeokmax, " max. angle to ridge", -1);
00257 zzdef_(zinc, Zridge0, "bounded ridges with near-zero normal", -1);
00258 zzdef_(wadd, Wridge0, " ave. angle to ridge", Zridge0);
00259 zzdef_(wmax, Wridge0max, " max. angle to ridge", -1);
00260 }
00261
00262
00263
00264
00265
00266
00267
00268 void qh_allstatistics (void) {
00269 int i;
00270
00271 for (i=ZEND; i--; )
00272 qhstat printed[i]= False;
00273 }
00274
00275 #if qh_KEEPstatistics
00276
00277
00278
00279
00280
00281
00282
00283 void qh_collectstatistics (void) {
00284 facetT *facet, *neighbor, **neighborp;
00285 vertexT *vertex, **vertexp;
00286 realT dotproduct, dist;
00287 int sizneighbors, sizridges, sizvertices, i;
00288
00289 qh old_randomdist= qh RANDOMdist;
00290 qh RANDOMdist= False;
00291 zval_(Zmempoints)= qh num_points * qh normal_size +
00292 sizeof (qhT) + sizeof (qhstatT);
00293 zval_(Zmemfacets)= 0;
00294 zval_(Zmemridges)= 0;
00295 zval_(Zmemvertices)= 0;
00296 zval_(Zangle)= 0;
00297 wval_(Wangle)= 0.0;
00298 zval_(Znumridges)= 0;
00299 zval_(Znumfacets)= 0;
00300 zval_(Znumneighbors)= 0;
00301 zval_(Znumvertices)= 0;
00302 zval_(Znumvneighbors)= 0;
00303 zval_(Znummergetot)= 0;
00304 zval_(Znummergemax)= 0;
00305 zval_(Zvertices)= qh num_vertices - qh_setsize (qh del_vertices);
00306 if (qh MERGING || qh APPROXhull || qh JOGGLEmax < REALmax/2)
00307 wmax_(Wmaxoutside, qh max_outside);
00308 if (qh MERGING)
00309 wmin_(Wminvertex, qh min_vertex);
00310 FORALLfacets
00311 facet->seen= False;
00312 if (qh DELAUNAY) {
00313 FORALLfacets {
00314 if (facet->upperdelaunay != qh UPPERdelaunay)
00315 facet->seen= True;
00316 }
00317 }
00318 FORALLfacets {
00319 if (facet->visible && qh NEWfacets)
00320 continue;
00321 sizvertices= qh_setsize (facet->vertices);
00322 sizneighbors= qh_setsize (facet->neighbors);
00323 sizridges= qh_setsize (facet->ridges);
00324 zinc_(Znumfacets);
00325 zadd_(Znumvertices, sizvertices);
00326 zmax_(Zmaxvertices, sizvertices);
00327 zadd_(Znumneighbors, sizneighbors);
00328 zmax_(Zmaxneighbors, sizneighbors);
00329 zadd_(Znummergetot, facet->nummerge);
00330 i= facet->nummerge;
00331 zmax_(Znummergemax, i);
00332 if (sizridges) {
00333 zadd_(Znumridges, sizridges);
00334 zmax_(Zmaxridges, sizridges);
00335 }
00336 zadd_(Zmemfacets, sizeof (facetT) + qh normal_size + 2*sizeof (setT)
00337 + SETelemsize * (sizneighbors + sizvertices));
00338 if (facet->ridges) {
00339 zadd_(Zmemridges,
00340 sizeof (setT) + SETelemsize * sizridges + sizridges *
00341 (sizeof (ridgeT) + sizeof (setT) + SETelemsize * (qh hull_dim-1))/2);
00342 }
00343 if (facet->outsideset)
00344 zadd_(Zmempoints, sizeof (setT) + SETelemsize * qh_setsize (facet->outsideset));
00345 if (facet->coplanarset)
00346 zadd_(Zmempoints, sizeof (setT) + SETelemsize * qh_setsize (facet->coplanarset));
00347 if (facet->seen)
00348 continue;
00349 facet->seen= True;
00350 FOREACHneighbor_(facet) {
00351 if (neighbor == qh_DUPLICATEridge || neighbor == qh_MERGEridge
00352 || neighbor->seen || !facet->normal || !neighbor->normal)
00353 continue;
00354 dotproduct= qh_getangle(facet->normal, neighbor->normal);
00355 zinc_(Zangle);
00356 wadd_(Wangle, dotproduct);
00357 wmax_(Wanglemax, dotproduct)
00358 wmin_(Wanglemin, dotproduct)
00359 }
00360 if (facet->normal) {
00361 FOREACHvertex_(facet->vertices) {
00362 zinc_(Zdiststat);
00363 qh_distplane(vertex->point, facet, &dist);
00364 wmax_(Wvertexmax, dist);
00365 wmin_(Wvertexmin, dist);
00366 }
00367 }
00368 }
00369 FORALLvertices {
00370 if (vertex->deleted)
00371 continue;
00372 zadd_(Zmemvertices, sizeof (vertexT));
00373 if (vertex->neighbors) {
00374 sizneighbors= qh_setsize (vertex->neighbors);
00375 zadd_(Znumvneighbors, sizneighbors);
00376 zmax_(Zmaxvneighbors, sizneighbors);
00377 zadd_(Zmemvertices, sizeof (vertexT) + SETelemsize * sizneighbors);
00378 }
00379 }
00380 qh RANDOMdist= qh old_randomdist;
00381 }
00382 #endif
00383
00384
00385
00386
00387
00388
00389
00390 void qh_freestatistics (void) {
00391
00392 #if qh_QHpointer
00393 free (qh_qhstat);
00394 qh_qhstat= NULL;
00395 #endif
00396 }
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407 void qh_initstatistics (void) {
00408 int i;
00409 realT realx;
00410 int intx;
00411
00412 #if qh_QHpointer
00413 if (!(qh_qhstat= (qhstatT *)malloc (sizeof(qhstatT)))) {
00414 fprintf (qhmem.ferr, "qhull error (qh_initstatistics): insufficient memory\n");
00415 exit (1);
00416 }
00417 #endif
00418
00419 qhstat next= 0;
00420 qh_allstatA();
00421 qh_allstatB();
00422 qh_allstatC();
00423 qh_allstatD();
00424 qh_allstatE();
00425 qh_allstatF();
00426 qh_allstatG();
00427 qh_allstatH();
00428 qh_allstatI();
00429
00430 qhstat init[zinc].i= 0;
00431 qhstat init[zadd].i= 0;
00432 qhstat init[zmin].i= INT_MAX;
00433 qhstat init[zmax].i= INT_MIN;
00434 qhstat init[wadd].r= 0;
00435 qhstat init[wmin].r= REALmax;
00436 qhstat init[wmax].r= -REALmax;
00437 for (i=0; i < ZEND; i++) {
00438 if (qhstat type[i] > ZTYPEreal) {
00439 realx= qhstat init[(unsigned char)(qhstat type[i])].r;
00440 qhstat stats[i].r= realx;
00441 }else if (qhstat type[i] != zdoc) {
00442 intx= qhstat init[(unsigned char)(qhstat type[i])].i;
00443 qhstat stats[i].i= intx;
00444 }
00445 }
00446 }
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457 boolT qh_newstats (int index, int *nextindex) {
00458 boolT isnew= False;
00459 int start, i;
00460
00461 if (qhstat type[qhstat id[index]] == zdoc)
00462 start= index+1;
00463 else
00464 start= index;
00465 for (i= start; i < qhstat next && qhstat type[qhstat id[i]] != zdoc; i++) {
00466 if (!qh_nostatistic(qhstat id[i]) && !qhstat printed[qhstat id[i]])
00467 isnew= True;
00468 }
00469 *nextindex= i;
00470 return isnew;
00471 }
00472
00473
00474
00475
00476
00477
00478
00479 boolT qh_nostatistic (int i) {
00480
00481 if ((qhstat type[i] > ZTYPEreal
00482 &&qhstat stats[i].r == qhstat init[(unsigned char)(qhstat type[i])].r)
00483 || (qhstat type[i] < ZTYPEreal
00484 &&qhstat stats[i].i == qhstat init[(unsigned char)(qhstat type[i])].i))
00485 return True;
00486 return False;
00487 }
00488
00489 #if qh_KEEPstatistics
00490
00491
00492
00493
00494
00495
00496 void qh_printallstatistics (FILE *fp, char *string) {
00497
00498 qh_allstatistics();
00499 qh_collectstatistics();
00500 qh_printstatistics (fp, string);
00501 qh_memstatistics (fp);
00502 }
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515 void qh_printstatistics (FILE *fp, char *string) {
00516 int i, k;
00517 realT ave;
00518
00519 if (qh num_points != qh num_vertices) {
00520 wval_(Wpbalance)= 0;
00521 wval_(Wpbalance2)= 0;
00522 }else
00523 wval_(Wpbalance2)= qh_stddev (zval_(Zpbalance), wval_(Wpbalance),
00524 wval_(Wpbalance2), &ave);
00525 wval_(Wnewbalance2)= qh_stddev (zval_(Zprocessed), wval_(Wnewbalance),
00526 wval_(Wnewbalance2), &ave);
00527 fprintf (fp, "\n\
00528 %s\n\
00529 qhull invoked by: %s | %s\n%s with options:\n%s\n", string, qh rbox_command,
00530 qh qhull_command, qh_version, qh qhull_options);
00531 fprintf (fp, "\nprecision constants:\n\
00532 %6.2g max. abs. coordinate in the (transformed) input ('Qbd:n')\n\
00533 %6.2g max. roundoff error for distance computation ('En')\n\
00534 %6.2g max. roundoff error for angle computations\n\
00535 %6.2g min. distance for outside points ('Wn')\n\
00536 %6.2g min. distance for visible facets ('Vn')\n\
00537 %6.2g max. distance for coplanar facets ('Un')\n\
00538 %6.2g max. facet width for recomputing centrum and area\n\
00539 ",
00540 qh MAXabs_coord, qh DISTround, qh ANGLEround, qh MINoutside,
00541 qh MINvisible, qh MAXcoplanar, qh WIDEfacet);
00542 if (qh KEEPnearinside)
00543 fprintf(fp, "\
00544 %6.2g max. distance for near-inside points\n", qh NEARinside);
00545 if (qh premerge_cos < REALmax/2) fprintf (fp, "\
00546 %6.2g max. cosine for pre-merge angle\n", qh premerge_cos);
00547 if (qh PREmerge) fprintf (fp, "\
00548 %6.2g radius of pre-merge centrum\n", qh premerge_centrum);
00549 if (qh postmerge_cos < REALmax/2) fprintf (fp, "\
00550 %6.2g max. cosine for post-merge angle\n", qh postmerge_cos);
00551 if (qh POSTmerge) fprintf (fp, "\
00552 %6.2g radius of post-merge centrum\n", qh postmerge_centrum);
00553 fprintf (fp, "\
00554 %6.2g max. distance for merging two simplicial facets\n\
00555 %6.2g max. roundoff error for arithmetic operations\n\
00556 %6.2g min. denominator for divisions\n\
00557 zero diagonal for Gauss: ", qh ONEmerge, REALepsilon, qh MINdenom);
00558 for (k=0; k < qh hull_dim; k++)
00559 fprintf (fp, "%6.2e ", qh NEARzero[k]);
00560 fprintf (fp, "\n\n");
00561 for (i=0 ; i < qhstat next; )
00562 qh_printstats (fp, i, &i);
00563 }
00564 #endif
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575 void qh_printstatlevel (FILE *fp, int id, int start) {
00576 #define NULLfield " "
00577
00578 if (id >= ZEND || qhstat printed[id])
00579 return;
00580 if (qhstat type[id] == zdoc) {
00581 fprintf (fp, "%s\n", qhstat doc[id]);
00582 return;
00583 }
00584 start= 0;
00585 if (qh_nostatistic(id) || !qhstat doc[id])
00586 return;
00587 qhstat printed[id]= True;
00588 if (qhstat count[id] != -1
00589 && qhstat stats[(unsigned char)(qhstat count[id])].i == 0)
00590 fprintf (fp, " *0 cnt*");
00591 else if (qhstat type[id] >= ZTYPEreal && qhstat count[id] == -1)
00592 fprintf (fp, "%7.2g", qhstat stats[id].r);
00593 else if (qhstat type[id] >= ZTYPEreal && qhstat count[id] != -1)
00594 fprintf (fp, "%7.2g", qhstat stats[id].r/ qhstat stats[(unsigned char)(qhstat count[id])].i);
00595 else if (qhstat type[id] < ZTYPEreal && qhstat count[id] == -1)
00596 fprintf (fp, "%7d", qhstat stats[id].i);
00597 else if (qhstat type[id] < ZTYPEreal && qhstat count[id] != -1)
00598 fprintf (fp, "%7.3g", (realT) qhstat stats[id].i / qhstat stats[(unsigned char)(qhstat count[id])].i);
00599 fprintf (fp, " %s\n", qhstat doc[id]);
00600 }
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612 void qh_printstats (FILE *fp, int index, int *nextindex) {
00613 int j, nexti;
00614
00615 if (qh_newstats (index, &nexti)) {
00616 fprintf (fp, "\n");
00617 for (j=index; j<nexti; j++)
00618 qh_printstatlevel (fp, qhstat id[j], 0);
00619 }
00620 if (nextindex)
00621 *nextindex= nexti;
00622 }
00623
00624 #if qh_KEEPstatistics
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640 realT qh_stddev (int num, realT tot, realT tot2, realT *ave) {
00641 realT stddev;
00642
00643 *ave= tot/num;
00644 stddev= sqrt (tot2/num - *ave * *ave);
00645 return stddev;
00646 }
00647
00648 #endif
00649
00650 #if !qh_KEEPstatistics
00651 void qh_collectstatistics (void) {}
00652 void qh_printallstatistics (FILE *fp, char *string) {};
00653 void qh_printstatistics (FILE *fp, char *string) {}
00654 #endif
00655