⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stat.c

📁 这是一个新的用于图像处理的工具箱
💻 C
📖 第 1 页 / 共 2 页
字号:
    if (sizridges) {      zadd_(Znumridges, sizridges);      zmax_(Zmaxridges, sizridges);    }    zadd_(Zmemfacets, sizeof (facetT) + qh normal_size + 2*sizeof (setT)        + SETelemsize * (sizneighbors + sizvertices));    if (facet->ridges) {      zadd_(Zmemridges,	 sizeof (setT) + SETelemsize * sizridges + sizridges *          (sizeof (ridgeT) + sizeof (setT) + SETelemsize * (qh hull_dim-1))/2);    }    if (facet->outsideset)      zadd_(Zmempoints, sizeof (setT) + SETelemsize * qh_setsize (facet->outsideset));    if (facet->coplanarset)      zadd_(Zmempoints, sizeof (setT) + SETelemsize * qh_setsize (facet->coplanarset));    if (facet->seen) /* Delaunay upper envelope */      continue;    facet->seen= True;    FOREACHneighbor_(facet) {      if (neighbor == qh_DUPLICATEridge || neighbor == qh_MERGEridge	  || neighbor->seen || !facet->normal || !neighbor->normal)	continue;      dotproduct= qh_getangle(facet->normal, neighbor->normal);      zinc_(Zangle);      wadd_(Wangle, dotproduct);      wmax_(Wanglemax, dotproduct)      wmin_(Wanglemin, dotproduct)    }    if (facet->normal) {      FOREACHvertex_(facet->vertices) {        zinc_(Zdiststat);        qh_distplane(vertex->point, facet, &dist);        wmax_(Wvertexmax, dist);        wmin_(Wvertexmin, dist);      }    }  }  FORALLvertices {    if (vertex->deleted)      continue;    zadd_(Zmemvertices, sizeof (vertexT));    if (vertex->neighbors) {      sizneighbors= qh_setsize (vertex->neighbors);      zadd_(Znumvneighbors, sizneighbors);      zmax_(Zmaxvneighbors, sizneighbors);      zadd_(Zmemvertices, sizeof (vertexT) + SETelemsize * sizneighbors);    }  }} /* collectstatistics */#endif /* qh_KEEPstatistics *//*--------------------------------------------------freestatistics- free memory used for statistics*/void qh_freestatistics (void) {#if qh_QHpointer  free (qh_qhstat);  qh_qhstat= NULL;#endif} /* freestatistics *//*--------------------------------------------------initstatistics- allocate and initialize statistics  uses malloc instead of memalloc since mem.c not setup yet*/void qh_initstatistics (void) {  int i;  realT realx;  int intx;#if qh_QHpointer  if (!(qh_qhstat= (qhstatT *)malloc (sizeof(qhstatT)))) {    fprintf (qhmem.ferr, "qhull error (qh_initstatistics): insufficient memory\n");    exit (1);  /* can not use qh_errexit() */  }#endif    qhstat next= 0;  qh_allstatA();  qh_allstatB();  qh_allstatC();  qh_allstatD();  qh_allstatE();  qh_allstatF();  qh_allstatG();  qh_allstatH();  qhstat init[zinc].i= 0;  qhstat init[zadd].i= 0;  qhstat init[zmin].i= INT_MAX;  qhstat init[zmax].i= INT_MIN;  qhstat init[wadd].r= 0;  qhstat init[wmin].r= REALmax;  qhstat init[wmax].r= -REALmax;  for (i=0; i<ZEND; i++) {    if (qhstat type[i] > ZTYPEreal) {      realx= qhstat init[(unsigned char)(qhstat type[i])].r;      qhstat stats[i].r= realx;    }else if (qhstat type[i] != zdoc) {      intx= qhstat init[(unsigned char)(qhstat type[i])].i;      qhstat stats[i].i= intx;    }  }} /* initstatistics *//*--------------------------------------------newstats- returns True if statistics for zdocreturns:  next zdoc*/boolT qh_newstats (int index, int *nextindex) {  boolT isnew= False;  int start, i;  if (qhstat type[qhstat id[index]] == zdoc)     start= index+1;  else    start= index;  for (i= start; i < qhstat next && qhstat type[qhstat id[i]] != zdoc; i++) {    if (!qh_nostatistic(qhstat id[i]) && !qhstat printed[qhstat id[i]])	isnew= True;  }  *nextindex= i;  return isnew;} /* newstats *//*--------------------------------------------nostatistic- true if no statistic to print*/boolT qh_nostatistic (int i) {    if ((qhstat type[i] > ZTYPEreal       &&qhstat stats[i].r == qhstat init[(unsigned char)(qhstat type[i])].r)      || (qhstat type[i] < ZTYPEreal	  &&qhstat stats[i].i == qhstat init[(unsigned char)(qhstat type[i])].i))    return True;  return False;} /* nostatistic */#if qh_KEEPstatistics/*--------------------------------------------printallstatistics- print all statistics*/void qh_printallstatistics (FILE *fp, char *string) {  qh_allstatistics();  qh_collectstatistics();  qh_printstatistics (fp, string);  qh_memstatistics (fp);}/*--------------------------------------------printstatistics- print statistics to a file  skips statistics with qhstat printed[] (reset with qh_allstatistics)  see also: qh_printallstatistics*/void qh_printstatistics (FILE *fp, char *string) {  int i, k;  realT ave;    if (qh num_points != qh num_vertices) {    wval_(Wpbalance)= 0;    wval_(Wpbalance2)= 0;  }else    wval_(Wpbalance2)= qh_stddev (zval_(Zpbalance), wval_(Wpbalance),                                  wval_(Wpbalance2), &ave);  wval_(Wnewbalance2)= qh_stddev (zval_(Zprocessed), wval_(Wnewbalance),                                  wval_(Wnewbalance2), &ave);  fprintf (fp, "\n\%s\n\ qhull invoked by: %s | %s\n%s with options:\n%s\n", string, qh rbox_command,      qh qhull_command, qh_version, qh qhull_options);  fprintf (fp, "\nprecision constants:\n\ %6.2g max. coordinate in the (transformed) input ('Qbd:n')\n\ %6.2g max. roundoff error for distance computation ('En')\n\ %6.2g max. roundoff error for angle computations\n\ %6.2g min. distance for outside points ('Wn')\n\ %6.2g min. distance for visible facets ('Vn')\n\ %6.2g max. distance for coplanar facets ('Un')\n\ %6.2g max. facet width for recomputing centrum and area\n\",   qh maxmaxcoord, qh DISTround, qh ANGLEround, qh MINoutside,         qh MINvisible, qh MAXcoplanar, qh WIDEfacet);  if (qh KEEPnearinside)    fprintf(fp, "\ %6.2g max. distance for near-inside points\n", qh NEARinside);  if (qh premerge_cos < REALmax/2) fprintf (fp, "\ %6.2g max. cosine for pre-merge angle\n", qh premerge_cos);  if (qh PREmerge) fprintf (fp, "\ %6.2g radius of pre-merge centrum\n", qh premerge_centrum);  if (qh postmerge_cos < REALmax/2) fprintf (fp, "\ %6.2g max. cosine for post-merge angle\n", qh postmerge_cos);  if (qh POSTmerge) fprintf (fp, "\ %6.2g radius of post-merge centrum\n", qh postmerge_centrum);  fprintf (fp, "\ %6.2g max. distance for merging two simplicial facets\n\ %6.2g max. roundoff error for arithmetic operations\n\ %6.2g min. denominator for divisions\n\  zero diagonal for Gauss: ", qh ONEmerge, REALepsilon, qh MINdenom);  for (k=0; k<qh hull_dim; k++)    fprintf (fp, "%6.2e ", qh NEARzero[k]);  fprintf (fp, "\n\n");  for (i=0 ; i<qhstat next; )     qh_printstats (fp, i, &i);} /* printstatistics */#endif /* qh_KEEPstatistics *//*--------------------------------------------printstatlevel- print level information for a statistic  start is 1st level to print  nop if id >= ZEND, printed, or same as initial value*/void qh_printstatlevel (FILE *fp, int id, int start) {#define NULLfield "       "  if (id >= ZEND || qhstat printed[id])    return;  if (qhstat type[id] == zdoc) {    fprintf (fp, "%s\n", qhstat doc[id]);    return;  }  start= 0; /* not used */  if (qh_nostatistic(id) || !qhstat doc[id])    return;  qhstat printed[id]= True;  if (qhstat count[id] != -1       && qhstat stats[(unsigned char)(qhstat count[id])].i == 0)    fprintf (fp, " *0 cnt*");  else if (qhstat type[id] >= ZTYPEreal && qhstat count[id] == -1)    fprintf (fp, "%7.2g", qhstat stats[id].r);  else if (qhstat type[id] >= ZTYPEreal && qhstat count[id] != -1)    fprintf (fp, "%7.2g", qhstat stats[id].r/ qhstat stats[(unsigned char)(qhstat count[id])].i);  else if (qhstat type[id] < ZTYPEreal && qhstat count[id] == -1)    fprintf (fp, "%7d", qhstat stats[id].i);  else if (qhstat type[id] < ZTYPEreal && qhstat count[id] != -1)    fprintf (fp, "%7.3g", (realT) qhstat stats[id].i / qhstat stats[(unsigned char)(qhstat count[id])].i);  fprintf (fp, " %s\n", qhstat doc[id]);} /* printstatlevel *//*--------------------------------------------------------printstats- print statistics for a zdoc groupreturns:  next zdoc if non-null*/void qh_printstats (FILE *fp, int index, int *nextindex) {  int j, nexti;  if (qh_newstats (index, &nexti)) {    for (j=index; j<nexti; j++)      qh_printstatlevel (fp, qhstat id[j], 0);    fprintf (fp, "\n");  }  if (nextindex)    *nextindex= nexti;} /* printstats */#if qh_KEEPstatistics/*------------------------------------------stddev- compute the standard deviation and average from statistics  tot2 is the sum of the squaresnotes:  computes r.m.s.: (x-ave)^2 == x^2 - 2x tot/num + (tot/num)^2     == tot2 - 2 tot tot/num + tot tot/num == tot2 - tot ave*/realT qh_stddev (int num, realT tot, realT tot2, realT *ave) {  realT stddev;  *ave= tot/num;  stddev= sqrt (tot2/num - *ave * *ave);  return stddev;} /* stddev */#endif /* qh_KEEPstatistics */ #if !qh_KEEPstatisticsvoid    qh_collectstatistics (void) {}void    qh_printallstatistics (FILE *fp, char *string) {};void    qh_printstatistics (FILE *fp, char *string) {}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -