Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
o2scl::uniform_grid< data_t > Class Template Reference

A class representing a uniform linear or logarithmic grid. More...

#include <uniform_grid.h>

Inheritance diagram for o2scl::uniform_grid< data_t >:
o2scl::uniform_grid_end< data_t > o2scl::uniform_grid_end_width< data_t > o2scl::uniform_grid_log_end< data_t > o2scl::uniform_grid_log_end_width< data_t > o2scl::uniform_grid_log_width< data_t > o2scl::uniform_grid_width< data_t >

Public Member Functions

 uniform_grid ()
 Default constructor.
 
size_t get_nbins () const
 Get the number of bins (regions in between grid points) More...
 
size_t get_npoints () const
 Get the number of points in the grid (always get_nbins()+1) More...
 
bool is_log () const
 Return true if the grid is logarithmic. More...
 
template<class resize_vec_t >
void vector (resize_vec_t &v) const
 Fill a vector with the specified grid. More...
 
const data_t operator[] (size_t i) const
 Get the grid point with index i ( $ i \in [0,\mathrm{n_{bins}}] $)
 
 uniform_grid (const uniform_grid &ug)
 Copy constructor.
 
uniform_gridoperator= (const uniform_grid &ug)
 Copy from = operator.
 

Protected Member Functions

 uniform_grid (data_t start, data_t end, data_t width, size_t n_bins, bool log=false)
 Construct a grid with specified values. More...
 

Protected Attributes

data_t g_start
 The low-side of the first bin.
 
data_t g_end
 The high-side of the last bin.
 
data_t g_width
 The width of each bin. More...
 
size_t g_n_bins
 The number of bins.
 
bool g_log
 If true, use a logarithmic scale.
 

Friends

void o2scl_hdf::hdf_output (o2scl_hdf::hdf_file &hf, uniform_grid< double > &ug, std::string name)
 
void o2scl_hdf::hdf_input (o2scl_hdf::hdf_file &hf, uniform_grid< double > &ug, std::string name)
 

Detailed Description

template<class data_t = double>
class o2scl::uniform_grid< data_t >

Note
This class has no public constructors and is to be instantiated through its children.

This class should work for any floating-point type compatible with std::pow() .

Empty grids are those for which g_n_bins is zero.

The first and last bin are always exactly equal to the originally specified values of "start" and "end", but finite-precision errors may affect the inner grid points.

Idea for Future:
Implement operator==, etc?

Definition at line 38 of file uniform_grid.h.

Constructor & Destructor Documentation

◆ uniform_grid()

template<class data_t = double>
o2scl::uniform_grid< data_t >::uniform_grid ( data_t  start,
data_t  end,
data_t  width,
size_t  n_bins,
bool  log = false 
)
inlineprotected
Note
This function is not public because it might create grids that are non-sensical. We require users to create grid objects using one of the children which don't allow non-sensical grids.

Definition at line 126 of file uniform_grid.h.

Member Function Documentation

◆ get_nbins()

template<class data_t = double>
size_t o2scl::uniform_grid< data_t >::get_nbins ( ) const
inline

This function returns zero if the grid is "empty".

Definition at line 193 of file uniform_grid.h.

◆ get_npoints()

template<class data_t = double>
size_t o2scl::uniform_grid< data_t >::get_npoints ( ) const
inline

This function will throw an exception if the grid is empty.

Definition at line 201 of file uniform_grid.h.

◆ is_log()

template<class data_t = double>
bool o2scl::uniform_grid< data_t >::is_log ( ) const
inline

This function will throw an exception if the grid is empty.

Definition at line 213 of file uniform_grid.h.

◆ vector()

template<class data_t = double>
template<class resize_vec_t >
void o2scl::uniform_grid< data_t >::vector ( resize_vec_t &  v) const
inline

If the vector is not big enough to hold the grid, it is automatically resized.

This function will throw an exception if the grid is empty.

Definition at line 228 of file uniform_grid.h.

Member Data Documentation

◆ g_width

template<class data_t = double>
data_t o2scl::uniform_grid< data_t >::g_width
protected

This should be always positive and non-zero for linear grids and always greater than 1 for logarithmic grids.

Definition at line 113 of file uniform_grid.h.


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

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