ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
gsl::histogram2d Class Reference

2D histograms. More...

#include <histogram2d.hpp>

Collaboration diagram for gsl::histogram2d:
Collaboration graph

Classes

class  pdf
 Empirical probability density functions. More...
 

Public Member Functions

 histogram2d ()
 The default constructor is only really useful for assigning to. More...
 
 histogram2d (size_t const nx, size_t const ny)
 The default constructor creates a new histogram2d with n elements. More...
 
 histogram2d (gsl_histogram2d *v)
 Could construct from a gsl_histogram2d. More...
 
 histogram2d (histogram2d const &v)
 The copy constructor. More...
 
histogram2doperator= (histogram2d const &v)
 The assignment operator. More...
 
 ~histogram2d ()
 The destructor only deletes the pointers if count reaches zero. More...
 
 histogram2d (histogram2d &&v)
 Move constructor. More...
 
histogram2doperator= (histogram2d &&v)
 Move operator. More...
 
bool operator== (histogram2d const &v) const
 Two histogram2d are identically equal if their elements are identical. More...
 
bool operator!= (histogram2d const &v) const
 Two histogram2d are different if their elements are not identical. More...
 
bool operator< (histogram2d const &v) const
 A container needs to define an ordering for sorting. More...
 
bool operator> (histogram2d const &v) const
 A container needs to define an ordering for sorting. More...
 
bool operator<= (histogram2d const &v) const
 A container needs to define an ordering for sorting. More...
 
bool operator>= (histogram2d const &v) const
 A container needs to define an ordering for sorting. More...
 
bool empty () const
 Find if the histogram2d is empty. More...
 
void swap (histogram2d &v)
 Swap two histogram2d objects. More...
 
gsl_histogram2d * get () const
 Get the gsl_histogram2d. More...
 
bool unique () const
 Find if this is the only object sharing the gsl_histogram2d. More...
 
size_t use_count () const
 Find how many histogram2d objects share this pointer. More...
 
 operator bool () const
 Allow conversion to bool. More...
 
int increment (double x, double y)
 C++ version of gsl_histogram2d_increment(). More...
 
int accumulate (double x, double y, double weight)
 C++ version of gsl_histogram2d_accumulate(). More...
 
int find (double const x, double const y, size_t &i, size_t &j) const
 C++ version of gsl_histogram2d_find(). More...
 
double get (size_t const i, size_t const j) const
 C++ version of gsl_histogram2d_get(). More...
 
int get_xrange (size_t const i, double &xlower, double &xupper) const
 C++ version of gsl_histogram2d_get_xrange(). More...
 
int get_yrange (size_t const j, double &ylower, double &yupper) const
 C++ version of gsl_histogram2d_get_yrange(). More...
 
double xmax () const
 C++ version of gsl_histogram2d_xmax(). More...
 
double xmin () const
 C++ version of gsl_histogram2d_xmin(). More...
 
size_t nx () const
 C++ version of gsl_histogram2d_nx(). More...
 
double ymax () const
 C++ version of gsl_histogram2d_ymax(). More...
 
double ymin () const
 C++ version of gsl_histogram2d_ymin(). More...
 
size_t ny () const
 C++ version of gsl_histogram2d_ny(). More...
 
void reset ()
 C++ version of gsl_histogram2d_reset(). More...
 
int set_ranges_uniform (double xmin, double xmax, double ymin, double ymax)
 C++ version of gsl_histogram2d_set_ranges_uniform(). More...
 
int set_ranges (double const xrange[], size_t xsize, double const yrange[], size_t ysize)
 C++ version of gsl_histogram2d_set_ranges(). More...
 
template<typename XRANGE , typename YRANGE >
int set_ranges (XRANGE const &xrange, YRANGE const &yrange)
 C++ version of gsl_histogram2d_set_ranges(). More...
 
int memcpy (histogram2d const &source)
 C++ version of gsl_histogram2d_memcpy(). More...
 
histogram2d clone () const
 C++ version of gsl_histogram2d_clone(). More...
 
double max_val () const
 C++ version of gsl_histogram2d_max_val(). More...
 
void max_bin (size_t &i, size_t &j) const
 C++ version of gsl_histogram2d_max_bin(). More...
 
