hist_2d.h
Go to the documentation of this file.
1 /*
2  -------------------------------------------------------------------
3 
4  Copyright (C) 2010-2020, Andrew W. Steiner
5 
6  This file is part of O2scl.
7 
8  O2scl is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 3 of the License, or
11  (at your option) any later version.
12 
13  O2scl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with O2scl. If not, see <http://www.gnu.org/licenses/>.
20 
21  -------------------------------------------------------------------
22 */
23 #ifndef O2SCL_HIST_2D_H
24 #define O2SCL_HIST_2D_H
25 
26 /** \file hist_2d.h
27  \brief File defining \ref o2scl::hist_2d
28 */
29 #include <iostream>
30 
31 #include <boost/numeric/ublas/vector.hpp>
32 #include <boost/numeric/ublas/matrix.hpp>
33 
34 #include <o2scl/convert_units.h>
35 #include <o2scl/interp.h>
36 #include <o2scl/uniform_grid.h>
37 #include <o2scl/table3d.h>
38 
39 // Forward definition of the hist_2d class for HDF I/O
40 namespace o2scl {
41  class hist_2d;
42 }
43 
44 // Forward definition of HDF I/O to extend friendship
45 namespace o2scl_hdf {
46  class hdf_file;
47  void hdf_input(hdf_file &hf, o2scl::hist_2d &t, std::string name);
48  void hdf_output(hdf_file &hf, o2scl::hist_2d &t, std::string name);
49 }
50 
51 #ifndef DOXYGEN_NO_O2NS
52 namespace o2scl {
53 #endif
54 
55  /** \brief A two-dimensional histogram class
56 
57  See discussion in the User's guide in the \ref hist_section
58  section.
59 
60  Typical usage begins with setting the histogram bins using
61  \ref hist_2d::set_bin_edges(). Note that if one attempts to set
62  the bins on a histogram where the bins have already been set,
63  one must ensure that the new and old bin settings have the same
64  size (in both x and y directions). This ensures that there is no
65  ambiguity in rebinning the data and also prevents accidental
66  data loss. One may set the bin edges either with generic
67  vectors, or with \ref uniform_grid objects.
68 
69  \note In order to ensure the histogram does not employ
70  user-specified representative values that are not defined, the
71  function \ref set_rep_mode() does not allow one to change the
72  mode to \ref hist::rmode_user directly. Instead, use \ref
73  set_reps() which automatically sets the mode to \ref
74  hist::rmode_user and allows the user to specify the
75  representatives.
76 
77  \comment
78 
79  This is commented out for now. The \ref twod_intp
80  object stores a reference to xrep and yrep, and thus
81  can't be used since xrep and yrep don't always exist.
82 
83  Interpolation for \ref hist_2d objects is performed by creating
84  a \ref twod_intp object from the internal histogram data. This
85  is done using \ref o2scl::hist_2d::setup_interp() .
86 
87  \endcomment
88 
89  Internally, either \ref hsize_x and \ref hsize_y should
90  both be zero or both be non-zero.
91 
92  \future Write a function to create a 1-d histogram
93  from a 2-d histogram either by selecting one bin
94  in one axis or by marginalizing over one direction.
95 
96  \future Note that here, there is a conflict between implementing
97  operator(size_t,size_t) to give matrix indexing of the histogram
98  weights, and operator(double,double) to implement
99  two-dimensional interpolation using the weights and the
100  representatives. Currently neither is implemented, but maybe
101  both should be implemented instead?
102  */
103  class hist_2d {
104 
105  public:
106 
109 
110  protected:
111 
112  /// Bin locations (Nx+1)
114 
115  /// Bin locations (Ny+1)
117 
118  /// Values (Nx,Ny)
120 
121  /// "Central" values for x-axis (N)
123 
124  /// "Central" values for y-axis (N)
126 
127  /// User-defined central values for x-axis (N)
129 
130  /// User-defined central values for y-axis (N)
132 
133  /// Number of x-bins
134  size_t hsize_x;
135 
136  /// Number of y-bins
137  size_t hsize_y;
138 
139  /// Rep mode for x
140  size_t xrmode;
141 
142  /// Rep mode for y
143  size_t yrmode;
144 
145  /** \brief Allocate for a histogram of size \c nx, \c ny
146 
147  This function also sets all the weights to zero.
148  */
149  void allocate(size_t nx, size_t ny);
150 
151  /** \brief An internal function to automatically set
152  \ref xrep and \ref yrep
153  */
154  void set_reps_auto();
155 
156  public:
157 
158  hist_2d();
159 
160  virtual ~hist_2d();
161 
162  /// Copy constructor
163  hist_2d(const hist_2d &h);
164 
165  /// Copy from <tt>operator=()</tt>
166  hist_2d &operator=(const hist_2d &h);
167 
168  /// Create a 2D histogram from vectors of data
169  template<class vec_t, class vec2_t> hist_2d
170  (size_t nv, const vec_t &v, const vec2_t &v2, size_t n_bins_x,
171  size_t n_bins_y) {
172 
173  xrmode=rmode_avg;
174  yrmode=rmode_avg;
175  extend_rhs=false;
176  extend_lhs=false;
177  hsize_x=0;
178  hsize_y=0;
179 
180  double min_x, max_x, min_y, max_y;
181  o2scl::vector_minmax_value(nv,v,min_x,max_x);
182  o2scl::vector_minmax_value(nv,v2,min_y,max_y);
183  uniform_grid<double> ugx=uniform_grid_end<double>(min_x,max_x,n_bins_x);
184  uniform_grid<double> ugy=uniform_grid_end<double>(min_y,max_y,n_bins_y);
185  set_bin_edges(ugx,ugy);
186 
187  for(size_t i=0;i<nv;i++) {
188  update(v[i],v2[i]);
189  }
190  return;
191  }
192 
193  /** \brief Create a 2D histogram from vectors of data obtaining
194  weights from a third column
195  */
196  template<class vec_t, class vec2_t, class vec3_t> hist_2d
197  (size_t nv, const vec_t &v, const vec2_t &v2, const vec3_t &v3,
198  size_t n_bins_x, size_t n_bins_y) {
199 
200  xrmode=rmode_avg;
201  yrmode=rmode_avg;
202  extend_rhs=false;
203  extend_lhs=false;
204  hsize_x=0;
205  hsize_y=0;
206 
207  double min_x, max_x, min_y, max_y;
208  o2scl::vector_minmax_value(nv,v,min_x,max_x);
209  o2scl::vector_minmax_value(nv,v2,min_y,max_y);
210  uniform_grid<double> ugx=uniform_grid_end<double>(min_x,max_x,n_bins_x);
211  uniform_grid<double> ugy=uniform_grid_end<double>(min_y,max_y,n_bins_y);
212  set_bin_edges(ugx,ugy);
213 
214  for(size_t i=0;i<nv;i++) {
215  update(v[i],v2[i],v3[i]);
216  }
217  return;
218  }
219 
220  /** \brief Create a 2D histogram from vectors of data
221  */
222  template<class vec_t, class vec2_t> hist_2d
223  (const vec_t &v, const vec2_t &v2, size_t n_bins_x,
224  size_t n_bins_y) {
225 
226  hist_2d(v.size(),v,v2,n_bins_x,n_bins_y);
227 
228  return;
229  }
230 
231  /** \brief Create a 2D histogram from vectors of data, obtaining
232  weights from the third vector
233  */
234  template<class vec_t, class vec2_t, class vec3_t> hist_2d
235  (const vec_t &v, const vec2_t &v2, const vec3_t &v3, size_t n_bins_x,
236  size_t n_bins_y) {
237 
238  hist_2d(v.size(),v,v2,v3,n_bins_x,n_bins_y);
239 
240  return;
241  }
242 
243  /** \brief Create a 2D histogram object from a table
244  */
245  void from_table(o2scl::table<> &t, std::string colx, std::string coly,
246  size_t n_bins_x, size_t n_bins_y) {
247  *this=hist_2d(t.get_nlines(),t.get_column(colx),t.get_column(coly),
248  n_bins_x,n_bins_y);
249  return;
250  }
251 
252  /** \brief Create a 2D histogram object from a table,
253  obtaining weights from the third column
254  */
255  void from_table(o2scl::table<> &t, std::string colx, std::string coly,
256  std::string colz, size_t n_bins_x, size_t n_bins_y) {
257  *this=hist_2d(t.get_nlines(),t.get_column(colx),t.get_column(coly),
258  t.get_column(colz),n_bins_x,n_bins_y);
259  return;
260  }
261 
262  /** \brief If true, allow abcissa larger than largest bin limit
263  to correspond to the highest bin (default false).
264  */
266 
267  /** \brief If true, allow abcissa smaller than smallest bin
268  limit to correspond to the lowest bin (default false).
269  */
271 
272  /** \brief Return the sum of all of the weights
273  */
274  double sum_wgts();
275 
276  /** \brief Return the integral under the histogram
277 
278  This function returns the sum of
279  \f[
280  w_{i,j} ( \mathrm{x,high}_i - \mathrm{x,low}_i)
281  ( \mathrm{y,high}_j - \mathrm{y,low}_j) \, .
282  \f]
283  */
284  double integ_wgts();
285 
286  /// \name Initial bin setup
287  //@{
288  /// Set the bins from two \ref uniform_grid objects
290 
291  /// Set the bins from a vector
292  template<class vec_t> void set_bin_edges(size_t nx, vec_t &vx,
293  size_t ny, vec_t &vy) {
294  if (nx!=hsize_x+1 || ny!=hsize_y+1) {
295  if (hsize_x!=0 || hsize_y!=0) {
296  O2SCL_ERR2("Requested binning change in non-empty ",
297  "histogram in hist_2d::set_bin_edges().",
298  exc_efailed);
299  }
300  allocate(nx-1,ny-1);
301  }
302  for(size_t i=0;i<nx;i++) xa[i]=vx[i];
303  for(size_t i=0;i<ny;i++) ya[i]=vy[i];
304  // Reset internal reps
305  if (xrep.size()>0) xrep.resize(0);
306  if (yrep.size()>0) yrep.resize(0);
307  return;
308  }
309  //@}
310 
311  /// \name Weight functions
312  //@{
313  /// Increment bin at <tt>(i,j)</tt> by value \c val
314  void update_i(size_t i, size_t j, double val=1.0) {
315  wgt(i,j)+=val;
316  return;
317  }
318 
319  /// Increment bin for \c x by value \c val
320  void update(double x, double y, double val=1.0) {
321  size_t i, j;
322  get_bin_indices(x,y,i,j);
323  update_i(i,j,val);
324  return;
325  }
326 
327  /// Return contents of bin at <tt>(i,j)</tt>
328  const double &get_wgt_i(size_t i, size_t j) const;
329 
330  /// Return contents of bin for \c x
331  const double &get_wgt(double x, double y) const {
332  size_t i, j;
333  get_bin_indices(x,y,i,j);
334  return get_wgt_i(i,j);
335  }
336 
337  /// Return contents of bin at <tt>(i,j)</tt>
338  double &get_wgt_i(size_t i, size_t j);
339 
340  /// Return contents of bin for \c x
341  double &get_wgt(double x, double y) {
342  size_t i, j;
343  get_bin_indices(x,y,i,j);
344  return get_wgt_i(i,j);
345  }
346 
347  /// Set contents of bin at <tt>(i,j)</tt> to value \c val
348  void set_wgt_i(size_t i, size_t j, double val);
349 
350  /// Set contents of bin for \c x to value \c val
351  void set_wgt(double x, double y, double val) {
352  size_t i, j;
353  get_bin_indices(x,y,i,j);
354  set_wgt_i(i,j,val);
355  return;
356  }
357 
358  /// Get a const reference to the full matrix of data
359  const ubmatrix &get_wgts() const {
360  return wgt;
361  }
362 
363  /// Get a reference to the full matrix of data
365  return wgt;
366  }
367  //@}
368 
369  /// \name Delete functions
370  //@{
371  /// Clear the data, but leave the bins as is
372  void clear_wgts();
373 
374  /// Clear the entire histogram
375  void clear();
376  //@}
377 
378  /// \name Bin manipulation
379  //@{
380  /** \brief Get the index of the bin which holds \c x and
381  the bin which holds \c y
382  */
383  void get_bin_indices(double x, double y, size_t &i, size_t &j) const;
384 
385  /// Get the index of the bin which holds \c x
386  size_t get_x_bin_index(double x) const;
387 
388  /// Get the indey of the bin which holds \c y
389  size_t get_y_bin_index(double y) const;
390 
391  /// Get the lower edge of bin of index \c i
392  double &get_x_low_i(size_t i);
393 
394  /// Get the lower edge of bin of index \c i
395  const double &get_x_low_i(size_t i) const;
396 
397  /// Get the upper edge of bin of index \c i
398  double &get_x_high_i(size_t i);
399 
400  /// Get the upper edge of bin of index \c i
401  const double &get_x_high_i(size_t i) const;
402 
403  /// Get the lower edge of bin of index \c j
404  double &get_y_low_i(size_t j);
405 
406  /// Get the lower edge of bin of index \c j
407  const double &get_y_low_i(size_t j) const;
408 
409  /// Get the upper edge of bin of index \c j
410  double &get_y_high_i(size_t j);
411 
412  /// Get the upper edge of bin of index \c j
413  const double &get_y_high_i(size_t j) const;
414  //@}
415 
416  /// \name Rep modes (default is \c rmode_avg)
417  //@{
418  static const size_t rmode_avg=0;
419  static const size_t rmode_user=1;
420  static const size_t rmode_low=2;
421  static const size_t rmode_high=3;
422  static const size_t rmode_gmean=4;
423  //@}
424 
425  /// \name Representative functions
426  //@{
427  /// Set the representative x-values for each bin
428  template<class vec_t> void set_reps(size_t nx, vec_t &vx,
429  size_t ny, vec_t &vy) {
430  if (user_xrep.size()!=hsize_x || user_yrep.size()!=hsize_y) {
431  std::string s="Expected vectors of size "+itos(hsize_x)+
432  ", "+itos(hsize_y)+" and got a vectors of size "+itos(nx)+
433  ", "+itos(ny)+" in hist_2d::set_reps().";
434  O2SCL_ERR(s.c_str(),exc_einval);
435  }
436  xrmode=rmode_user;
437  yrmode=rmode_user;
438  if (user_xrep.size()>0) user_xrep.clear();
439  if (user_yrep.size()>0) user_yrep.clear();
440  user_xrep.resize(nx);
441  user_yrep.resize(ny);
442  for(size_t i=0;i<nx;i++) user_xrep[i]=vx[i];
443  for(size_t i=0;i<ny;i++) user_yrep[i]=vy[i];
444  return;
445  }
446 
447  /// Set the representative x-values for each bin
448  template<class vec_t> void set_x_reps(size_t nx, vec_t &vx) {
449  if (hsize_x!=nx) {
450  std::string s="Expected vector of size "+itos(hsize_x)+
451  " and got a vector of size "+itos(nx)+" in hist_2d::set_reps().";
452  O2SCL_ERR(s.c_str(),exc_einval);
453  }
454  xrmode=rmode_user;
455  if (user_xrep.size()>0) user_xrep.clear();
456  user_xrep.resize(nx);
457  for(size_t i=0;i<nx;i++) user_xrep[i]=vx[i];
458  return;
459  }
460 
461  /// Set the representative y-values for each bin
462  template<class vec_t> void set_y_reps(size_t ny, vec_t &vy) {
463  if (hsize_y!=ny) {
464  std::string s="Expected vector of size "+itos(hsize_y)+
465  " and got a vector of size "+itos(ny)+" in hist_2d::set_reps().";
466  O2SCL_ERR(s.c_str(),exc_einval);
467  }
468  yrmode=rmode_user;
469  if (user_yrep.size()>0) user_yrep.clear();
470  user_yrep.resize(ny);
471  for(size_t i=0;i<ny;i++) user_yrep[i]=vy[i];
472  return;
473  }
474 
475  /// Set mode used to compute bin reps
476  void set_rep_mode(size_t x_mode, size_t y_mode);
477 
478  /// Get mode used to compute bin reps
479  size_t get_x_rep_mode() const {
480  return xrmode;
481  }
482 
483  /// Get mode used to compute bin reps
484  size_t get_y_rep_mode() const {
485  return yrmode;
486  }
487 
488  /// Get a reference to the full vector of bin specifications
489  const ubvector &get_x_bins() const {
490  return xa;
491  }
492 
493  /// Get a reference to the full vector of bin specifications
494  const ubvector &get_y_bins() const {
495  return ya;
496  }
497 
498  /// Return the histogram size of the x coordinate
499  size_t size_x() const {
500  return hsize_x;
501  }
502 
503  /// Return the histogram size of the y coordinate
504  size_t size_y() const {
505  return hsize_y;
506  }
507 
508  /** \brief Get a reference to the user-specified reps for x coordinates
509 
510  This function will call the error handler if the x-axis
511  representative mode is not \ref hist::rmode_user .
512 
513  \warning This vector reference is only valid so long as
514  the representative mode is unchanged and the function
515  clear() is not called.
516 
517  This member function is used by the \o2 HDF I/O functions.
518  */
519  const ubvector &get_user_reps_x() const {
520  if (xrmode!=rmode_user) {
521  O2SCL_ERR("Not user mode in hist::get_user_reps_x().",
522  exc_efailed);
523  }
524  return user_xrep;
525  }
526 
527  /** \brief Get a reference to the user-specified reps for y coordinates
528 
529  This function will call the error handler if the y-axis
530  representative mode is not \ref hist::rmode_user .
531 
532  \warning This vector reference is only valid so long as
533  the representative mode is unchanged and the function
534  clear() is not called.
535 
536  This member function is used by the \o2 HDF I/O functions.
537  */
538  const ubvector &get_user_reps_y() const {
539  if (yrmode!=rmode_user) {
540  O2SCL_ERR("Not user mode in hist::get_user_reps_y().",
541  exc_efailed);
542  }
543  return user_yrep;
544  }
545 
546  /** \brief Return the rep of bin of index \c i
547 
548  Note that this function returns a value and not a reference.
549  This is because we can't return a reference to the internally
550  computed representatives, since they don't always exist.
551  */
552  double get_x_rep_i(size_t i);
553 
554  /** \brief Return the rep of bin of index \c j
555 
556  Note that this function returns a value and not a reference.
557  This is because we can't return a reference to the internally
558  computed representatives, since they don't always exist.
559  */
560  double get_y_rep_i(size_t j);
561  //@}
562 
563  /* \brief Set up a twod_intp object for interpolation
564 
565  \future This is commented out for now. The \ref twod_intp
566  object stores a reference to xrep and yrep, and thus
567  can't be used since xrep and yrep don't always exist.
568  */
569  //void setup_interp(twod_intp &ti, bool x_first=true) {
570  //ti.set_data(hsize_x,hsize_y,xrep,yrep,wgt,x_first);
571  //return;
572  //}
573 
574  /// Internal consistency check
575  void is_valid() const;
576 
577  /** \brief Create a table3d object based on the histogram data
578  */
579  void copy_to_table3d(table3d &t, std::string xreps_name,
580  std::string yreps_name, std::string weights);
581 
582  friend void o2scl_hdf::hdf_output(o2scl_hdf::hdf_file &hf,
583  o2scl::hist_2d &h, std::string name);
584  friend void o2scl_hdf::hdf_input(o2scl_hdf::hdf_file &hf,
585  o2scl::hist_2d &h, std::string name);
586 
587  };
588 
589 #ifndef DOXYGEN_NO_O2NS
590 }
591 #endif
592 
593 #endif
boost::numeric::ublas::matrix< double >
o2scl::hist_2d::copy_to_table3d
void copy_to_table3d(table3d &t, std::string xreps_name, std::string yreps_name, std::string weights)
Create a table3d object based on the histogram data.
o2scl::table
Data table table class.
Definition: table.h:49
o2scl::table::get_nlines
size_t get_nlines() const
Return the number of lines.
Definition: table.h:460
o2scl::hist_2d::from_table
void from_table(o2scl::table<> &t, std::string colx, std::string coly, size_t n_bins_x, size_t n_bins_y)
Create a 2D histogram object from a table.
Definition: hist_2d.h:245
o2scl::hist_2d::get_wgt
double & get_wgt(double x, double y)
Return contents of bin for x.
Definition: hist_2d.h:341
o2scl::hist_2d::xrmode
size_t xrmode
Rep mode for x.
Definition: hist_2d.h:140
boost::numeric::ublas::vector< double >
o2scl::hist_2d::get_y_bins
const ubvector & get_y_bins() const
Get a reference to the full vector of bin specifications.
Definition: hist_2d.h:494
o2scl::hist_2d::integ_wgts
double integ_wgts()
Return the integral under the histogram.
o2scl::exc_efailed
@ exc_efailed
generic failure
Definition: err_hnd.h:61
o2scl::hist_2d::get_x_high_i
double & get_x_high_i(size_t i)
Get the upper edge of bin of index i.
O2SCL_ERR2
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
Definition: err_hnd.h:281
o2scl::hist_2d::get_wgts
const ubmatrix & get_wgts() const
Get a const reference to the full matrix of data.
Definition: hist_2d.h:359
o2scl::hist_2d::set_y_reps
void set_y_reps(size_t ny, vec_t &vy)
Set the representative y-values for each bin.
Definition: hist_2d.h:462
o2scl::hist_2d::sum_wgts
double sum_wgts()
Return the sum of all of the weights.
o2scl
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
Definition: anneal.h:42
o2scl::hist_2d::set_x_reps
void set_x_reps(size_t nx, vec_t &vx)
Set the representative x-values for each bin.
Definition: hist_2d.h:448
o2scl::hist_2d::set_reps_auto
void set_reps_auto()
An internal function to automatically set xrep and yrep.
o2scl::hist_2d::is_valid
void is_valid() const
Internal consistency check.
o2scl::hist_2d::xa
ubvector xa
Bin locations (Nx+1)
Definition: hist_2d.h:113
o2scl::hist_2d::get_x_rep_mode
size_t get_x_rep_mode() const
Get mode used to compute bin reps.
Definition: hist_2d.h:479
o2scl::vector_minmax_value
void vector_minmax_value(size_t n, vec_t &data, data_t &min, data_t &max)
Compute the minimum and maximum of the first n elements of a vector.
Definition: vector.h:1272
o2scl_hdf::hdf_input
void hdf_input(hdf_file &hf, o2scl::table< vec_t > &t, std::string name)
Input a o2scl::table object from a hdf_file.
Definition: hdf_io.h:148
o2scl::hist_2d::set_wgt_i
void set_wgt_i(size_t i, size_t j, double val)
Set contents of bin at (i,j) to value val.
o2scl::hist_2d::get_user_reps_y
const ubvector & get_user_reps_y() const
Get a reference to the user-specified reps for y coordinates.
Definition: hist_2d.h:538
o2scl::hist_2d::get_wgt_i
const double & get_wgt_i(size_t i, size_t j) const
Return contents of bin at (i,j)
o2scl::hist_2d::yrep
ubvector yrep
"Central" values for y-axis (N)
Definition: hist_2d.h:125
o2scl::hist_2d::set_bin_edges
void set_bin_edges(uniform_grid< double > gx, uniform_grid< double > gy)
Set the bins from two uniform_grid objects.
o2scl::hist_2d::operator=
hist_2d & operator=(const hist_2d &h)
Copy from operator=()
o2scl::hist_2d::clear
void clear()
Clear the entire histogram.
o2scl::hist_2d::clear_wgts
void clear_wgts()
Clear the data, but leave the bins as is.
o2scl::hist_2d::ya
ubvector ya
Bin locations (Ny+1)
Definition: hist_2d.h:116
o2scl::exc_einval
@ exc_einval
invalid argument supplied by user
Definition: err_hnd.h:59
o2scl::hist_2d::update
void update(double x, double y, double val=1.0)
Increment bin for x by value val.
Definition: hist_2d.h:320
o2scl::hist_2d::size_y
size_t size_y() const
Return the histogram size of the y coordinate.
Definition: hist_2d.h:504
o2scl::uniform_grid_end
Linear grid with fixed number of bins and fixed endpoint.
Definition: uniform_grid.h:333
o2scl::hist_2d::get_wgt
const double & get_wgt(double x, double y) const
Return contents of bin for x.
Definition: hist_2d.h:331
o2scl_hdf
The O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl namespace ...
Definition: table.h:59
o2scl::hist_2d::get_bin_indices
void get_bin_indices(double x, double y, size_t &i, size_t &j) const
Get the index of the bin which holds x and the bin which holds y.
o2scl::hist_2d::yrmode
size_t yrmode
Rep mode for y.
Definition: hist_2d.h:143
o2scl::uniform_grid< double >
o2scl::hist_2d::set_rep_mode
void set_rep_mode(size_t x_mode, size_t y_mode)
Set mode used to compute bin reps.
o2scl::hist_2d::update_i
void update_i(size_t i, size_t j, double val=1.0)
Increment bin at (i,j) by value val.
Definition: hist_2d.h:314
o2scl::hist_2d::extend_lhs
bool extend_lhs
If true, allow abcissa smaller than smallest bin limit to correspond to the lowest bin (default false...
Definition: hist_2d.h:270
o2scl::hist_2d::wgt
ubmatrix wgt
Values (Nx,Ny)
Definition: hist_2d.h:119
o2scl::hist_2d::get_x_bins
const ubvector & get_x_bins() const
Get a reference to the full vector of bin specifications.
Definition: hist_2d.h:489
o2scl::hist_2d::get_wgts
ubmatrix & get_wgts()
Get a reference to the full matrix of data.
Definition: hist_2d.h:364
o2scl::hist_2d::set_bin_edges
void set_bin_edges(size_t nx, vec_t &vx, size_t ny, vec_t &vy)
Set the bins from a vector.
Definition: hist_2d.h:292
o2scl::hist_2d::get_x_low_i
double & get_x_low_i(size_t i)
Get the lower edge of bin of index i.
o2scl::table::get_column
const vec_t & get_column(std::string scol) const
Returns a reference to the column named col. .
Definition: table.h:672
o2scl::itos
std::string itos(int x)
Convert an integer to a string.
o2scl::hist_2d::get_y_rep_mode
size_t get_y_rep_mode() const
Get mode used to compute bin reps.
Definition: hist_2d.h:484
o2scl::hist_2d::get_user_reps_x
const ubvector & get_user_reps_x() const
Get a reference to the user-specified reps for x coordinates.
Definition: hist_2d.h:519
o2scl::hist_2d::get_y_bin_index
size_t get_y_bin_index(double y) const
Get the indey of the bin which holds y.
o2scl_hdf::hdf_file
Store data in an O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$sc...
Definition: hdf_file.h:105
o2scl::hist_2d::from_table
void from_table(o2scl::table<> &t, std::string colx, std::string coly, std::string colz, size_t n_bins_x, size_t n_bins_y)
Create a 2D histogram object from a table, obtaining weights from the third column.
Definition: hist_2d.h:255
o2scl::hist_2d::get_y_high_i
double & get_y_high_i(size_t j)
Get the upper edge of bin of index j.
O2SCL_ERR
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
Definition: err_hnd.h:273
o2scl::hist_2d::get_y_rep_i
double get_y_rep_i(size_t j)
Return the rep of bin of index j.
o2scl::hist_2d::get_y_low_i
double & get_y_low_i(size_t j)
Get the lower edge of bin of index j.
o2scl::hist_2d::user_yrep
ubvector user_yrep
User-defined central values for y-axis (N)
Definition: hist_2d.h:131
o2scl::hist_2d::size_x
size_t size_x() const
Return the histogram size of the x coordinate.
Definition: hist_2d.h:499
o2scl::hist_2d::get_x_rep_i
double get_x_rep_i(size_t i)
Return the rep of bin of index i.
o2scl::hist_2d::hsize_x
size_t hsize_x
Number of x-bins.
Definition: hist_2d.h:134
o2scl::hist_2d::set_wgt
void set_wgt(double x, double y, double val)
Set contents of bin for x to value val.
Definition: hist_2d.h:351
o2scl::hist_2d::allocate
void allocate(size_t nx, size_t ny)
Allocate for a histogram of size nx, ny.
o2scl::hist_2d::get_x_bin_index
size_t get_x_bin_index(double x) const
Get the index of the bin which holds x.
o2scl::hist_2d::extend_rhs
bool extend_rhs
If true, allow abcissa larger than largest bin limit to correspond to the highest bin (default false)...
Definition: hist_2d.h:265
o2scl::hist_2d::hsize_y
size_t hsize_y
Number of y-bins.
Definition: hist_2d.h:137
o2scl::hist_2d::set_reps
void set_reps(size_t nx, vec_t &vx, size_t ny, vec_t &vy)
Set the representative x-values for each bin.
Definition: hist_2d.h:428
o2scl::hist_2d::xrep
ubvector xrep
"Central" values for x-axis (N)
Definition: hist_2d.h:122
o2scl::table3d
A data structure containing one or more slices of two-dimensional data points defined on a grid.
Definition: table3d.h:78
o2scl::hist_2d::user_xrep
ubvector user_xrep
User-defined central values for x-axis (N)
Definition: hist_2d.h:128
o2scl::hist_2d
A two-dimensional histogram class.
Definition: hist_2d.h:103

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