20#ifndef CCGSL_HISTOGRAM2D_HPP
21#define CCGSL_HISTOGRAM2D_HPP
24#include<gsl/gsl_histogram2d.h>
50 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
100#ifdef __GXX_EXPERIMENTAL_CXX0X__
106 std::swap(
count, v.count );
107 v.ccgsl_pointer =
nullptr;
225#ifdef __GXX_EXPERIMENTAL_CXX0X__
250 inline static histogram2d calloc_uniform(
size_t const nx,
size_t const ny,
251 double const xmin,
double const xmax,
252 double const ymin,
double const ymax ){
262 int increment(
double x,
double y ){
return gsl_histogram2d_increment(
get(), x, y ); }
272 return gsl_histogram2d_accumulate(
get(), x, y, weight ); }
283 int find(
double const x,
double const y,
size_t* i,
size_t* j )
const {
284 return gsl_histogram2d_find(
get(), x, y, i, j ); }
294 int find(
double const x,
double const y,
size_t& i,
size_t& j )
const {
295 return gsl_histogram2d_find(
get(), x, y, &i, &j ); }
303 double get(
size_t const i,
size_t const j )
const {
304 return gsl_histogram2d_get(
get(), i, j ); }
314 int get_xrange(
size_t const i,
double* xlower,
double* xupper )
const {
315 return gsl_histogram2d_get_xrange(
get(), i, xlower, xupper ); }
324 int get_xrange(
size_t const i,
double& xlower,
double& xupper )
const {
325 return gsl_histogram2d_get_xrange(
get(), i, &xlower, &xupper ); }
335 int get_yrange(
size_t const i,
double* ylower,
double* yupper )
const {
336 return gsl_histogram2d_get_yrange(
get(), i, ylower, yupper ); }
345 int get_yrange(
size_t const j,
double& ylower,
double& yupper )
const {
346 return gsl_histogram2d_get_yrange(
get(), j, &ylower, &yupper ); }
352 double xmax()
const {
return gsl_histogram2d_xmax(
get() ); }
358 double xmin()
const {
return gsl_histogram2d_xmin(
get() ); }
364 size_t nx()
const {
return gsl_histogram2d_nx(
get() ); }
370 double ymax()
const {
return gsl_histogram2d_ymax(
get() ); }
376 double ymin()
const {
return gsl_histogram2d_ymin(
get() ); }
382 size_t ny()
const {
return gsl_histogram2d_ny(
get() ); }
398 inline static histogram2d calloc_range(
size_t nx,
size_t ny,
double* xrange,
400 return histogram2d( gsl_histogram2d_calloc_range(
nx,
ny, xrange, yrange ) ); }
408 template<
typename XRANGE,
typename YRANGE>
409 inline static histogram2d calloc_range( XRANGE& xrange, YRANGE& yrange ){
410 return histogram2d( gsl_histogram2d_calloc_range( xrange.size(), yrange.size(),
411 xrange.data(), yrange.data() ) ); }
433 int set_ranges(
double const xrange[],
size_t xsize,
double const yrange[],
size_t ysize ){
434 return gsl_histogram2d_set_ranges(
get(), xrange, xsize, yrange, ysize ); }
442 template<
typename XRANGE,
typename YRANGE>
443 int set_ranges( XRANGE
const& xrange, YRANGE
const& yrange ){
444 return gsl_histogram2d_set_ranges(
get(), xrange.data(), xrange.size(),
445 yrange.data(), yrange.size() ); }
453 return gsl_histogram2d_memcpy(
get(), source.
get() ); }
465 double max_val()
const {
return gsl_histogram2d_max_val(
get() ); }
473 void max_bin(
size_t* i,
size_t* j )
const { gsl_histogram2d_max_bin(
get(), i, j ); }
480 void max_bin(
size_t& i,
size_t& j )
const { gsl_histogram2d_max_bin(
get(), &i, &j ); }
486 double min_val()
const {
return gsl_histogram2d_min_val(
get() ); }
494 void min_bin(
size_t* i,
size_t* j )
const { gsl_histogram2d_min_bin(
get(), i, j ); }
501 void min_bin(
size_t& i,
size_t& j )
const { gsl_histogram2d_min_bin(
get(), &i, &j ); }
507 double xmean()
const {
return gsl_histogram2d_xmean(
get() ); }
513 double ymean()
const {
return gsl_histogram2d_ymean(
get() ); }
519 double xsigma()
const {
return gsl_histogram2d_xsigma(
get() ); }
525 double ysigma()
const {
return gsl_histogram2d_ysigma(
get() ); }
531 double cov()
const {
return gsl_histogram2d_cov(
get() ); }
537 double sum()
const {
return gsl_histogram2d_sum(
get() ); }
546 return gsl_histogram2d_equal_bins_p(
get(), h2.
get() ) != 0; }
595 int fwrite( FILE* stream )
const {
return gsl_histogram2d_fwrite( stream,
get() ); }
602 int fread( FILE* stream ){
return gsl_histogram2d_fread( stream,
get() ); }
611 int fprintf( FILE* stream,
char const* range_format,
char const* bin_format )
const {
612 return gsl_histogram2d_fprintf( stream,
get(), range_format, bin_format ); }
619 int fscanf( FILE* stream ){
return gsl_histogram2d_fscanf( stream,
get() ); }
642 explicit pdf(
size_t const nx,
size_t const ny ){
645 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
658 explicit pdf( gsl_histogram2d_pdf* v ){
695#ifdef __GXX_EXPERIMENTAL_CXX0X__
701 std::swap(
count, v.count );
702 v.ccgsl_pointer =
nullptr;
710 pdf( std::move( v ) ).swap( *
this );
820#ifdef __GXX_EXPERIMENTAL_CXX0X__
831 return gsl_histogram2d_pdf_init(
get(), h.
get() ); }
842 int sample(
double r1,
double r2,
double* x,
double* y ){
843 return gsl_histogram2d_pdf_sample(
get(), r1, r2, x, y ); }
853 int sample(
double r1,
double r2,
double& x,
double& y ){
854 return gsl_histogram2d_pdf_sample(
get(), r1, r2, &x, &y ); }
Empirical probability density functions.
size_t * count
The shared reference count.
bool operator<=(pdf const &v) const
A container needs to define an ordering for sorting.
bool operator==(pdf const &v) const
Two pdf are identically equal if their elements are identical.
pdf & operator=(pdf &&v)
Move operator.
bool operator>=(pdf const &v) const
A container needs to define an ordering for sorting.
gsl_histogram2d_pdf * get() const
Get the gsl_histogram2d_pdf.
size_t use_count() const
Find how many pdf objects share this pointer.
bool operator<(pdf const &v) const
A container needs to define an ordering for sorting.
pdf()
The default constructor is only really useful for assigning to.
pdf(pdf &&v)
Move constructor.
bool unique() const
Find if this is the only object sharing the gsl_histogram2d_pdf.
pdf(gsl_histogram2d_pdf *v)
Could construct from a gsl_histogram2d_pdf.
int init(histogram2d const &h) const
C++ version of gsl_histogram2d_pdf_init().
pdf(size_t const nx, size_t const ny)
The default constructor creates a new pdf with n elements.
pdf & operator=(pdf const &v)
The assignment operator.
int sample(double r1, double r2, double &x, double &y)
C++ version of gsl_histogram2d_pdf_sample().
bool empty() const
Find if the pdf is empty.
pdf(pdf const &v)
The copy constructor.
bool operator>(pdf const &v) const
A container needs to define an ordering for sorting.
void swap(pdf &v)
Swap two pdf objects.
bool operator!=(pdf const &v) const
Two pdf are different if their elements are not identical.
~pdf()
The destructor only deletes the pointers if count reaches zero.
gsl_histogram2d_pdf * ccgsl_pointer
The shared pointer.
bool operator>(histogram2d const &v) const
A container needs to define an ordering for sorting.
double ymean() const
C++ version of gsl_histogram2d_ymean().
double xmean() const
C++ version of gsl_histogram2d_xmean().
int find(double const x, double const y, size_t &i, size_t &j) const
C++ version of gsl_histogram2d_find().
bool operator<(histogram2d const &v) const
A container needs to define an ordering for sorting.
bool empty() const
Find if the histogram2d is empty.
size_t nx() const
C++ version of gsl_histogram2d_nx().
double get(size_t const i, size_t const j) const
C++ version of gsl_histogram2d_get().
double ysigma() const
C++ version of gsl_histogram2d_ysigma().
int sub(histogram2d const &h2)
C++ version of gsl_histogram2d_sub().
bool operator==(histogram2d const &v) const
Two histogram2d are identically equal if their elements are identical.
double max_val() const
C++ version of gsl_histogram2d_max_val().
~histogram2d()
The destructor only deletes the pointers if count reaches zero.
int shift(double shift)
C++ version of gsl_histogram2d_shift().
static histogram2d calloc(size_t const nx, size_t const ny)
C++ version of gsl_histogram2d_calloc().
double sum() const
C++ version of gsl_histogram2d_sum().
int memcpy(histogram2d const &source)
C++ version of gsl_histogram2d_memcpy().
int scale(double scale)
C++ version of gsl_histogram2d_scale().
bool operator>=(histogram2d const &v) const
A container needs to define an ordering for sorting.
bool operator!=(histogram2d const &v) const
Two histogram2d are different if their elements are not identical.
void max_bin(size_t &i, size_t &j) const
C++ version of gsl_histogram2d_max_bin().
gsl_histogram2d * get() const
Get the gsl_histogram2d.
int get_xrange(size_t const i, double &xlower, double &xupper) const
C++ version of gsl_histogram2d_get_xrange().
int set_ranges(XRANGE const &xrange, YRANGE const &yrange)
C++ version of gsl_histogram2d_set_ranges().
gsl_histogram2d * ccgsl_pointer
The shared pointer.
int add(histogram2d const &h2)
C++ version of gsl_histogram2d_add().
double xsigma() const
C++ version of gsl_histogram2d_xsigma().
void swap(histogram2d &v)
Swap two histogram2d objects.
void min_bin(size_t &i, size_t &j) const
C++ version of gsl_histogram2d_min_bin().
histogram2d & operator=(histogram2d const &v)
The assignment operator.
void reset()
C++ version of gsl_histogram2d_reset().
int fprintf(FILE *stream, char const *range_format, char const *bin_format) const
C++ version of gsl_histogram2d_fprintf().
double xmin() const
C++ version of gsl_histogram2d_xmin().
int accumulate(double x, double y, double weight)
C++ version of gsl_histogram2d_accumulate().
histogram2d(histogram2d const &v)
The copy constructor.
int mul(histogram2d const &h2)
C++ version of gsl_histogram2d_mul().
int increment(double x, double y)
C++ version of gsl_histogram2d_increment().
size_t * count
The shared reference count.
histogram2d()
The default constructor is only really useful for assigning to.
histogram2d(size_t const nx, size_t const ny)
The default constructor creates a new histogram2d with n elements.
histogram2d & operator=(histogram2d &&v)
Move operator.
int set_ranges(double const xrange[], size_t xsize, double const yrange[], size_t ysize)
C++ version of gsl_histogram2d_set_ranges().
size_t use_count() const
Find how many histogram2d objects share this pointer.
bool unique() const
Find if this is the only object sharing the gsl_histogram2d.
size_t ny() const
C++ version of gsl_histogram2d_ny().
double xmax() const
C++ version of gsl_histogram2d_xmax().
int fwrite(FILE *stream) const
C++ version of gsl_histogram2d_fwrite().
double cov() const
C++ version of gsl_histogram2d_cov().
double ymax() const
C++ version of gsl_histogram2d_ymax().
int fread(FILE *stream)
C++ version of gsl_histogram2d_fread().
histogram2d clone() const
C++ version of gsl_histogram2d_clone().
int div(histogram2d const &h2)
C++ version of gsl_histogram2d_div().
bool operator<=(histogram2d const &v) const
A container needs to define an ordering for sorting.
histogram2d(gsl_histogram2d *v)
Could construct from a gsl_histogram2d.
int get_yrange(size_t const j, double &ylower, double &yupper) const
C++ version of gsl_histogram2d_get_yrange().
int set_ranges_uniform(double xmin, double xmax, double ymin, double ymax)
C++ version of gsl_histogram2d_set_ranges_uniform().
double ymin() const
C++ version of gsl_histogram2d_ymin().
double min_val() const
C++ version of gsl_histogram2d_min_val().
histogram2d(histogram2d &&v)
Move constructor.
int fscanf(FILE *stream)
C++ version of gsl_histogram2d_fscanf().
bool equal_bins_p(histogram2d const &h2) const
C++ version of gsl_histogram2d_equal_bins_p().
The gsl package creates an interface to the GNU Scientific Library for C++.