BRL-CAD

General purpose histogram handling routines. More...

Collaboration diagram for Histogram Handling:

Files

file  hist.h
 

Data Structures

struct  bu_hist
 

Macros

#define BU_HIST_NULL   ((struct bu_hist *)0)
 
#define BU_CK_HIST(_p)   BU_CKMAG(_p, BU_HIST_MAGIC, "struct bu_hist")
 
#define BU_HIST_INIT(_hp)
 
#define BU_HIST_INIT_ZERO   {BU_HIST_MAGIC, 0.0, 0.0, 0.0, 0, 0, NULL}
 
#define BU_HIST_IS_INITIALIZED(_hp)   (((struct bu_hist *)(_hp) != BU_HIST_NULL) && LIKELY((_hp)->magic == BU_HIST_MAGIC))
 
#define BU_HIST_TALLY(_hp, _val)
 
#define BU_HIST_TALLY_MULTIPLE(_hp, _val, _count)
 

Typedefs

typedef struct bu_hist bu_hist_t
 

Functions

void bu_hist_free (struct bu_hist *histp)
 
void bu_hist_init (struct bu_hist *histp, fastf_t min, fastf_t max, size_t nbins)
 
void bu_hist_range (struct bu_hist *hp, fastf_t low, fastf_t high)
 
void bu_hist_pr (const struct bu_hist *histp, const char *title)
 

Detailed Description

General purpose histogram handling routines.

The subroutine bu_hist_range() is used to record items that may extend across multiple "bin"s.

Macro Definition Documentation

◆ BU_HIST_NULL

#define BU_HIST_NULL   ((struct bu_hist *)0)

Definition at line 59 of file hist.h.

◆ BU_CK_HIST

#define BU_CK_HIST (   _p)    BU_CKMAG(_p, BU_HIST_MAGIC, "struct bu_hist")

assert the integrity of a bu_hist struct.

Definition at line 64 of file hist.h.

◆ BU_HIST_INIT

#define BU_HIST_INIT (   _hp)
Value:
{ \
(_hp)->magic = BU_HIST_MAGIC; \
(_hp)->hg_min = (_hp)->hg_max = (_hp)->hg_clumpsize = 0.0; \
(_hp)->hg_nsamples = (_hp)->hg_nbins = 0; \
(_hp)->hg_bins = NULL; \
}
#define BU_HIST_MAGIC
Definition: magic.h:62

initialize a bu_hist struct without allocating any memory.

Definition at line 69 of file hist.h.

◆ BU_HIST_INIT_ZERO

#define BU_HIST_INIT_ZERO   {BU_HIST_MAGIC, 0.0, 0.0, 0.0, 0, 0, NULL}

macro suitable for declaration statement initialization of a bu_hist struct. does not allocate memory.

Definition at line 80 of file hist.h.

◆ BU_HIST_IS_INITIALIZED

#define BU_HIST_IS_INITIALIZED (   _hp)    (((struct bu_hist *)(_hp) != BU_HIST_NULL) && LIKELY((_hp)->magic == BU_HIST_MAGIC))

returns truthfully whether a bu_hist has been initialized via BU_HIST_INIT() or BU_HIST_INIT_ZERO.

Definition at line 86 of file hist.h.

◆ BU_HIST_TALLY

#define BU_HIST_TALLY (   _hp,
  _val 
)
Value:
{ \
if ((_val) <= (_hp)->hg_min) { \
(_hp)->hg_bins[0]++; \
} else if ((_val) >= (_hp)->hg_max) { \
(_hp)->hg_bins[(_hp)->hg_nbins]++; \
} else { \
(_hp)->hg_bins[(int)(((_val)-(_hp)->hg_min)/(_hp)->hg_clumpsize)]++; \
} \
(_hp)->hg_nsamples++; }

Definition at line 88 of file hist.h.

◆ BU_HIST_TALLY_MULTIPLE

#define BU_HIST_TALLY_MULTIPLE (   _hp,
  _val,
  _count 
)
Value:
{ \
int __count = (_count); \
if ((_val) <= (_hp)->hg_min) { \
(_hp)->hg_bins[0] += __count; \
} else if ((_val) >= (_hp)->hg_max) { \
(_hp)->hg_bins[(_hp)->hg_nbins] += __count; \
} else { \
(_hp)->hg_bins[(int)(((_val)-(_hp)->hg_min)/(_hp)->hg_clumpsize)] += __count; \
} \
(_hp)->hg_nsamples += __count; }

Definition at line 98 of file hist.h.

Typedef Documentation

◆ bu_hist_t

typedef struct bu_hist bu_hist_t

Definition at line 58 of file hist.h.

Function Documentation

◆ bu_hist_free()

void bu_hist_free ( struct bu_hist histp)

◆ bu_hist_init()

void bu_hist_init ( struct bu_hist histp,
fastf_t  min,
fastf_t  max,
size_t  nbins 
)

Initialize a bu_hist structure.

It is expected that the structure is junk upon entry.

◆ bu_hist_range()

void bu_hist_range ( struct bu_hist hp,
fastf_t  low,
fastf_t  high 
)

◆ bu_hist_pr()

void bu_hist_pr ( const struct bu_hist histp,
const char *  title 
)

Print a histogram.