![]() |
Object-oriented Scientific Computing Library: Version 0.910
|
A data structure containing many slices of two-dimensional data points defined on a grid. More...
#include <table3d.h>
Public Member Functions | |
table3d () | |
Create a new 3D table . | |
bool | is_size_set () const |
bool | is_xy_set () const |
virtual const char * | type () |
Return the type, "table3d" . | |
Initialization | |
template<class vec2_t > | |
int | set_xy (std::string x_name, size_t nx, const vec2_t &x, std::string y_name, size_t ny, const vec2_t &y) |
Initialize the x-y grid. | |
int | set_size (size_t nx, size_t ny) |
Initialize table size. | |
On-grid get and set methods | |
int | set (size_t ix, size_t iy, std::string name, double val) |
Set element in slice name at location ix,iy to value val . | |
int | set (size_t ix, size_t iy, size_t z, double val) |
Set element in slice of index z at location ix,iy to value val . | |
double & | get (size_t ix, size_t iy, std::string name) |
Get element in slice name at location ix,iy | |
const double & | get (size_t ix, size_t iy, std::string name) const |
Get element in slice name at location ix,iy (const version) | |
double & | get (size_t ix, size_t iy, size_t z) |
Get element in slice of index z at location ix,iy | |
const double & | get (size_t ix, size_t iy, size_t z) const |
Get element in slice of index z at location ix,iy (const version) | |
Off-grid get and set methods | |
These methods return the value of a slice on the grid point nearest to a user-specified location. For interpolation into a point off the grid, use table3d::interp(). | |
int | set_val (double x, double y, std::string name, double val) |
Set element in slice name at the nearest location to x,y to value val . | |
int | set_val (double x, double y, size_t z, double val) |
Set element in slice of index z at the nearest location to x,y to value val . | |
double & | get_val (double x, double y, std::string name) |
Get element in slice name at location closest to x,y | |
const double & | get_val (double x, double y, std::string name) const |
Get element in slice name at location closest to x,y | |
double & | get_val (double x, double y, size_t z) |
Get element in slice of index z at location closest to x,y | |
const double & | get_val (double x, double y, size_t z) const |
Get element in slice of index z at location closest to x,y | |
template<class vec_t > | |
int | set_slices (double x, double y, size_t nv, vec_t &vals) |
Set elements in the first nv slices at the nearest location to x,y to value val . | |
template<class vec_t > | |
int | get_slices (double x, double y, size_t nv, vec_t &v) |
Get the data for every slice at the nearest location to x,y | |
Off-grid get and set methods returning nearest point | |
int | set_val_ret (double &x, double &y, std::string name, double val) |
Set element in slice name at the nearest location to x,y to value val . | |
int | set_val_ret (double &x, double &y, size_t z, double val) |
Set element in slice of index z at the nearest location to x,y to value val . | |
double & | get_val_ret (double &x, double &y, std::string name) |
Get element in slice name at location closest to x,y , and also return the corresponding values of x and y . | |
const double & | get_val_ret (double &x, double &y, std::string name) const |
Get element in slice name at location closest to x,y , and also return the corresponding values of x and y . | |
double & | get_val_ret (double &x, double &y, size_t z) |
Get element in slice of index z at location closest to x,y , and also return the corresponding values of x and y . | |
const double & | get_val_ret (double &x, double &y, size_t z) const |
Get element in slice of index z at location closest to x,y , and also return the corresponding values of x and y . | |
template<class vec_t > | |
int | set_slices_ret (double &x, double &y, size_t nv, vec_t &vals) |
Set elements in the first nv slices at the nearest location to x,y to values vals . | |
template<class vec_t > | |
int | get_slices_ret (double &x, double &y, size_t nv, vec_t &vals) |
Get elements in the first nv slices at the nearest location to x,y to value val . | |
Grid information get and set methods | |
int | set_grid_x (size_t ix, double val) |
Set x grid point at index ix . | |
int | set_grid_y (size_t iy, double val) |
Set y grid point at index iy . | |
double | get_grid_x (size_t ix) |
Get x grid point at index ix . | |
double | get_grid_y (size_t iy) |
Get y grid point at index iy . | |
std::string | get_x_name () const |
Get the name of the x grid variable. | |
std::string | get_y_name () const |
Get the name of the y grid variable. | |
int | set_x_name (std::string name) |
Set the name of the x grid variable. | |
int | set_y_name (std::string name) |
Set the name of the y grid variable. | |
const ovector & | get_x_data () const |
Get a const reference to the full x grid. | |
const ovector & | get_y_data () const |
Get a const reference to the full y grid. | |
Size get methods | |
int | get_size (size_t &nx, size_t &ny) const |
Get the size of the slices. | |
int | get_nx () const |
Get the x size. | |
int | get_ny () const |
Get the y size. | |
int | get_nslices () const |
Get the number of slices. | |
Slice manipulation | |
int | line_of_names (std::string names) |
Create a set of new slices specified in the string names . | |
std::string | get_slice_name (size_t z) const |
Returns the name of slice with index z . | |
int | new_slice (std::string name) |
Add a new slice. | |
int | set_slice_all (std::string name, double val) |
Set all of the values in slice name to val . | |
int | lookup_slice (std::string name, size_t &ix) const |
Find the index for column named name . | |
bool | is_slice (std::string name, int &ix) |
Return true if slice is already present. | |
int | rename_slice (std::string olds, std::string news) |
Rename slice named olds to news . | |
int | copy_slice (std::string src, std::string dest) |
Make a new slice named dest which is a copy of the slice with name given in src . | |
int | init_slice (std::string scol, double val) |
Initialize all values of slice named scol to val . | |
const omatrix & | get_slice (std::string scol) const |
Return a constant reference to a slice. | |
const omatrix & | get_slice (size_t iz) const |
Return a constant reference to a slice. | |
omatrix & | get_slice (std::string scol) |
Return a constant reference to a slice. | |
omatrix & | get_slice (size_t iz) |
Return a constant reference to a slice. | |
const std::vector< omatrix > & | get_data () |
Return a constant reference to all the slice data. | |
Lookup and search methods | |
int | lookup_x (double val, size_t &ix) const |
Look for a value in the x grid. | |
int | lookup_y (double val, size_t &iy) const |
Look for a value in the y grid. | |
int | lookup (double val, std::string slice, size_t &ix, size_t &iy) const |
Look for a value in a specified slice. | |
Interpolation, differentiation, and integration | |
int | set_interp (base_interp_mgr< ovector_const_view > &b1, base_interp_mgr< ovector_const_subvector > &b2) |
Specify the base interpolation objects to use. | |
double | interp (double x, double y, std::string name) |
Interpolate x and y in slice named name . | |
double | deriv_x (double x, double y, std::string name) |
Interpolate the derivative of the data with respect to the x grid at point x and y in slice named name . | |
double | deriv_y (double x, double y, std::string name) |
Interpolate the derivative of the data with respect to the y grid at point x and y in slice named name . | |
double | deriv_xy (double x, double y, std::string name) |
Interpolate the mixed second derivative of the data at point x and y in slice named name . | |
double | integ_x (double x1, double x2, double y, std::string name) |
Interpolate the integral of the data respect to the x grid. | |
double | integ_y (double x, double y1, double y2, std::string name) |
Interpolate the integral of the data respect to the y grid. | |
template<class vec_t > | |
int | interp_slices (double x, double y, size_t nv, vec_t &v) |
Fill a vector of interpolated values from each slice at the point x,y | |
Extract 2-dimensional tables | |
int | extract_x (double x, table &t) |
Extract a table at a fixed x grid point. | |
int | extract_y (double y, table &t) |
Extract a table at a fixed y grid point. | |
Clear methods | |
int | zero_table () |
Zero the data entries but keep the slice names and grid. | |
void | clear_table () |
Clear the table and the slice names. | |
void | clear_data () |
Remove all of the data by setting the number of lines to zero. | |
Summary method | |
int | summary (std::ostream *out, int ncol=79) const |
Output a summary of the information stored. | |
Histogram-like functions | |
int | hist_update (double ix, double iy, std::string scol, double inc=1.0) |
Update a histogram entry. | |
double | hist_get (double ix, double iy, std::string scol) const |
Get a histogram entry. | |
int | hist_set (double ix, double iy, std::string scol, double value) |
Set a histogram entry. | |
Manipulating constants | |
virtual int | add_constant (std::string name, double val) |
Add a constant. | |
virtual int | remove_constant (std::string name) |
Remove a constant. | |
virtual int | set_constant (std::string name, double val) |
Add a constant. | |
virtual double | get_constant (std::string name) |
Get a constant. | |
virtual int | get_constant (size_t ix, std::string &name, double &val) const |
Get a constant by index. | |
virtual size_t | get_nconsts () const |
Get the number of constants. | |
Data Fields | |
Default interpolation objects | |
def_interp_mgr < ovector_const_view, cspline_interp > | dim1 |
def_interp_mgr < ovector_const_subvector, cspline_interp > | dim2 |
Protected Types | |
Iterator types | |
typedef std::map< std::string, size_t, string_comp > ::iterator | map_iter |
typedef std::map< std::string, size_t, string_comp > ::const_iterator | map_const_iter |
Protected Member Functions | |
Tree iterator boundaries | |
map_iter | begin () |
Return the beginning of the slice tree. | |
map_iter | end () |
Return the end of the slice tree. | |
map_const_iter | const_begin () const |
Return the beginning of the slice tree. | |
map_const_iter | const_end () const |
Return the end of the slice tree. | |
Protected Attributes | |
Interpolation data | |
base_interp_mgr < ovector_const_view > * | bimp1 |
The base interpolation object. | |
base_interp_mgr < ovector_const_subvector > * | bimp2 |
The subvector base interpolation object. | |
sm_interp_vec ** | si |
The array of sm_interp_vec pointers. | |
omatrix_col ** | aci |
Matrices for interpolation. | |
Data storage | |
std::map< std::string, double > | constants |
The list of constants. | |
size_t | numx |
The size of the x grid. | |
size_t | numy |
The size of the y grid. | |
std::map< std::string, size_t, string_comp > | tree |
A tree connecting column names to list indexes. | |
std::string | xname |
The name for the x grid. | |
std::string | yname |
The name for the y grid. | |
std::vector< omatrix > | list |
The pointers to the matrices. | |
ovector | xval |
The x grid. | |
ovector | yval |
The y grid. | |
bool | xy_set |
True if the grid has been set. | |
bool | size_set |
True if the size of the grid has been set. | |
bool | has_slice |
True if the table has at least one slice. |
int table3d::set_xy | ( | std::string | x_name, |
size_t | nx, | ||
const vec2_t & | x, | ||
std::string | y_name, | ||
size_t | ny, | ||
const vec2_t & | y | ||
) | [inline] |
This function will not allow you to redefine the grid when there is data in the table if a grid of a different size was already set from a previous call to either set_xy() or set_size(). However, you may freely redefine the grid after a call to clear_data() or clear_table(). You may change individual grid points at any time with set_grid_x() and set_grid_y().
int table3d::set_size | ( | size_t | nx, |
size_t | ny | ||
) |
This function will not allow you to resize the table if it already has data or if the size has already been set with the set_xy() function, unless you clear the data with clear_data() or the table with clear_table() first.
int table3d::rename_slice | ( | std::string | olds, |
std::string | news | ||
) |
This is slow since we have to delete the column and re-insert it. This process in turn mangles all of the iterators in the list.
const std::vector<omatrix>& table3d::get_data | ( | ) |
int table3d::extract_x | ( | double | x, |
table & | t | ||
) |
t
will be lost. int table3d::extract_y | ( | double | y, |
table & | t | ||
) |
t
will be lost. void table3d::clear_data | ( | ) |
This leaves the column names intact and does not remove the constants.
int table3d::summary | ( | std::ostream * | out, |
int | ncol = 79 |
||
) | const |
Outputs the number of constants, the grid information, and a list of the slice names
int table3d::hist_update | ( | double | ix, |
double | iy, | ||
std::string | scol, | ||
double | inc = 1.0 |
||
) |
Assuming that the histogram bins are given in column named ix_col
, this updates the histogram found in column scol
at index location ix
by incrementing it by an amount given in inc
.
double table3d::hist_get | ( | double | ix, |
double | iy, | ||
std::string | scol | ||
) | const |
Assuming that the histogram bins are given in column named ix_col
, this returns the histogram entry found in column scol
at index location ix
.
int table3d::hist_set | ( | double | ix, |
double | iy, | ||
std::string | scol, | ||
double | value | ||
) |
Assuming that the histogram bins are given in column named ix_col
, this sets the histogram entry found in column scol
at index location ix
to the value given in value
.
Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).