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 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().",
253 if (v.size()<g_n_bins+1) {
254 v.resize(g_n_bins+1);
257 for(
size_t i=0;i<g_n_bins+1;i++) {
270 O2SCL_ERR(
"Grid not set in uniform_grid::get_npoints().",
274 #if !O2SCL_NO_RANGE_CHECK 278 " in uniform_grid::operator[].";
285 if (i==0)
return g_start;
286 else if (i==g_n_bins)
return g_end;
287 return g_start+i*g_width;
290 if (i==0)
return g_start;
291 else if (i==g_n_bins)
return g_end;
292 return g_start*std::pow(g_width,((data_t)i));
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
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
invalid argument supplied by user
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
The O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl namespace ...
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
void hdf_output(hdf_file &hf, o2scl::uniform_grid< double > &t, std::string name)
Output a o2scl::uniform_grid object to a hdf_file.
Store data in an O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$sc...
Invalid index for array or matrix.
std::string szttos(size_t x)
Convert a size_t to a string.
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.