A class representing a uniform linear or logarithmic grid. More...
#include <uniform_grid.h>
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.
Definition at line 38 of file uniform_grid.h.
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... | |
double | get_start () |
Get the first grid point. | |
double | get_end () |
Get the last grid point. | |
double | get_width () |
Get the interval between grid points. | |
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 ( ![]() | |
uniform_grid (const uniform_grid &ug) | |
Copy constructor. | |
uniform_grid & | operator= (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) |
|
inlineprotected |
Definition at line 126 of file uniform_grid.h.
|
inline |
This function returns zero if the grid is "empty".
Definition at line 193 of file uniform_grid.h.
|
inline |
This function will throw an exception if the grid is empty.
Definition at line 201 of file uniform_grid.h.
|
inline |
This function will throw an exception if the grid is empty.
Definition at line 213 of file uniform_grid.h.
|
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 246 of file uniform_grid.h.
|
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.
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).