Go to the documentation of this file.
23 #ifndef O2SCL_UNIFORM_GRID_H
24 #define O2SCL_UNIFORM_GRID_H
31 #include <boost/numeric/ublas/vector.hpp>
33 #include <o2scl/err_hnd.h>
34 #include <o2scl/string_conv.h>
50 #ifndef DOXYGEN_NO_O2NS
54 #ifdef O2SCL_NEVER_DEFINED
57 template<
class data_t>
class uniform_grid;
92 template<
class data_t=
double>
class uniform_grid {
96 friend void o2scl_hdf::hdf_output
135 O2SCL_ERR2(
"Requested grid with start==end in ",
140 if ((width<1.0 && start<end) ||
141 (width>1.0 && start>end)) {
142 O2SCL_ERR2(
"Incommensurate logarithmic grid in ",
145 }
else if (start<0.0) {
146 if ((width<1.0 && start>end) ||
147 (width>1.0 && start<end)) {
148 O2SCL_ERR2(
"Incommensurate logarithmic grid in ",
151 }
else if (start==0.0 || end==0.0) {
152 O2SCL_ERR2(
"Requested logarithmic grid with either ",
153 "start or end=0 in uniform_grid::uniform_grid().",
157 O2SCL_ERR2(
"Requested width 1 for logrithmic grid in ",
161 if ((width<0.0 && start<end) ||
162 (width>0.0 && start>end)) {
167 O2SCL_ERR2(
"Requested zero width for linear grid in ",
203 O2SCL_ERR(
"Grid not set in uniform_grid::get_npoints().",
215 O2SCL_ERR(
"Grid not set in uniform_grid::get_npoints().",
246 template<
class resize_vec_t>
void vector(resize_vec_t &v)
const {
249 O2SCL_ERR(
"Grid not set in uniform_grid::get_npoints().",
270 O2SCL_ERR(
"Grid not set in uniform_grid::get_npoints().",
274 #if !O2SCL_NO_RANGE_CHECK
278 " in uniform_grid::operator[].";
344 uniform_grid<data_t>(start,end,(end-start)/((data_t)n_bins),
362 uniform_grid<data_t>(start,start+n_bins*width,width,n_bins,false) {
380 ((size_t)((end-start)/width)),false) {
397 uniform_grid<data_t>(start,end,std::pow(end/start,1.0/((data_t)n_bins)),
415 uniform_grid<data_t>(start,start*std::pow(width,n_bins),
434 ((size_t)(log(end/start)/log(width))),true) {
438 #ifndef DOXYGEN_NO_O2NS
void hdf_output(hdf_file &hf, o2scl::uniform_grid< double > &t, std::string name)
Output a o2scl::uniform_grid object to a hdf_file.
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
void hdf_input(hdf_file &hf, o2scl::uniform_grid< double > &t, std::string name)
Input a o2scl::uniform_grid object from a hdf_file.
void hdf_input(hdf_file &hf, o2scl::table< vec_t > &t, std::string name)
Input a o2scl::table object from a hdf_file.
@ exc_einval
invalid argument supplied by user
The O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl namespace ...
@ exc_eindex
Invalid index for array or matrix.
Store data in an O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$sc...
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
std::string szttos(size_t x)
Convert a size_t to a string.
Documentation generated with Doxygen. Provided under the
GNU Free Documentation License (see License Information).