double min_val () const
 C++ version of gsl_histogram2d_min_val(). More...
 
void min_bin (size_t &i, size_t &j) const
 C++ version of gsl_histogram2d_min_bin(). More...
 
double xmean () const
 C++ version of gsl_histogram2d_xmean(). More...
 
double ymean () const
 C++ version of gsl_histogram2d_ymean(). More...
 
double xsigma () const
 C++ version of gsl_histogram2d_xsigma(). More...
 
double ysigma () const
 C++ version of gsl_histogram2d_ysigma(). More...
 
double cov () const
 C++ version of gsl_histogram2d_cov(). More...
 
double sum () const
 C++ version of gsl_histogram2d_sum(). More...
 
bool equal_bins_p (histogram2d const &h2) const
 C++ version of gsl_histogram2d_equal_bins_p(). More...
 
int add (histogram2d const &h2)
 C++ version of gsl_histogram2d_add(). More...
 
int sub (histogram2d const &h2)
 C++ version of gsl_histogram2d_sub(). More...
 
int mul (histogram2d const &h2)
 C++ version of gsl_histogram2d_mul(). More...
 
int div (histogram2d const &h2)
 C++ version of gsl_histogram2d_div(). More...
 
int scale (double scale)
 C++ version of gsl_histogram2d_scale(). More...
 
int shift (double shift)
 C++ version of gsl_histogram2d_shift(). More...
 
int fwrite (FILE *stream) const
 C++ version of gsl_histogram2d_fwrite(). More...
 
int fread (FILE *stream)
 C++ version of gsl_histogram2d_fread(). More...
 
int fprintf (FILE *stream, char const *range_format, char const *bin_format) const
 C++ version of gsl_histogram2d_fprintf(). More...
 
int fscanf (FILE *stream)
 C++ version of gsl_histogram2d_fscanf(). More...
 

Static Public Member Functions

static histogram2d calloc (size_t const nx, size_t const ny)
 C++ version of gsl_histogram2d_calloc(). More...
 

Private Attributes

gsl_histogram2d * ccgsl_pointer
 The shared pointer. More...
 
size_t * count
 The shared reference count. More...
 

Detailed Description

2D histograms.

Definition at line 31 of file histogram2d.hpp.

Constructor & Destructor Documentation

◆ histogram2d() [1/5]

gsl::histogram2d::histogram2d ( )
inline

The default constructor is only really useful for assigning to.

Definition at line 36 of file histogram2d.hpp.

References ccgsl_pointer, and count.

Referenced by calloc(), clone(), and operator=().

◆ histogram2d() [2/5]

gsl::histogram2d::histogram2d ( size_t const  nx,
size_t const  ny 
)
inlineexplicit

The default constructor creates a new histogram2d with n elements.

Parameters
nxThe number of bin slices in x direction
nyThe number of bin slices in y direction

Definition at line 47 of file histogram2d.hpp.

References ccgsl_pointer, count, nx(), and ny().

◆ histogram2d() [3/5]

gsl::histogram2d::histogram2d ( gsl_histogram2d *  v)
inlineexplicit

Could construct from a gsl_histogram2d.

This is not usually a good idea. In this case we should not use gsl_histogram2d_free() to deallocate the memory.

Parameters
vThe histogram2d

Definition at line 63 of file histogram2d.hpp.

References ccgsl_pointer, and count.

◆ histogram2d() [4/5]

gsl::histogram2d::histogram2d ( histogram2d const &  v)
inline

The copy constructor.

This creates a new reference to the workspace.

Parameters
vThe histogram2d to copy.

Definition at line 74 of file histogram2d.hpp.

References ccgsl_pointer, and count.

◆ ~histogram2d()

gsl::histogram2d::~histogram2d ( )
inline

The destructor only deletes the pointers if count reaches zero.

Definition at line 93 of file histogram2d.hpp.

References ccgsl_pointer, and count.

◆ histogram2d() [5/5]

gsl::histogram2d::histogram2d ( histogram2d &&  v)
inline

Move constructor.

Parameters
vThe histogram2d to move.

Definition at line 105 of file histogram2d.hpp.

References count.

Member Function Documentation

◆ accumulate()

int gsl::histogram2d::accumulate ( double  x,
double  y,
double  weight 
)
inline

C++ version of gsl_histogram2d_accumulate().

Parameters
xThe x value
yThe y value
weightThe weight given to (x,y)
Returns
Error code on failure

Definition at line 271 of file histogram2d.hpp.

References get().

◆ add()

int gsl::histogram2d::add ( histogram2d const &  h2)
inline

C++ version of gsl_histogram2d_add().

Parameters
h2Another histogram
Returns
Error code on failure

Definition at line 553 of file histogram2d.hpp.

References get().

◆ calloc()

static histogram2d gsl::histogram2d::calloc ( size_t const  nx,
size_t const  ny 
)
inlinestatic

C++ version of gsl_histogram2d_calloc().

Parameters
nxNumber of bin slices in x direction
nyNumber of bin slices in y direction
Returns
A new histogram2d object

Definition at line 236 of file histogram2d.hpp.

References histogram2d(), nx(), and ny().

◆ clone()

histogram2d gsl::histogram2d::clone ( ) const
inline

C++ version of gsl_histogram2d_clone().

Returns
A new histogram2d object

Definition at line 459 of file histogram2d.hpp.

References get(), and histogram2d().

◆ cov()

double gsl::histogram2d::cov ( ) const
inline

C++ version of gsl_histogram2d_cov().

Returns
The covariance of the histogrammed values

Definition at line 531 of file histogram2d.hpp.

References get().

◆ div()

int gsl::histogram2d::div ( histogram2d const &  h2)
inline

C++ version of gsl_histogram2d_div().

Parameters
h2Another histogram
Returns
Error code on failure

Definition at line 574 of file histogram2d.hpp.

References get().

◆ empty()

bool gsl::histogram2d::empty ( ) const
inline

Find if the histogram2d is empty.

Returns
true if has size zero; otherwise false

Definition at line 182 of file histogram2d.hpp.

References ccgsl_pointer.

◆ equal_bins_p()

bool gsl::histogram2d::equal_bins_p ( histogram2d const &  h2) const
inline

C++ version of gsl_histogram2d_equal_bins_p().

Parameters
h2Another histogram
Returns
true or false according as h2 does or does not contain the same number of x and y bin slices (ranges) as this

Definition at line 545 of file histogram2d.hpp.

References get().

◆ find()

int gsl::histogram2d::find ( double const  x,
double const  y,
size_t &  i,
size_t &  j 
) const
inline

C++ version of gsl_histogram2d_find().

Parameters
xThe x value
yThe y value
iThe index in the x direction (return value)
jThe index in the y direction (return value)
Returns
Error code on failure

Definition at line 294 of file histogram2d.hpp.

References get().

◆ fprintf()

int gsl::histogram2d::fprintf ( FILE *  stream,
char const *  range_format,
char const *  bin_format 
) const
inline

C++ version of gsl_histogram2d_fprintf().

Parameters
streamAn output stream
range_formatOne of the g, e or f formats
bin_formatOne of the g, e or f formats
Returns
Error code on failure

Definition at line 611 of file histogram2d.hpp.

References get().

◆ fread()

int gsl::histogram2d::fread ( FILE *  stream)
inline

C++ version of gsl_histogram2d_fread().

Parameters
streamAn input stream
Returns
Error code on failure

Definition at line 602 of file histogram2d.hpp.

References get().

◆ fscanf()

int gsl::histogram2d::fscanf ( FILE *  stream)
inline

C++ version of gsl_histogram2d_fscanf().

Parameters
streamAn input stream
Returns
Error code on failure

Definition at line 619 of file histogram2d.hpp.

References get().

◆ fwrite()

int gsl::histogram2d::fwrite ( FILE *  stream) const
inline

C++ version of gsl_histogram2d_fwrite().

Parameters
streamAn output stream
Returns
Error code on failure

Definition at line 595 of file histogram2d.hpp.

References get().

◆ get() [1/2]

gsl_histogram2d * gsl::histogram2d::get ( ) const
inline

◆ get() [2/2]

double gsl::histogram2d::get ( size_t const  i,
size_t const  j 
) const
inline

C++ version of gsl_histogram2d_get().

Parameters
iThe index in the x direction
jThe index in the y direction
Returns
The size of the bin at (i,j)

