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

Histograms. More...

#include <histogram.hpp>

Collaboration diagram for gsl::histogram:
Collaboration graph

Classes

class  pdf
 Histogram probability (empirical) density functions. More...
 

Public Member Functions

 histogram ()
 The default constructor is only really useful for assigning to. More...
 
 histogram (size_t const n)
 The default constructor creates a new histogram with n elements. More...
 
 histogram (gsl_histogram *v)
 Could construct from a gsl_histogram. More...
 
 histogram (histogram const &v)
 The copy constructor. More...
 
histogramoperator= (histogram const &v)
 The assignment operator. More...
 
 ~histogram ()
 The destructor only deletes the pointers if count reaches zero. More...
 
 histogram (histogram &&v)
 Move constructor. More...
 
histogramoperator= (histogram &&v)
 Move operator. More...
 
bool operator== (histogram const &v) const
 Two histogram are identically equal if their elements are identical. More...
 
bool operator!= (histogram const &v) const
 Two histogram are different if their elements are not identical. More...
 
bool operator< (histogram const &v) const
 A container needs to define an ordering for sorting. More...
 
bool operator> (histogram const &v) const
 A container needs to define an ordering for sorting. More...
 
bool operator<= (histogram const &v) const
 A container needs to define an ordering for sorting. More...
 
bool operator>= (histogram const &v) const
 A container needs to define an ordering for sorting. More...
 
bool empty () const
 Find if the histogram is empty. More...
 
void swap (histogram &v)
 Swap two histogram objects. More...
 
gsl_histogram * get () const
 Get the gsl_histogram. More...
 
bool unique () const
 Find if this is the only object sharing the gsl_histogram. More...
 
size_t use_count () const
 Find how many histogram objects share this pointer. More...
 
 operator bool () const
 Allow conversion to bool. More...
 
int increment (double x)
 C++ version of gsl_histogram_increment(). More...
 
int accumulate (double x, double weight)
 C++ version of gsl_histogram_accumulate(). More...
 
int find (double const x, size_t &i) const
 C++ version of gsl_histogram_find(). More...
 
double get (size_t i) const
 C++ version of gsl_histogram_get(). More...
 
double operator[] (size_t i) const
 C++ version of gsl_histogram_get(). More...
 
int get_range (size_t i, double *lower, double *upper) const
 C++ version of gsl_histogram_get_range(). More...
 
int get_range (size_t i, double &lower, double &upper) const
 C++ version of gsl_histogram_get_range(). More...
 
double max () const
 C++ version of gsl_histogram_max(). More...
 
double min () const
 C++ version of gsl_histogram_min(). More...
 
size_t bins () const
 C++ version of gsl_histogram_bins(). More...
 
void reset ()
 C++ version of gsl_histogram_reset(). More...
 
template<typename RANGE >
int set_ranges (RANGE const &range)
 C++ version of gsl_histogram_set_ranges(). More...
 
int set_ranges_uniform (double xmin, double xmax)
 C++ version of gsl_histogram_set_ranges_uniform(). More...
 
int memcpy (histogram const &source)
 C++ version of gsl_histogram_memcpy(). More...
 
histogram clone () const
 C++ version of gsl_histogram_clone(). More...
 
double max_val () const
 C++ version of gsl_histogram_max_val(). More...
 
size_t max_bin () const
 C++ version of gsl_histogram_max_bin(). More...
 
double min_val () const
 C++ version of gsl_histogram_min_val(). More...
 
size_t min_bin () const
 C++ version of gsl_histogram_min_bin(). More...
 
bool equal_bins_p (histogram const &h2) const
 C++ version of gsl_histogram_equal_bins_p(). More...
 
int add (histogram const &h2)
 C++ version of gsl_histogram_add(). More...
 
int sub (histogram const &h2)
 C++ version of gsl_histogram_sub(). More...
 
int mul (histogram const &h2)
 C++ version of gsl_histogram_mul(). More...
 
int div (histogram const &h2)
 C++ version of gsl_histogram_div(). More...
 
int scale (double const scale)
 C++ version of gsl_histogram_scale(). More...
 
