123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- /* stat.h - contains all statistics that are collected for qhull
- see README and stat.c
- copyright (c) 1993, 1997, The Geometry Center
- recompile qhull if you change this file
- Integer statistics are Z* while real statistics are W*.
- qh_KEEPstatistics=0 turns off statistic gathering (except zzdef/zzinc/zzadd)
- define maydebugx to call a routine at every statistic event
- */
- #ifndef qhDEFstat
- #define qhDEFstat 1
- #ifndef qh_KEEPstatistics
- #define qh_KEEPstatistics 1
- #endif
- /*----------------------------------------------------
- -statistics, Zxxx for integers, Wxxx for reals
- can pick up all statistics by:
- grep '[zw].*_[(][ZW]' *.c >z.x
- remove trailers with query-replace-regexp [,)].*
- remove leaders with query-replace-regexp [ ^I]+ (
- */
- #if qh_KEEPstatistics
- enum statistics { /* alphabetical after Z/W */
- Zacoplanar,
- Wacoplanarmax,
- Wacoplanartot,
- Zangle,
- Wangle,
- Wanglemax,
- Wanglemin,
- Zangletests,
- Wareatot,
- Wareamax,
- Wareamin,
- Zavoidold,
- Wavoidoldmax,
- Wavoidoldtot,
- Zback0,
- Zbestcentrum,
- Zbestdist,
- Zcentrumtests,
- Zcheckpart,
- Zcomputefurthest,
- Zconcave,
- Wconcavemax,
- Wconcavetot,
- Zconcaveridges,
- Zconcaveridge,
- Zcoplanar,
- Wcoplanarmax,
- Wcoplanartot,
- Zcoplanarangle,
- Zcoplanarcentrum,
- Zcoplanarhorizon,
- Zcoplanarinside,
- Zcoplanarpart,
- Zcoplanarridges,
- Wcpu,
- Zcyclefacetmax,
- Zcyclefacettot,
- Zcyclehorizon,
- Wcyclemax,
- Wcycletot,
- Zcyclevertex,
- Zdegen,
- Wdegenmax,
- Wdegentot,
- Zdegenvertex,
- Zdelfacetdup,
- Zdelridge,
- Zdelvertextot,
- Zdelvertexmax,
- Zdetsimplex,
- Zdistcheck,
- Zdistconvex,
- Zdistgood,
- Zdistio,
- Zdistplane,
- Zdiststat,
- Zdistvertex,
- Zdistzero,
- Zdoc1,
- Zdoc2,
- Zdoc3,
- Zdoc4,
- Zdoc5,
- Zdoc6,
- Zdoc7,
- Zdoc8,
- Zdoc9,
- Zdoc10,
- Zdropdegen,
- Zdropneighbor,
- Zdupflip,
- Zduplicate,
- Wduplicatemax,
- Wduplicatetot,
- Zdupridge,
- Zdupsame,
- Zfindfail,
- Zflipped,
- Wflippedmax,
- Wflippedtot,
- Zflippedfacets,
- Zgauss0,
- Zgoodfacet,
- Zhashlookup,
- Zhashridge,
- Zhashridgetest,
- Zhashtests,
- Zinsidevisible,
- Zintersect,
- Zintersectfail,
- Zintersectmax,
- Zintersectnum,
- Zintersecttot,
- Zmaxneighbors,
- Wmaxout,
- Wmaxoutside,
- Zmaxridges,
- Zmaxvertex,
- Zmaxvertices,
- Zmaxvneighbors,
- Zmemfacets,
- Zmempoints,
- Zmemridges,
- Zmemvertices,
- Zmergeflipdup,
- Zmergehorizon,
- Zmergeinittot,
- Zmergeinitmax,
- Zmergeinittot2,
- Zmergeintohorizon,
- Zmergenew,
- Zmergesettot,
- Zmergesetmax,
- Zmergesettot2,
- Zmergesimplex,
- Zmergevertex,
- Wmindenom,
- Wminvertex,
- Zminnorm,
- Zmultiridge,
- Znearlysingular,
- Zneighbor,
- Wnewbalance,
- Wnewbalance2,
- Znewfacettot,
- Znewfacetmax,
- Znewvertex,
- Wnewvertex,
- Wnewvertexmax,
- Znoarea,
- Znotgood,
- Znotgoodnew,
- Znotmax,
- Znumfacets,
- Znummergemax,
- Znummergetot,
- Znumneighbors,
- Znumridges,
- Znumvertices,
- Znumvisibility,
- Znumvneighbors,
- Zonehorizon,
- Zpartcoplanar,
- Zpartinside,
- Zpartition,
- Zpartitionall,
- Zpartnear,
- Zpbalance,
- Wpbalance,
- Wpbalance2,
- Zpostfacets,
- Zpremergetot,
- Zprocessed,
- Zremvertex,
- Zremvertexdel,
- Zrenameall,
- Zrenamepinch,
- Zrenameshare,
- Zsamevertices,
- Zsearchpoints,
- Zsetplane,
- Ztestvneighbor,
- Ztotcheck,
- Ztothorizon,
- Ztotmerge,
- Ztotpartcoplanar,
- Ztotpartition,
- Ztotridges,
- Ztotvertices,
- Ztotvisible,
- Wvertexmax,
- Wvertexmin,
- Zvertexridge,
- Zvertexridgetot,
- Zvertexridgemax,
- Zvertices,
- Zvisfacettot,
- Zvisfacetmax,
- Zvisvertextot,
- Zvisvertexmax,
- Zwidefacet,
- Zwidevertices,
- ZEND};
- #else
- enum statistics { /* for zzdef etc. macros */
- Zback0,
- Zbestdist,
- Zcentrumtests,
- Zconcaveridges,
- Zcoplanarhorizon,
- Zcoplanarpart,
- Zcoplanarridges,
- Zcyclefacettot,
- Zcyclehorizon,
- Zdistcheck,
- Zdistconvex,
- Zdistzero,
- Zdoc1,
- Zdoc2,
- Zdoc3,
- Zflippedfacets,
- Zgauss0,
- Zminnorm,
- Zmultiridge,
- Znearlysingular,
- Znumvisibility,
- Zpartcoplanar,
- Zpartition,
- Zpartitionall,
- Zprocessed,
- Zsetplane,
- Ztotmerge,
- ZEND};
- #endif
- /* ------------ -ztypes- ---------------------
- the type of a statistic sets its initial value. The type should
- be the same as the macro for collecting the statistic
- */
- enum ztypes {zdoc,zinc,zadd,zmax,zmin,ZTYPEreal,wadd,wmax,wmin,ZTYPEend};
- /*------------ -macros -------------
- macros:
- zdef_(type, name, doc, -1) define a statistic (assumes 'qhstat next= 0;')
- zdef_(type, name, doc, count) printed as name/count
- zinc_(name) integer statistic is count
- zadd/wadd_(name, value) integer or real statistic is total value
- zmax/wmax_(name, value) integer or real statistic is max value
- zmin/wmin_(name, value) integer or real statistic is min value
- zval/wval_(name) set or return value of statistic
- */
- #define MAYdebugx /* maydebug() is called frequently to trap an error */
- #define zzinc_(id) {MAYdebugx; qhstat stats[id].i++;}
- #define zzadd_(id, val) {MAYdebugx; qhstat stats[id].i += (val);}
- #define zzval_(id) ((qhstat stats[id]).i)
- #define wwval_(id) ((qhstat stats[id]).r)
- #define zzdef_(stype,name,string,cnt) qhstat id[qhstat next++]=name; \
- qhstat doc[name]= string; qhstat count[name]= cnt; qhstat type[name]= stype
- #if qh_KEEPstatistics
- #define zinc_(id) {MAYdebugx; qhstat stats[id].i++;}
- #define zadd_(id, val) {MAYdebugx; qhstat stats[id].i += (val);}
- #define wadd_(id, val) {MAYdebugx; qhstat stats[id].r += (val);}
- #define zmax_(id, val) {MAYdebugx; maximize_(qhstat stats[id].i,(val));}
- #define wmax_(id, val) {MAYdebugx; maximize_(qhstat stats[id].r,(val));}
- #define zmin_(id, val) {MAYdebugx; minimize_(qhstat stats[id].i,(val));}
- #define wmin_(id, val) {MAYdebugx; minimize_(qhstat stats[id].r,(val));}
- #define zval_(id) ((qhstat stats[id]).i)
- #define wval_(id) ((qhstat stats[id]).r)
- #define zdef_(stype,name,string,cnt) qhstat id[qhstat next++]=name; \
- qhstat doc[name]= string; qhstat count[name]= cnt; qhstat type[name]= stype
- #else /* !qh_KEEPstatistics */
- #define zinc_(id) {}
- #define zadd_(id, val) {}
- #define wadd_(id, val) {}
- #define zmax_(id, val) {}
- #define wmax_(id, val) {}
- #define zmin_(id, val) {}
- #define wmin_(id, val) {}
- #define zval_(id) qhstat tempi
- #define wval_(id) qhstat tempr
- #define zdef_(type,name,doc,count)
- #define ZMAXlevel 1
- #endif
-
- /* -typedef and extern- types are defined below */
- typedef struct qhstatT qhstatT; /* global data structure for statistics */
- typedef union intrealT intrealT; /* union of int and realT */
- /* -qhstat-
- access to qh_qhstat is via the "qhstat" macro. There are two choices
- qh_QHpointer = 1 access globals via a pointer
- enables qh_saveqhull() and qh_restoreqhull()
- = 0 qh_qhstat is a static data structure
- only one instance of qhull() can be active at a time
- default value
- qh_QHpointer is defined in qhull.h
- */
- #if qh_QHpointer
- #define qhstat qh_qhstat->
- extern qhstatT *qh_qhstat; /* allocated in stat.c */
- #else
- #define qhstat qh_qhstat.
- extern qhstatT qh_qhstat; /* allocated in stat.c */
- #endif
- /*-------------------------------------------
- -intrealT- union of integer and real, used for statistics
- */
- union intrealT {
- int i;
- realT r;
- };
- /*--------------------------------------------
- -qhstatT- global data structure for statistics
- */
- struct qhstatT {
- intrealT stats[ZEND]; /* integer and real statistics */
- unsigned char id[ZEND]; /* id's in print order */
- char *doc[ZEND]; /* array of documentation strings */
- short int count[ZEND]; /* -1 if none, else index of count to use */
- char type[ZEND]; /* type, see ztypes above */
- char printed[ZEND]; /* true, if statistic has been printed */
- intrealT init[ZTYPEend]; /* initial values by types, set initstatistics */
- int next; /* next index for zdef_ */
- int precision; /* index for precision problems */
- int tempi;
- realT tempr;
- };
- /* ========== -functions- ===========
- see also qhull.h
- -allstatA define statistics in groups of 20
- -qh_allstatistics reset printed flag for all statistics
- -collectstatistics collect statistics for qh facet_list
- -freestatistics free memory used for statistics
- -initstatistics allocate and initialize statistics
- -newstats returns True if statistics for zdoc
- -nostatistic true if no statistic to print
- -printallstatistics print all statistics
- -printstatistics print statistics to a file
- -printstatlevel print level information for a statistic
- -printstats print statistics for a zdoc group
- -stddev compute the standard deviation and average from statistics
- */
-
- void qh_allstatA(void);
- void qh_allstatB(void);
- void qh_allstatC(void);
- void qh_allstatD(void);
- void qh_allstatE(void);
- void qh_allstatF(void);
- void qh_allstatG(void);
- void qh_allstatH(void);
- void qh_allstatistics (void);
- void qh_collectstatistics (void);
- void qh_freestatistics (void);
- void qh_initstatistics (void);
- boolT qh_newstats (int index, int *nextindex);
- boolT qh_nostatistic (int i);
- void qh_printallstatistics (FILE *fp, char *string);
- void qh_printstatistics (FILE *fp, char *string);
- void qh_printstatlevel (FILE *fp, int id, int start);
- void qh_printstats (FILE *fp, int index, int *nextindex);
- realT qh_stddev (int num, realT tot, realT tot2, realT *ave);
- #endif /* qhDEFstat */
|