Definition at line 303 of file histogram2d.hpp.

References get().

◆ get_xrange()

int gsl::histogram2d::get_xrange ( size_t const  i,
double &  xlower,
double &  xupper 
) const
inline

C++ version of gsl_histogram2d_get_xrange().

Parameters
iThe index in the x direction
xlowerThe lower bound
xupperThe upper bound
Returns
Error code on failure

Definition at line 324 of file histogram2d.hpp.

References get().

◆ get_yrange()

int gsl::histogram2d::get_yrange ( size_t const  j,
double &  ylower,
double &  yupper 
) const
inline

C++ version of gsl_histogram2d_get_yrange().

Parameters
jThe index in the y direction
ylowerThe lower bound
yupperThe upper bound
Returns
Error code on failure

Definition at line 345 of file histogram2d.hpp.

References get().

◆ increment()

int gsl::histogram2d::increment ( double  x,
double  y 
)
inline

C++ version of gsl_histogram2d_increment().

Parameters
xThe x value
yThe y value
Returns
Error code on failure

Definition at line 262 of file histogram2d.hpp.

References get().

◆ max_bin()

void gsl::histogram2d::max_bin ( size_t &  i,
size_t &  j 
) const
inline

C++ version of gsl_histogram2d_max_bin().

Parameters
iThe index in the x direction (return value)
jThe index in the y direction (return value)

Definition at line 480 of file histogram2d.hpp.

References get().

◆ max_val()

double gsl::histogram2d::max_val ( ) const
inline

C++ version of gsl_histogram2d_max_val().

Returns
The maximum value contained in the histogram

Definition at line 465 of file histogram2d.hpp.

References get().

◆ memcpy()

int gsl::histogram2d::memcpy ( histogram2d const &  source)
inline

C++ version of gsl_histogram2d_memcpy().

Parameters
sourceA histogram2d object
Returns
Error code on failure

Definition at line 452 of file histogram2d.hpp.

References get().

◆ min_bin()

void gsl::histogram2d::min_bin ( size_t &  i,
size_t &  j 
) const
inline

C++ version of gsl_histogram2d_min_bin().

Parameters
iThe index in the x direction (return value)
jThe index in the y direction (return value)

Definition at line 501 of file histogram2d.hpp.

References get().

◆ min_val()

double gsl::histogram2d::min_val ( ) const
inline

C++ version of gsl_histogram2d_min_val().

Returns
The minimum value contained in the histogram

Definition at line 486 of file histogram2d.hpp.

References get().

◆ mul()

int gsl::histogram2d::mul ( histogram2d const &  h2)
inline

C++ version of gsl_histogram2d_mul().

Parameters
h2Another histogram
Returns
Error code on failure

Definition at line 567 of file histogram2d.hpp.

References get().

◆ nx()

size_t gsl::histogram2d::nx ( ) const
inline

C++ version of gsl_histogram2d_nx().

Returns
The number of bin slices in the x direction

Definition at line 364 of file histogram2d.hpp.

References get().

Referenced by calloc(), histogram2d(), and gsl::histogram2d::pdf::pdf().

◆ ny()

size_t gsl::histogram2d::ny ( ) const
inline

C++ version of gsl_histogram2d_ny().

Returns
The number of bin slices in the y direction

Definition at line 382 of file histogram2d.hpp.

References get().

Referenced by calloc(), histogram2d(), and gsl::histogram2d::pdf::pdf().

◆ operator bool()

gsl::histogram2d::operator bool ( ) const
inlineexplicit

Allow conversion to bool.

Returns
true or false according as this contains a pointer to a gsl_histogram2d.

Definition at line 228 of file histogram2d.hpp.

References ccgsl_pointer.

◆ operator!=()

bool gsl::histogram2d::operator!= ( histogram2d const &  v) const
inline

Two histogram2d are different if their elements are not identical.

Parameters
vThe histogram2d to be compared with this
Returns
false or true according as this and v have identical elements or not

Definition at line 135 of file histogram2d.hpp.

References operator==().

◆ operator<()

bool gsl::histogram2d::operator< ( histogram2d const &  v) const
inline

A container needs to define an ordering for sorting.

This uses standard lexicographical ordering and so is not useful, for example, for checking, that a histogram2d is nonnegative.