int shift (double const shift)
 C++ version of gsl_histogram_shift(). More...
 
double sigma () const
 C++ version of gsl_histogram_sigma(). More...
 
double mean () const
 C++ version of gsl_histogram_mean(). More...
 
double sum () const
 C++ version of gsl_histogram_sum(). More...
 
int fwrite (FILE *stream) const
 C++ version of gsl_histogram_fwrite(). More...
 
int fread (FILE *stream)
 C++ version of gsl_histogram_fread(). More...
 
int fprintf (FILE *stream, char const *range_format, char const *bin_format) const
 C++ version of gsl_histogram_fprintf(). More...
 
int fscanf (FILE *stream)
 C++ version of gsl_histogram_fscanf(). More...
 

Private Attributes

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

Detailed Description

Histograms.

Definition at line 31 of file histogram.hpp.

Constructor & Destructor Documentation

◆ histogram() [1/5]

gsl::histogram::histogram ( )
inline

The default constructor is only really useful for assigning to.

Definition at line 36 of file histogram.hpp.

References ccgsl_pointer, and count.

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

◆ histogram() [2/5]

gsl::histogram::histogram ( size_t const  n)
inlineexplicit

The default constructor creates a new histogram with n elements.

Parameters
nnumber of bins

Definition at line 46 of file histogram.hpp.

References ccgsl_pointer, count, and gsl::rstat::n().

◆ histogram() [3/5]

gsl::histogram::histogram ( gsl_histogram *  v)
inlineexplicit

Could construct from a gsl_histogram.

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

Parameters
vThe histogram

Definition at line 62 of file histogram.hpp.

References ccgsl_pointer, and count.

◆ histogram() [4/5]

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

The copy constructor.

This creates a new reference to the workspace.

Parameters
vThe histogram to copy.

Definition at line 73 of file histogram.hpp.

References ccgsl_pointer, and count.

◆ ~histogram()

gsl::histogram::~histogram ( )
inline

The destructor only deletes the pointers if count reaches zero.

Definition at line 92 of file histogram.hpp.

References ccgsl_pointer, and count.

◆ histogram() [5/5]

gsl::histogram::histogram ( histogram &&  v)
inline

Move constructor.

Parameters
vThe histogram to move.

Definition at line 104 of file histogram.hpp.

References count.

Member Function Documentation

◆ accumulate()

int gsl::histogram::accumulate ( double  x,
double  weight 
)
inline

C++ version of gsl_histogram_accumulate().

Parameters
xA real value
weightThe weight to give to x
Returns
Error code on failure

Definition at line 261 of file histogram.hpp.

References get().

◆ add()

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

C++ version of gsl_histogram_add().

Parameters
h2A histogram
Returns
Error code on failure

Definition at line 429 of file histogram.hpp.

References get().

◆ bins()

size_t gsl::histogram::bins ( ) const
inline

C++ version of gsl_histogram_bins().

Returns
The number of bins

Definition at line 332 of file histogram.hpp.

References get().

◆ clone()

histogram gsl::histogram::clone ( ) const
inline

C++ version of gsl_histogram_clone().

Returns
UNDOCUMENTED

Definition at line 389 of file histogram.hpp.

References get(), and histogram().

◆ div()

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

C++ version of gsl_histogram_div().

Parameters
h2A histogram
Returns
Error code on failure

Definition at line 450 of file histogram.hpp.

References get().

◆ empty()

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

Find if the histogram is empty.

Returns
true if has size zero; otherwise false

Definition at line 181 of file histogram.hpp.

References ccgsl_pointer.

◆ equal_bins_p()

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

C++ version of gsl_histogram_equal_bins_p().

Parameters
h2A histogram
Returns
true or false according as this and h2 do or do not have identical ranges

Definition at line 421 of file histogram.hpp.

References get().

◆ find()

int gsl::histogram::find ( double const  x,
size_t &  i 
) const
inline

C++ version of gsl_histogram_find().

Parameters
xA real value
iThe index of the bin containing x (return value)
Returns
Error code on failure

Definition at line 280 of file histogram.hpp.

References get().

◆ fprintf()

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

C++ version of gsl_histogram_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 505 of file histogram.hpp.

