home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activetcltk / ActiveTcl8.3.4.1-8.win32-ix86.exe / ActiveTcl8.3.4.1-win32-ix86 / include / util / hist.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-22  |  3.9 KB  |  98 lines

  1. /************************************************************************/
  2. /*    file: hist.h                            */
  3. /*    Desc: The structure definition for the histogram structure    */
  4. /*    Date: Nov 27, 1990                        */
  5. /*    History:                                                          */
  6. /*        Sept 7, 1994  Corrected a bug in 'body_insert_hist()' that    */
  7. /*                      made the statements into a block.               */
  8. /*                                    */
  9. /************************************************************************/
  10. #define HIST_H_VERSION "V1.0"
  11.  
  12. #define PEAK_WIDTH 3
  13. #define PEAK 0
  14. #define TROUGH 1
  15.  
  16. typedef struct hist{
  17.        int count;
  18.        double from, to;
  19.      } HIST;
  20.  
  21. #define head_insert_hist(_hist,_num_bins) { \
  22.  register int _index; \
  23.  register int _out_of_range=0; \
  24.  register double _dist; \
  25.  register double _from; \
  26.    _from = _hist[0]->from; \
  27.    _dist = _hist[_num_bins-1]->to - _hist[0]->from;
  28.  
  29. #define body_insert_hist(_hist,_num_bins,_value) { \
  30.    _index = (int)((double)_num_bins * ((double)_value - (double)_from) / (double)_dist); \
  31.    if ((_index>=0) && (_index<_num_bins)){ \
  32.        _hist[_index]->count++; \
  33.    } \
  34.    else{ \
  35.         _out_of_range++; \
  36.    } \
  37.  
  38. #define end_insert_hist(_hist,_num_bins) \
  39.    if (_out_of_range > 0)   \
  40.        printf("Hist Library: %d samples out of range (%4.2f,%4.2f)\n", \
  41.                   _out_of_range,_from,_hist[_num_bins-1]->to); \
  42. }
  43.  
  44. #if defined(__STDC__) || defined(__GNUC__) || defined(sgi)
  45. #define PROTO(ARGS)    ARGS
  46. #else
  47. #define PROTO(ARGS)    ()
  48. #endif
  49.  
  50. /* hist.c */  void init_hist PROTO((HIST ***hist, int num_bins, double from, double to)) ;
  51. /* hist.c */  void free_hist PROTO((HIST ***hist, int num_bins)) ;
  52. /* hist.c */  void diff_hist PROTO((HIST **h1, HIST **h2, HIST **hd, int num_bins)) ;
  53. /* hist.c */  void subtract_hist PROTO((HIST **h1, HIST **h2, HIST **hs, int num_bins)) ;
  54. /* hist.c */  double percentile_hist PROTO((HIST **hist, int num_bins, double percentile)) ;
  55. /* hist.c */  double percentage_left_hist PROTO((HIST **hist, int num_bins, double value)) ;
  56. /* hist.c */  double do_least_squares PROTO((HIST **noise, HIST **normal, int num_bins)) ;
  57. /* hist.c */  void hist_copy PROTO((HIST **from, HIST **to, int num_bins, int start, int end)) ;
  58. /* hist.c */  void erase_hist PROTO((HIST **hist, int num_bins)) ;
  59. /* hist.c */  void dump_hist PROTO((HIST **hist, int num_bins, FILE *fp)) ;
  60. /* hist.c */  void dump_esps_hist PROTO((HIST **hist, int num_bins, char *fname)) ;
  61. /* hist.c */  void read_esps_hist PROTO((HIST ***hist, int *num_bins, char *fname)) ;
  62. /* hist.c */  void dump_gnuplot_hist PROTO((HIST **hist, int num_bins, char *fname)) ;
  63. /* hist.c */  void dump_gnuplot_2hist PROTO((HIST **hist1, HIST **hist2, int num_bins, char *fname)) ;
  64. /* hist.c */  void half_cosine_hist PROTO((HIST **hist, int num_bins, int begin_bin, int end_bin, int height)) ;
  65. /* hist.c */  void full_cosine_hist PROTO((HIST **hist, int num_bins, int begin_bin, int end_bin, int height)) ;
  66. /* hist.c */  int hist_area PROTO((HIST **hist, int num_bins)) ;
  67. /* hist.c */  void hist_character PROTO((HIST **hist, int num_bins, double *mean, double *vari, int *area)) ;
  68. /* hist.c */  int max_hist PROTO((HIST **hist, int num_bins)) ;
  69. /* hist.c */  int average_hieght_hist PROTO((HIST **hist, int num_bins, int center, int window)) ;
  70. /* hist.c */  void smooth_hist PROTO((HIST **from, HIST **to, int num_bins, int window)) ;
  71. /* hist.c */  int comp PROTO((const void *a, const void *b)) ;
  72. /* hist.c */  int locate_extremum PROTO((HIST **h, int from, int to, int type)) ;
  73. /* hist.c */  void build_normal_hist PROTO((HIST **hist, int num_bins, double mean, double variance, double total_area)) ;
  74. /* hist.c */  int hist_slope PROTO((HIST **hist, int num_bins, int center, int factor)) ;
  75. /* hist.c */  void do_hist PROTO((HIST **hist, int num_bins, double *arr, int arr_cnt)) ;
  76. /* hist.c */  void median_filter PROTO((HIST **h, HIST **out, int num_bins, int size)) ;
  77. /* hist.c */  double db_RMS_hist PROTO((HIST **hist, int num_bins));
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.