Parameters
vThe histogram2d to be compared with this
Returns
false or true according as this is less than v lexicographically

Definition at line 147 of file histogram2d.hpp.

References ccgsl_pointer.

◆ operator<=()

bool gsl::histogram2d::operator<= ( histogram2d const &  v) const
inline

A container needs to define an ordering for sorting.

This uses standard lexicographical ordering and so is not useful, for example, for checking, that a histogram2d is nonnegative.

Parameters
vThe histogram2d to be compared with this
Returns
false or true according as this is less than or equal to v lexicographically

Definition at line 167 of file histogram2d.hpp.

References ccgsl_pointer.

◆ operator=() [1/2]

histogram2d & gsl::histogram2d::operator= ( histogram2d &&  v)
inline

Move operator.

Parameters
vThe histogram2d to move.
Returns
A reference to this.

Definition at line 114 of file histogram2d.hpp.

References histogram2d().

◆ operator=() [2/2]

histogram2d & gsl::histogram2d::operator= ( histogram2d const &  v)
inline

The assignment operator.

This copies elementwise.

Parameters
vThe histogram2d to copy

Definition at line 81 of file histogram2d.hpp.

References ccgsl_pointer, and count.

◆ operator==()

bool gsl::histogram2d::operator== ( histogram2d const &  v) const
inline

Two histogram2d are identically equal if their elements are identical.

Parameters
vThe histogram2d to be compared with this
Returns
true or false according as this and v have identical elements or not

Definition at line 127 of file histogram2d.hpp.

References ccgsl_pointer.

Referenced by operator!=().

◆ operator>()

bool gsl::histogram2d::operator> ( histogram2d const &  v) const
inline

A container needs to define an ordering for sorting.

This uses standard lexicographical ordering and so is not useful, for example, for checking, that a histogram2d is nonnegative.

Parameters
vThe histogram2d to be compared with this
Returns
false or true according as this is greater than v lexicographically

Definition at line 157 of file histogram2d.hpp.

References ccgsl_pointer.

◆ operator>=()

bool gsl::histogram2d::operator>= ( histogram2d const &  v) const
inline

A container needs to define an ordering for sorting.

This uses standard lexicographical ordering and so is not useful, for example, for checking, that a histogram2d is nonnegative.

Parameters
vThe histogram2d to be compared with this
Returns
false or true according as this is no less than v lexicographically

Definition at line 177 of file histogram2d.hpp.

References ccgsl_pointer.

◆ reset()

void gsl::histogram2d::reset ( )
inline

C++ version of gsl_histogram2d_reset().

Definition at line 387 of file histogram2d.hpp.

References get().

◆ scale()

int gsl::histogram2d::scale ( double  scale)
inline

C++ version of gsl_histogram2d_scale().

Parameters
scaleA constant
Returns
Error code on failure

Definition at line 581 of file histogram2d.hpp.

References get(), and scale().

Referenced by scale().

◆ set_ranges() [1/2]

int gsl::histogram2d::set_ranges ( double const  xrange[],
size_t  xsize,
double const  yrange[],
size_t  ysize 
)
inline

C++ version of gsl_histogram2d_set_ranges().

Parameters
xrange[]The x ranges
xsizeThe size of xrange
yrange[]The y ranges
ysizeThe size of yrange
Returns
Error code on failure

Definition at line 433 of file histogram2d.hpp.

References get().

◆ set_ranges() [2/2]

template<typename XRANGE , typename YRANGE >
int gsl::histogram2d::set_ranges ( XRANGE const &  xrange,
YRANGE const &  yrange 
)
inline

C++ version of gsl_histogram2d_set_ranges().

This version works with std::vector<double> and gsl::vector

Parameters
xrangeThe x ranges
yrangeThe y ranges
Returns
Error code on failure

Definition at line 443 of file histogram2d.hpp.

References get().

◆ set_ranges_uniform()

int gsl::histogram2d::set_ranges_uniform ( double  xmin,
double  xmax,
double  ymin,
double  ymax 
)
inline

C++ version of gsl_histogram2d_set_ranges_uniform().

Parameters
xminLower bound of bottom x range
xmaxUpper bound of top x range
yminLower bound of bottom y range
ymaxUpper bound of top y range
Returns
Error code on failure