References get().

◆ fread()

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

C++ version of gsl_histogram_fread().

Parameters
streamAn input stream
Returns
Error code on failure

Definition at line 496 of file histogram.hpp.

References get().

◆ fscanf()

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

C++ version of gsl_histogram_fscanf().

Parameters
streamAn inoutput stream
Returns
Error code on failure

Definition at line 513 of file histogram.hpp.

References get().

◆ fwrite()

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

C++ version of gsl_histogram_fwrite().

Parameters
streamAn output stream
Returns
Error code on failure

Definition at line 489 of file histogram.hpp.

References get().

◆ get() [1/2]

gsl_histogram * gsl::histogram::get ( ) const
inline

◆ get() [2/2]

double gsl::histogram::get ( size_t  i) const
inline

C++ version of gsl_histogram_get().

Parameters
iAn index
Returns
The value of the ith bin

Definition at line 288 of file histogram.hpp.

References get().

Referenced by get().

◆ get_range() [1/2]

int gsl::histogram::get_range ( size_t  i,
double &  lower,
double &  upper 
) const
inline

C++ version of gsl_histogram_get_range().

Parameters
iAn index
lowerThe lower bound of the bin (return value)
upperThe upper bound of the bin (return value)
Returns
Error code on failure

Definition at line 313 of file histogram.hpp.

References get().

◆ get_range() [2/2]

int gsl::histogram::get_range ( size_t  i,
double *  lower,
double *  upper 
) const
inline

C++ version of gsl_histogram_get_range().

Parameters
iAn index
lowerThe lower bound of the bin (return value)
upperThe upper bound of the bin (return value)
Returns
Error code on failure

Definition at line 304 of file histogram.hpp.

References get().

◆ increment()

int gsl::histogram::increment ( double  x)
inline

C++ version of gsl_histogram_increment().

Parameters
xA real value
Returns
Error code on failure

Definition at line 253 of file histogram.hpp.

References get().

◆ max()

double gsl::histogram::max ( ) const
inline

C++ version of gsl_histogram_max().

Returns
The maximum upper bound of the histogram

Definition at line 320 of file histogram.hpp.

References get().

◆ max_bin()

size_t gsl::histogram::max_bin ( ) const
inline

C++ version of gsl_histogram_max_bin().

Returns
The index of the bin containing the maximum value

Definition at line 401 of file histogram.hpp.

References get().

◆ max_val()

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

C++ version of gsl_histogram_max_val().

Returns
The maximum value

Definition at line 395 of file histogram.hpp.

References get().

◆ mean()

double gsl::histogram::mean ( ) const
inline

C++ version of gsl_histogram_mean().

Returns
The mean of the histogrammed variable

Definition at line 476 of file histogram.hpp.

References get().

◆ memcpy()

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

C++ version of gsl_histogram_memcpy().

Parameters
sourceA histogram
Returns
Error code on failure

Definition at line 383 of file histogram.hpp.

References get().

◆ min()

double gsl::histogram::min ( ) const
inline

C++ version of gsl_histogram_min().

Returns
The minimum lower bound of the histogram

Definition at line 326 of file histogram.hpp.

References get().

◆ min_bin()

size_t gsl::histogram::min_bin ( ) const
inline

C++ version of gsl_histogram_min_bin().

Returns
The index of the bin containing the minimum value

Definition at line 413 of file histogram.hpp.

References get().

◆ min_val()

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

C++ version of gsl_histogram_min_val().

Returns
The minimum value

Definition at line 407 of file histogram.hpp.

References get().

◆ mul()

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

C++ version of gsl_histogram_mul().

Parameters
h2A histogram
Returns
Error code on failure

Definition at line 443 of file histogram.hpp.

References get().

◆ operator bool()

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

Allow conversion to bool.

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

Definition at line 227 of file histogram.hpp.

References ccgsl_pointer.

◆ operator!=()

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

Two histogram are different if their elements are not identical.

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

Definition at line 134 of file histogram.hpp.

References operator==().

◆ operator<()

