Object-oriented Scientific Computing Library: Version 0.910
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
hist_2d Class Reference

A two-dimensional histogram class. More...

#include <hist_2d.h>


Detailed Description

Experimental.

Idea for Future:
Write a function to create a 1-d histogram from a 2-d histogram either by selecting one bin in one axis or by marginalizing over one direction.

Definition at line 45 of file hist_2d.h.

Public Member Functions

 hist_2d (const hist_2d &h)
hist_2doperator= (const hist_2d &h)
int setup_interp (twod_intp &ti, bool x_first=true)
 Set up a twod_intp object for interpolation.
Initial bin setup
int set_bins (uniform_grid< double > gx, uniform_grid< double > gy)
template<class vec_t >
int set_bins (size_t nx, vec_t &vx, size_t ny, vec_t &vy)
 Set the bins from a vector.
Weight functions
int update_i (size_t i, size_t j, double val=1.0)
 Increment bin for x by value val.
int update (double x, double y, double val=1.0)
 Increment bin for x by value val.
const double & get_wgt_i (size_t i, size_t j) const
 Return contents of bin with index i.
const double & get_wgt (double x, double y) const
 Return contents of bin for x.
double & get_wgt_i (size_t i, size_t j)
 Return contents of bin with index i.
double & get_wgt (double x, double y)
 Return contents of bin for x.
int set_wgt_i (size_t i, size_t j, double val)
 Set contents of bin with index i to value val.
int set_wgt (double x, double y, double val)
 Set contents of bin for x to value val.
const omatrixget_wgts () const
 Get a const reference to the full data vector.
omatrixget_wgts ()
 Get a reference to the full data vector.
Delete functions
int clear_wgts ()
 Clear the data, but leave the bins as is.
int clear ()
 Clear the entire histogram.
Bin manipulation
void get_bin_indices (double x, double y, size_t &i, size_t &j) const
 Get the index of the bin which holds x.
size_t get_x_bin_index (double x) const
 Get the index of the bin which holds x.
size_t get_y_bin_index (double y) const
 Get the indey of the bin which holds y.
double & get_x_low_i (size_t i)
 Get the lower edge of bin of index i.
const double & get_x_low_i (size_t i) const
 Get the lower edge of bin of index i.
double & get_x_high_i (size_t i)
 Get the upper edge of bin of index i.
const double & get_x_high_i (size_t i) const
 Get the upper edge of bin of index i.
double & get_y_low_i (size_t j)
 Get the lower edge of bin of index j.
const double & get_y_low_i (size_t j) const
 Get the lower edge of bin of index j.
double & get_y_high_i (size_t j)
 Get the upper edge of bin of index j.
const double & get_y_high_i (size_t j) const
 Get the upper edge of bin of index j.
Rep functions
template<class vec_t >
int set_reps (size_t nx, vec_t &vx, size_t ny, vec_t &vy)
 Set the representative x-values for each bin.
template<class vec_t >
int set_x_reps (size_t nx, vec_t &vx)
 Set the representative x-values for each bin.
template<class vec_t >
int set_y_reps (size_t ny, vec_t &vy)
 Set the representative y-values for each bin.
int set_rep_mode (size_t x_mode, size_t y_mode)
 Set mode used to compute bin reps.
size_t get_x_rep_mode () const
 Get mode used to compute bin reps.
size_t get_y_rep_mode () const
 Get mode used to compute bin reps.
const ovectorget_x_bins () const
 Get a reference to the full vector of bin specifications.
const ovectorget_y_bins () const
 Get a reference to the full vector of bin specifications.
size_t size_x () const
 Return the histogram size of the x coordinate.
size_t size_y () const
 Return the histogram size of the y coordinate.
const ovectorget_user_reps_x () const
 Get a reference to the user-specified reps for x coordinates.
const ovectorget_user_reps_y () const
 Get a reference to the user-specified reps for y coordinates.
double & get_x_rep_i (size_t i)
 Return the rep of bin of index i.
const double & get_x_rep_i (size_t i) const
 Return the rep of bin of index i.
double & get_y_rep_i (size_t j)
 Return the rep of bin of index j.
const double & get_y_rep_i (size_t j) const
 Return the rep of bin of index j.

Data Fields

bool extend_rhs
 If true, allow abcissa larger than largest bin limit to correspond to the highest bin (default false).

Static Public Attributes

Rep modes (default is \c rmode_avg)
static const size_t rmode_avg = 0
static const size_t rmode_user = 1
static const size_t rmode_low = 2
static const size_t rmode_high = 3
static const size_t rmode_gmean = 4

Protected Member Functions

void allocate (size_t nx, size_t ny)
 Allocate for a histogram of size nx, ny.
void set_reps_auto ()
 An internal function to automatically set xrep and yrep.

Protected Attributes

ovector xa
 Bin locations (Nx+1)
ovector ya
 Bin locations (Ny+1)
omatrix wgt
 Values (Nx,Ny)
ovector xrep
 "Central" values for x-axis (N)
ovector yrep
 "Central" values for y-axis (N)
ovector user_xrep
 User-defined central values for x-axis (N)
ovector user_yrep
 User-defined central values for y-axis (N)
size_t hsize_x
 Number of x-bins.
size_t hsize_y
 Number of y-bins.
size_t xrmode
 Rep mode for x.
size_t yrmode
 Rep mode for y.
base_interp_mgr
< ovector_const_view > * 
bim1
 A pointer to the interpolation manager.
base_interp_mgr
< ovector_const_subvector > * 
bim2
 A pointer to the subvector interpolation manager.
def_interp_mgr
< ovector_const_view,
cspline_interp
dim1
 Default interpolation manager.
def_interp_mgr
< ovector_const_subvector,
cspline_interp
dim2
 Default interpolation manager.

Member Function Documentation

void hist_2d::allocate ( size_t  nx,
size_t  ny 
) [protected]

This function also sets all the weights to zero.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.