Definition at line 422 of file histogram2d.hpp.

References get(), xmax(), xmin(), ymax(), and ymin().

◆ shift()

int gsl::histogram2d::shift ( double  shift)
inline

C++ version of gsl_histogram2d_shift().

Parameters
shiftA constant
Returns
Error code on failure

Definition at line 588 of file histogram2d.hpp.

References get(), and shift().

Referenced by shift().

◆ sub()

int gsl::histogram2d::sub ( histogram2d const &  h2)
inline

C++ version of gsl_histogram2d_sub().

Parameters
h2Another histogram
Returns
Error code on failure

Definition at line 560 of file histogram2d.hpp.

References get().

◆ sum()

double gsl::histogram2d::sum ( ) const
inline

C++ version of gsl_histogram2d_sum().

Returns
The sum of all the histogram values

Definition at line 537 of file histogram2d.hpp.

References get().

◆ swap()

void gsl::histogram2d::swap ( histogram2d v)
inline

Swap two histogram2d objects.

This works even if the histogram2d have different sizes because it swaps pointers.

Parameters
vThe histogram2d to swap with this.

Definition at line 189 of file histogram2d.hpp.

References ccgsl_pointer, and count.

◆ unique()

bool gsl::histogram2d::unique ( ) const
inline

Find if this is the only object sharing the gsl_histogram2d.

Returns
true or falses according as this is the only histogram2d object sharing the gsl_histogram2d.

Definition at line 214 of file histogram2d.hpp.

References count.

◆ use_count()

size_t gsl::histogram2d::use_count ( ) const
inline

Find how many histogram2d objects share this pointer.

Returns
the number of histogram2d objects that share this pointer.

Definition at line 219 of file histogram2d.hpp.

References count.

◆ xmax()

double gsl::histogram2d::xmax ( ) const
inline

C++ version of gsl_histogram2d_xmax().

Returns
The upper bound of the top x range

Definition at line 352 of file histogram2d.hpp.

References get().

Referenced by set_ranges_uniform().

◆ xmean()

double gsl::histogram2d::xmean ( ) const
inline

C++ version of gsl_histogram2d_xmean().

Returns
The mean of the histogrammed x values

Definition at line 507 of file histogram2d.hpp.

References get().

◆ xmin()

double gsl::histogram2d::xmin ( ) const
inline

C++ version of gsl_histogram2d_xmin().

Returns
The lower bound of the bottom x range

Definition at line 358 of file histogram2d.hpp.

References get().

Referenced by set_ranges_uniform().

◆ xsigma()

double gsl::histogram2d::xsigma ( ) const
inline

C++ version of gsl_histogram2d_xsigma().

Returns
The standard deviation of the histogrammed x values

Definition at line 519 of file histogram2d.hpp.

References get().

◆ ymax()

double gsl::histogram2d::ymax ( ) const
inline

C++ version of gsl_histogram2d_ymax().

Returns
The upper bound of the top y range

Definition at line 370 of file histogram2d.hpp.

References get().

Referenced by set_ranges_uniform().

◆ ymean()

double gsl::histogram2d::ymean ( ) const
inline

C++ version of gsl_histogram2d_ymean().

Returns
The mean of the histogrammed y values

Definition at line 513 of file histogram2d.hpp.

References get().

◆ ymin()

double gsl::histogram2d::ymin ( ) const
inline

C++ version of gsl_histogram2d_ymin().

Returns
The lower bound of the bottom y range

Definition at line 376 of file histogram2d.hpp.

References get().

Referenced by set_ranges_uniform().

◆ ysigma()

double gsl::histogram2d::ysigma ( ) const
inline

C++ version of gsl_histogram2d_ysigma().

Returns
The standard deviation of the histogrammed x values

Definition at line 525 of file histogram2d.hpp.

References get().

Member Data Documentation

◆ ccgsl_pointer

gsl_histogram2d* gsl::histogram2d::ccgsl_pointer
private

◆ count

size_t* gsl::histogram2d::count
private

The shared reference count.

Definition at line 201 of file histogram2d.hpp.

Referenced by histogram2d(), operator=(), swap(), unique(), use_count(), and ~histogram2d().


The documentation for this class was generated from the following file: