23 #ifndef O2SCL_TENSOR_GRID_H 24 #define O2SCL_TENSOR_GRID_H 36 #include <gsl/gsl_matrix.h> 37 #include <gsl/gsl_ieee_utils.h> 39 #include <o2scl/err_hnd.h> 40 #include <o2scl/interp.h> 41 #include <o2scl/tensor.h> 42 #include <o2scl/table3d.h> 52 template<
class vec_t,
class vec_
size_t>
55 template<
class vec_t,
class vec_
size_t>
60 #ifndef DOXYGEN_NO_O2NS 64 typedef boost::numeric::ublas::range ub_range;
107 template<
class vec_t=std::vector<
double>,
108 class vec_
size_t=std::vector<
size_t> >
class tensor_grid :
109 public tensor<vec_t,vec_size_t> {
113 #ifndef DOXYGEN_INTERNAL 117 #ifdef O2SCL_NEVER_DEFINED 146 template<
class size_vec_t>
148 tensor<vec_t,vec_size_t>(rank,dim) {
152 for(
size_t i=0;i<this->rk;i++) {
154 O2SCL_ERR((((std::string)
"Requested zero size with non-zero ")+
155 "rank for index "+
szttos(i)+
" in tensor_grid::"+
156 "tensor_grid(size_t,size_vec_t)").c_str(),
168 template<
class vec2_t>
169 void set_val(
const vec2_t &grdp,
double val) {
172 vec_size_t index(this->rk);
173 for(
size_t i=0;i<this->rk;i++) {
174 index[i]=lookup_grid(i,grdp[i]);
179 for(
size_t i=1;i<this->rk;i++) {
197 template<
class vec2_t,
class vec3_t>
198 void set_val(
const vec2_t &grdp,
double val, vec3_t &closest) {
201 vec_size_t index(this->rk);
202 for(
size_t i=0;i<this->rk;i++) {
203 index[i]=lookup_grid_val(i,grdp[i],closest[i]);
208 for(
size_t i=1;i<this->rk;i++) {
223 template<
class vec2_t>
double get_val(
const vec2_t &gridp) {
226 vec_size_t index(this->rk);
227 for(
size_t i=0;i<this->rk;i++) {
228 index[i]=lookup_grid(i,gridp[i]);
233 for(
size_t i=1;i<this->rk;i++) {
239 return this->data[ix];
248 template<
class vec2_t,
class vec3_t>
249 double get_val(
const vec2_t &gridp, vec3_t &closest) {
252 vec_size_t index(this->rk);
253 for(
size_t i=0;i<this->rk;i++) {
254 index[i]=lookup_grid_val(i,gridp[i],closest[i]);
259 for(
size_t i=1;i<this->rk;i++) {
265 return this->data[ix];
281 template<
class size_vec2_t>
282 void resize(
size_t rank,
const size_vec2_t &dim) {
285 for(
size_t i=0;i<rank;i++) {
287 O2SCL_ERR((((std::string)
"Requested zero size with non-zero ")+
288 "rank for index "+
szttos(i)+
" in tensor_grid::"+
295 this->size.resize(this->rk);
302 this->data.resize(0);
306 for(
size_t i=0;i<this->rk;i++) {
307 this->size[i]=dim[i];
310 this->data.resize(tot);
343 template<
class vec2_t>
346 O2SCL_ERR2(
"Tried to set grid for empty tensor in ",
347 "tensor_grid::set_grid_packed().",
exc_einval);
350 for(
size_t i=0;i<this->rk;i++) ngrid+=this->size[i];
352 for(
size_t i=0;i<ngrid;i++) {
361 template<
class vec_vec_t>
364 O2SCL_ERR2(
"Tried to set grid for empty tensor in ",
368 for(
size_t i=0;i<this->rk;i++) ngrid+=this->size[i];
371 for(
size_t i=0;i<this->rk;i++) {
372 for(
size_t j=0;j<this->size[i];j++) {
373 grid[k]=grid_vecs[i][j];
386 template<
class rvec_t>
void copy_grid(
size_t i, rvec_t &v) {
387 v.resize(this->size[i]);
389 for(
size_t k=0;k<i;k++) istart+=this->size[k];
390 for(
size_t k=0;k<this->size[i];k++) {
399 O2SCL_ERR(
"Grid not set in tensor_grid::get_grid().",
404 " greater than or equal to rank, "+
szttos(this->rk)+
405 ", in tensor_grid::get_grid().").c_str(),
409 for(
size_t k=0;k<i;k++) istart+=this->size[k];
410 return grid[istart+j];
416 O2SCL_ERR(
"Grid not set in tensor_grid::get_grid().",
421 " greater than or equal to rank, "+
szttos(this->rk)+
422 ", in tensor_grid::get_grid().").c_str(),
426 for(
size_t k=0;k<i;k++) istart+=this->size[k];
434 O2SCL_ERR(
"Grid not set in tensor_grid::lookup_grid().",
439 " greater than or equal to rank, "+
szttos(this->rk)+
440 ", in tensor_grid::lookup_grid().").c_str(),
445 for(
size_t j=0;j<i;j++) {
446 istart+=this->size[j];
449 double min=fabs(grid[istart]-val);
450 for(
size_t j=istart;j<istart+this->size[i];j++) {
451 if (fabs(grid[j]-val)<min) {
453 min=fabs(grid[j]-val);
469 template<
class vec2_t,
class size_vec2_t>
471 for(
size_t k=0;k<this->rk;k++) {
472 indices[k]=lookup_grid(k,vals[k]);
486 " greater than or equal to rank, "+
szttos(this->rk)+
487 ", in tensor_grid::lookup_grid_val().").c_str(),
490 if (grid_set==
false) {
491 O2SCL_ERR(
"Grid not set in tensor_grid::lookup_grid_val().",
500 for(
size_t j=0;j<i;j++) istart+=this->size[j];
502 double min=fabs(grid[istart]-temp);
504 for(
size_t j=istart;j<istart+this->size[i];j++) {
505 if (fabs(grid[j]-temp)<min) {
507 min=fabs(grid[j]-temp);
517 O2SCL_ERR(
"Grid not set in tensor_grid::lookup_grid_packed().",
523 ", in tensor_grid::lookup_grid_packed().").c_str(),
527 for(
size_t j=0;j<i;j++) istart+=this->size[j];
529 double min=fabs(grid[istart]-val);
530 for(
size_t j=istart;j<istart+this->size[i];j++) {
531 if (fabs(grid[j]-val)<min) {
533 min=fabs(grid[j]-val);
542 O2SCL_ERR(
"Grid not set in tensor_grid::lookup_grid_packed().",
548 ", in tensor_grid::lookup_grid_packed().").c_str(),
552 for(
size_t j=0;j<i;j++) istart+=this->size[j];
554 double min=fabs(grid[istart]-val);
556 for(
size_t j=istart;j<istart+this->size[i];j++) {
557 if (fabs(grid[j]-val)<min) {
559 min=fabs(grid[j]-val);
598 template<
class size_vec2_t>
600 table3d &tab, std::string slice_name) {
602 if (ix_x>=this->rk || ix_y>=this->rk || ix_x==ix_y) {
603 O2SCL_ERR2(
"Either indices greater than rank or x and y ind",
604 "ices equal in tensor_grid::copy_slice_align().",
612 if (nx==0 && ny==0) {
615 std::vector<double> gx, gy;
616 for(
size_t i=0;i<this->size[ix_x];i++) {
617 gx.push_back(this->get_grid(ix_x,i));
619 for(
size_t i=0;i<this->size[ix_y];i++) {
620 gy.push_back(this->get_grid(ix_y,i));
624 tab.
set_xy(
"x",nx,gx,
"y",ny,gy);
628 if (nx!=this->size[ix_x] || ny!=this->size[ix_y]) {
630 "tensor_grid::copy_slice_align().",
exc_einval);
638 for(
size_t i=0;i<nx;i++) {
639 for(
size_t j=0;j<ny;j++) {
642 double val=this->
get(index);
643 tab.
set(i,j,slice_name,val);
670 template<
class size_vec2_t>
672 table3d &tab, std::string slice_name) {
674 if (ix_x>=this->rk || ix_y>=this->rk || ix_x==ix_y) {
675 O2SCL_ERR2(
"Either indices greater than rank or x and y ",
676 "indices equal in tensor_grid::copy_slice_interp().",
684 if (nx==0 && ny==0) {
686 return copy_slice_align(ix_x,ix_y,index,tab,slice_name);
690 std::vector<double> vals(this->rk);
691 for(
size_t i=0;i<this->rk;i++) {
692 if (i!=ix_x && i!=ix_y) vals[i]=this->get_grid(i,index[i]);
700 for(
size_t i=0;i<nx;i++) {
701 for(
size_t j=0;j<ny;j++) {
713 template<
class vec2_t>
716 std::string slice_name) {
718 if (ix_x>=this->rk || ix_y>=this->rk || ix_x==ix_y) {
719 O2SCL_ERR2(
"Either indices greater than rank or x and y ",
720 "indices equal in tensor_grid::copy_slice_interp().",
723 if (values.size()!=this->rk) {
725 "in tensor_grid::copy_slice_interp_values().",
743 for(
size_t i=0;i<nx;i++) {
744 for(
size_t j=0;j<ny;j++) {
800 template<
class range_t=ub_range,
801 class data_range_t=ubvector_range,
802 class index_range_t=ubvector_size_t_range>
809 interp_t si(this->size[0],grid,this->data,itype);
810 return si.eval(vals[0]);
816 for(
size_t i=1;i<this->rk;i++) ss*=this->size[i];
819 std::vector<vec_t> yvec(ss);
820 std::vector<interp_t *> si(ss);
821 for(
size_t i=0;i<ss;i++) {
822 yvec[i].resize(this->size[0]);
827 index_range_t size_new(this->size,ub_range(1,this->rk));
828 tdat.
resize(this->rk-1,size_new);
831 data_range_t grid_new(grid,ub_range(this->size[0],grid.size()));
835 vec_size_t co(this->rk);
836 for(
size_t i=0;i<this->rk;i++) co[i]=0;
844 for(
size_t i=0;i<this->size[0];i++) {
846 yvec[cnt][i]=this->
get(co);
849 si[cnt]=
new interp_t(this->size[0],grid,yvec[cnt],itype);
851 index_range_t co2(co,ub_range(1,this->rk));
852 tdat.
set(co2,si[cnt]->eval(vals[0]));
858 for(
int j=((
int)this->rk)-1;j>0;j--) {
859 if (co[j]>=this->size[j]) {
866 if (cnt==ss) done=
true;
874 for(
size_t i=0;i<ss;i++) {
904 std::vector<size_t> loc(this->rk);
905 std::vector<double> gnew;
906 for(
size_t i=0;i<this->rk;i++) {
907 std::vector<double> grid_unpacked(this->size[i]);
908 for(
size_t j=0;j<this->size[i];j++) {
909 grid_unpacked[j]=grid[j+rgs];
912 loc[i]=sv.
find(v[i]);
913 gnew.push_back(grid_unpacked[loc[i]]);
914 gnew.push_back(grid_unpacked[loc[i]+1]);
920 std::vector<size_t> snew(this->rk);
921 for(
size_t i=0;i<this->rk;i++) {
929 std::vector<size_t> index_new(this->rk), index_old(this->rk);
931 for(
size_t j=0;j<this->rk;j++) index_old[j]=index_new[j]+loc[j];
932 tnew.
set(index_new,this->
get(index_old));
950 template<
class vec2_
size_t>
954 return this->data[0]+(this->data[1]-this->data[0])/
955 (grid[1]-grid[0])*(v[0]-grid[0]);
958 size_t last=this->rk-1;
959 double frac=(v[last]-get_grid(last,0))/
960 (get_grid(last,1)-get_grid(last,0));
969 std::vector<size_t> index(this->rk);
972 double val_lo=this->
get(index);
974 double val_hi=this->
get(index);
975 tnew.
set(index,val_lo+frac*(val_hi-val_lo));
993 template<
class vec2_
size_t,
class vec2_t>
998 std::vector<size_t> loc(this->rk);
999 std::vector<double> gnew;
1000 for(
size_t i=0;i<this->size[0];i++) {
1001 gnew.push_back(grid[i]);
1005 for(
size_t i=1;i<this->rk;i++) {
1006 std::vector<double> grid_unpacked(this->size[i]);
1007 for(
size_t j=0;j<this->size[i];j++) {
1008 grid_unpacked[j]=grid[j+rgs];
1011 loc[i]=sv.
find(v[i]);
1012 gnew.push_back(grid_unpacked[loc[i]]);
1013 gnew.push_back(grid_unpacked[loc[i]+1]);
1019 std::vector<size_t> snew(this->rk);
1020 snew[0]=this->size[0];
1021 for(
size_t i=1;i<this->rk;i++) {
1029 std::vector<size_t> index_new(this->rk), index_old(this->rk);
1031 for(
size_t j=0;j<this->rk;j++) {
1032 index_old[j]=index_new[j]+loc[j];
1034 tnew.
set(index_new,this->
get(index_old));
1054 template<
class vec2_
size_t,
class vec2_t>
1058 size_t n=this->size[0];
1060 vec_size_t ix0(2), ix1(2);
1063 for(
size_t i=0;i<n;i++) {
1066 res[i]=this->
get(ix0)+(this->
get(ix1)-this->
get(ix0))/
1067 (grid[n+1]-grid[n])*(v[1]-grid[n]);
1072 size_t last=this->rk-1;
1073 double frac=(v[last]-get_grid(last,0))/
1074 (get_grid(last,1)-get_grid(last,0));
1083 std::vector<size_t> index(this->rk);
1085 index[this->rk-1]=0;
1086 double val_lo=this->
get(index);
1087 index[this->rk-1]=1;
1088 double val_hi=this->
get(index);
1089 tnew.
set(index,val_lo+frac*(val_hi-val_lo));
1108 template<
class vec2_
size_t,
class vec2_t>
1111 size_t n=this->size[ifree];
1115 std::vector<size_t> map;
1116 map.push_back(ifree);
1117 for(
size_t i=0;i<this->rk;i++) {
1125 vec_size_t loc(this->rk);
1127 for(
size_t i=0;i<this->rk;i++) {
1128 vec_t grid_unpacked(this->size[i]);
1129 for(
size_t j=0;j<this->size[i];j++) {
1130 grid_unpacked[j]=grid[j+rgs];
1134 loc[i]=sv.
find(v[i]);
1140 std::vector<double> gnew, vnew;
1141 for(
size_t new_ix=0;new_ix<this->rk;new_ix++) {
1142 for(
size_t old_ix=0;old_ix<this->rk;old_ix++) {
1143 if (map[new_ix]==old_ix) {
1144 vnew.push_back(v[old_ix]);
1145 if (old_ix==ifree) {
1146 for(
size_t j=0;j<this->size[old_ix];j++) {
1147 gnew.push_back(this->get_grid(old_ix,j));
1150 gnew.push_back(this->get_grid(old_ix,loc[old_ix]));
1151 gnew.push_back(this->get_grid(old_ix,loc[old_ix]+1));
1161 std::vector<size_t> snew;
1163 for(
size_t i=0;i<this->rk;i++) {
1175 std::vector<size_t> index_new(this->rk), index_old(this->rk);
1177 for(
size_t j=0;j<this->rk;j++) {
1178 index_old[map[j]]=index_new[j]+loc[map[j]];
1180 tnew.
set(index_new,this->
get(index_old));
1190 template<
class vecf_t,
class vecf_
size_t>
friend void o2scl_hdf::hdf_output
1204 template<
class vec_t=std::vector<
double>,
1218 this->data.resize(sz);
1219 this->grid_set=
false;
1222 #ifdef O2SCL_NEVER_DEFINED 1230 double &
get(
size_t ix1) {
1236 const double &
get(
size_t ix1)
const {
1242 void set(
size_t ix1,
double val) {
1248 template<
class range_t=ub_range,
class data_range_t=ubvector_range,
1249 class index_range_t=ubvector_size_t_range>
1252 <range_t,data_range_t,index_range_t>(&x);
1265 template<
class vec_t=std::vector<
double>,
1281 this->data.resize(tot);
1282 this->grid_set=
false;
1285 #ifdef O2SCL_NEVER_DEFINED 1293 double &
get(
size_t ix1,
size_t ix2) {
1294 size_t sz[2]={ix1,ix2};
1299 const double &
get(
size_t ix1,
size_t ix2)
const {
1300 size_t sz[2]={ix1,ix2};
1305 void set(
size_t ix1,
size_t ix2,
double val) {
1306 size_t sz[2]={ix1,ix2};
1312 template<
class range_t=ub_range,
class data_range_t=ubvector_range,
1313 class index_range_t=ubvector_size_t_range>
1315 double arr[2]={x,y};
1317 <range_t,data_range_t,index_range_t>(arr);
1322 double arr[2]={x,y};
1330 template<
class vec_t=std::vector<
double>,
1347 size_t tot=sz*sz2*sz3;
1348 this->data.resize(tot);
1349 this->grid_set=
false;
1352 #ifdef O2SCL_NEVER_DEFINED 1360 double &
get(
size_t ix1,
size_t ix2,
size_t ix3) {
1361 size_t sz[3]={ix1,ix2,ix3};
1366 const double &
get(
size_t ix1,
size_t ix2,
size_t ix3)
const {
1367 size_t sz[3]={ix1,ix2,ix3};
1372 void set(
size_t ix1,
size_t ix2,
size_t ix3,
double val) {
1373 size_t sz[3]={ix1,ix2, ix3};
1379 template<
class range_t=ub_range,
class data_range_t=ubvector_range,
1380 class index_range_t=ubvector_size_t_range>
1381 double interp(
double x,
double y,
double z) {
1382 double arr[3]={x,y,z};
1384 <range_t,data_range_t,index_range_t>(arr);
1389 double arr[3]={x,y,z};
1397 template<
class vec_t=std::vector<
double>,
1415 size_t tot=sz*sz2*sz3*sz4;
1416 this->data.resize(tot);
1417 this->grid_set=
false;
1420 #ifdef O2SCL_NEVER_DEFINED 1428 double &
get(
size_t ix1,
size_t ix2,
size_t ix3,
size_t ix4) {
1429 size_t sz[4]={ix1,ix2,ix3,ix4};
1434 const double &
get(
size_t ix1,
size_t ix2,
size_t ix3,
1436 size_t sz[4]={ix1,ix2,ix3,ix4};
1441 void set(
size_t ix1,
size_t ix2,
size_t ix3,
size_t ix4,
1443 size_t sz[4]={ix1,ix2,ix3,ix4};
1449 template<
class range_t=ub_range,
class data_range_t=ubvector_range,
1450 class index_range_t=ubvector_size_t_range>
1451 double interp(
double x,
double y,
double z,
double a) {
1452 double arr[4]={x,y,z,a};
1454 <range_t,data_range_t,index_range_t>(arr);
1459 double arr[4]={x,y,z,a};
1465 #ifndef DOXYGEN_NO_O2NS bool is_grid_set() const
Return true if the grid has been set.
Tensor class with arbitrary dimensions with a grid.
tensor_grid()
Create an empty tensor with zero rank.
void interp_linear_power_two_vec0(vec2_size_t &v, vec2_t &res)
Perform linear interpolation assuming that the last n-1 indices can take only two values...
The main O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl names...
Rank 1 tensor with a grid.
size_t lookup_grid_packed(size_t i, double val)
Lookup index for grid closest to val.
double interpolate(double *vals)
Interpolate values vals into the tensor, returning the result.
size_t lookup_grid_val(size_t i, const double &val, double &val2)
Lookup index for grid closest to val, returning the grid point.
size_t lookup_grid_packed_val(size_t i, double val, double &val2)
Lookup index for grid closest to val.
double get_grid_x(size_t ix)
Get x grid point at index ix.
size_t find(const double x0)
Search an increasing or decreasing vector for the interval containing x0
tensor_grid(size_t rank, const size_vec_t &dim)
Create a tensor of rank rank with sizes given in dim.
void set(const size_vec_t &index, double val)
Set the element indexed by index to value val.
invalid argument supplied by user
void unpack_indices(size_t ix, size_vec_t &index)
Unpack the single vector index into indices.
Rank 2 tensor with a grid.
double interp_linear(vec2_size_t &v)
Perform a linear interpolation of v into the function implied by the tensor and grid.
void resize(size_t rank, const size_vec2_t &dim)
Resize the tensor to rank rank with sizes given in dim.
void set_interp_type(size_t interp_type)
Set interpolation type for interpolate()
bool is_slice(std::string name, size_t &ix) const
Return true if slice is already present.
Rank 3 tensor with a grid.
size_t lookup_grid(size_t i, double val)
Lookup index for grid closest to val.
tensor_grid3(size_t sz, size_t sz2, size_t sz3)
Create a rank 3 tensor of size (sz,sz2,sz3)
double interp(double x)
Interpolate x and return the results.
vec_t & get_data()
Return a reference to the data (for HDF I/O)
void get_size(size_t &nx, size_t &ny) const
Get the size of the slices.
double interp(double x, double y, double z)
Interpolate (x,y,z) and return the results.
double get_grid(size_t i, size_t j) const
Lookup jth value on the ith grid.
double interp(double x, double y, double z, double a)
Interpolate (x,y,z,a) and return the results.
double interp_linear(double x, double y)
Interpolate (x,y) and return the results.
dat_t * vector_range(dat_t *v, size_t start, size_t last)
Vector range function for pointers.
tensor_grid2(size_t sz, size_t sz2)
Create a rank 2 tensor of size (sz,sz2)
double interp(double x, double y)
Interpolate (x,y) and return the results.
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
void copy_slice_align(size_t ix_x, size_t ix_y, size_vec2_t &index, table3d &tab, std::string slice_name)
Create a slice in a table3d object with an aligned grid.
The O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl namespace ...
tensor_grid4()
Create an empty tensor.
double interp_linear_power_two(vec2_size_t &v)
Perform linear interpolation assuming that all indices can take only two values.
Rank 4 tensor with a grid.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
void interp_linear_vec(vec2_size_t &v, size_t ifree, vec2_t &res)
Perform a linear interpolation of v into the tensor leaving one index free resulting in a vector...
void set_grid_packed(const vec2_t &grid_vec)
Set the grid.
void interp_linear_vec0(vec2_size_t &v, vec2_t &res)
Perform a linear interpolation of v[1] to v[n-1] resulting in a vector.
double get_val(const vec2_t &gridp, vec3_t &closest)
Get the element closest to grid point gridp, store grid values in closest and return value...
void set_grid(const vec_vec_t &grid_vecs)
Set grid from a vector of vectors of grid points.
void copy_grid(size_t i, rvec_t &v)
Copy grid for index i to vector v.
void set_grid(size_t i, size_t j, double val)
Set the jth value on the ith grid.
double interp_linear(double x, double y, double z, double a)
Interpolate (x,y,z,a) and return the results.
void clear()
Clear the tensor of all data and free allocated memory.
double get_val(const vec2_t &gridp)
Get the element closest to grid point gridp.
void set_val(const vec2_t &grdp, double val, vec3_t &closest)
Set the element closest to grid point grdp to value val.
double get_grid_y(size_t iy)
Get y grid point at index iy.
void copy_slice_interp_values(size_t ix_x, size_t ix_y, vec2_t &values, table3d &tab, std::string slice_name)
Copy to a slice in a table3d object using interpolation.
size_t total_size() const
Returns the size of the tensor (the product of the sizes over every index)
void set(size_t ix, size_t iy, std::string name, double val)
Set element in slice name at location ix,iy to value val.
Searching class for monotonic data with caching.
size_t itype
Interpolation type.
A data structure containing many slices of two-dimensional data points defined on a grid...
Store data in an O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$sc...
void new_slice(std::string name)
Add a new slice.
bool grid_set
If true, the grid has been set by the user.
double & get(const size_vec_t &index)
Get the element indexed by index.
tensor_grid2()
Create an empty tensor.
void copy_slice_interp(size_t ix_x, size_t ix_y, size_vec2_t &index, table3d &tab, std::string slice_name)
Copy to a slice in a table3d object using interpolation.
vec_t grid
A rank-sized set of arrays for the grid points.
tensor_grid4(size_t sz, size_t sz2, size_t sz3, size_t sz4)
Create a rank 4 tensor of size (sz,sz2,sz3,sz4)
void clear()
Clear the tensor of all data and free allocated memory.
void lookup_grid_vec(const vec2_t &vals, size_vec2_t &indices) const
Lookup indices for grid closest point to vals.
void set_val(const vec2_t &grdp, double val)
Set the element closest to grid point grdp to value val.
void set_xy(std::string x_name, size_t nx, const vec_t &x, std::string y_name, size_t ny, const vec2_t &y)
Initialize the x-y grid.
tensor_grid3()
Create an empty tensor.
Linear interpolation (GSL)
std::string szttos(size_t x)
Convert a size_t to a string.
void hdf_input(hdf_file &hf, o2scl::table< vec_t > &t, std::string name)
Input a o2scl::table object from a hdf_file.
tensor_grid1()
Create an empty tensor.
double interp_linear(double x)
Interpolate x and return the results.
tensor_grid1(size_t sz)
Create a rank 2 tensor of size (sz,sz2,sz3)
Tensor class with arbitrary dimensions.
double interp_linear(double x, double y, double z)
Interpolate (x,y,z) and return the results.