bool gsl::histogram::operator< ( histogram 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 histogram is nonnegative.

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

Definition at line 146 of file histogram.hpp.

References ccgsl_pointer.

◆ operator<=()

bool gsl::histogram::operator<= ( histogram 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 histogram is nonnegative.

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

Definition at line 166 of file histogram.hpp.

References ccgsl_pointer.

◆ operator=() [1/2]

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

Move operator.

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

Definition at line 113 of file histogram.hpp.

References histogram().

◆ operator=() [2/2]

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

The assignment operator.

This copies elementwise.

Parameters
vThe histogram to copy

Definition at line 80 of file histogram.hpp.

References ccgsl_pointer, and count.

◆ operator==()

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

Two histogram are identically equal if their elements are identical.

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

Definition at line 126 of file histogram.hpp.

References ccgsl_pointer.

Referenced by operator!=().

◆ operator>()

bool gsl::histogram::operator> ( histogram 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 histogram is nonnegative.

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

Definition at line 156 of file histogram.hpp.

References ccgsl_pointer.

◆ operator>=()

bool gsl::histogram::operator>= ( histogram 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 histogram is nonnegative.

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

Definition at line 176 of file histogram.hpp.

References ccgsl_pointer.

◆ operator[]()

double gsl::histogram::operator[] ( size_t  i) const
inline

C++ version of gsl_histogram_get().

Parameters
iAn index
Returns
The value of the ith bin

Definition at line 295 of file histogram.hpp.

References get().

◆ reset()

void gsl::histogram::reset ( )
inline

C++ version of gsl_histogram_reset().

Definition at line 337 of file histogram.hpp.

References get().

◆ scale()

int gsl::histogram::scale ( double const  scale)
inline

C++ version of gsl_histogram_scale().

Parameters
scaleA constant
Returns
Error code on failure

Definition at line 457 of file histogram.hpp.

References get(), and scale().

Referenced by scale().

◆ set_ranges()

template<typename RANGE >
int gsl::histogram::set_ranges ( RANGE const &  range)
inline

C++ version of gsl_histogram_set_ranges().

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

Parameters
range[]A set of range bounds
Returns
Error code on failure

Definition at line 366 of file histogram.hpp.

References get().

◆ set_ranges_uniform()

int gsl::histogram::set_ranges_uniform ( double  xmin,
double  xmax 
)
inline

C++ version of gsl_histogram_set_ranges_uniform().

Parameters
xminThe new minimum lower bound
xmaxThe new maximum upper bound
Returns
Error code on failure

Definition at line 375 of file histogram.hpp.

References get().

◆ shift()

int gsl::histogram::shift ( double const  shift)
inline

C++ version of gsl_histogram_shift().

Parameters
shiftA constant
Returns
Error code on failure

Definition at line 464 of file histogram.hpp.

References get(), and shift().

Referenced by shift().

◆ sigma()

double gsl::histogram::sigma ( ) const
inline

C++ version of gsl_histogram_sigma().

Returns
The standard deviation of the histogrammed variable

Definition at line 470 of file histogram.hpp.

References get().

◆ sub()

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

C++ version of gsl_histogram_sub().

Parameters
h2A histogram
Returns
Error code on failure

Definition at line 436 of file histogram.hpp.

References get().

◆ sum()

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

C++ version of gsl_histogram_sum().

Returns
The sum of all the binned values

Definition at line 482 of file histogram.hpp.

References get().

◆ swap()

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

Swap two histogram objects.

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

Parameters
vThe histogram to swap with this.

Definition at line 188 of file histogram.hpp.

References ccgsl_pointer, and count.

◆ unique()

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

Find if this is the only object sharing the gsl_histogram.

Returns
true or falses according as this is the only histogram object sharing the gsl_histogram.

Definition at line 213 of file histogram.hpp.

References count.

◆ use_count()

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

Find how many histogram objects share this pointer.

Returns
the number of histogram objects that share this pointer.

Definition at line 218 of file histogram.hpp.

References count.

Member Data Documentation

◆ ccgsl_pointer

gsl_histogram* gsl::histogram::ccgsl_pointer
private

◆ count

size_t* gsl::histogram::count
private

The shared reference count.

Definition at line 200 of file histogram.hpp.

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


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