![]() |
Object-oriented Scientific Computing Library: Version 0.910
|
Tensor_Old class with arbitrary dimensions with a grid. More...
#include <tensor_old.h>
This tensor_old class allows one to assign the indexes to numerical scales, so that n-dimensional interpolation can be performed. To set the grid, use set_grid() and then interpolation can be done using interpolate().
By convention, member functions ending in the _val suffix return the closest grid-point to some user-specified values.
Definition at line 508 of file tensor_old.h.
Public Member Functions | |
tensor_old_grid () | |
Create an empty tensor_old with zero rank. | |
template<class uint_vec_t > | |
tensor_old_grid (size_t rank, const uint_vec_t &dim) | |
Create a tensor_old of rank rank with sizes given in dim . | |
Set functions | |
template<class vec_t > | |
int | set_val (const vec_t &grdp, double val) |
Set the element closest to grid point grdp to value val . | |
template<class vec_t , class vec2_t > | |
int | set_val (const vec_t &grdp, double val, vec2_t &closest) |
Set the element closest to grid point grdp to value val . | |
Get functions | |
template<class vec_t > | |
double | get_val (const vec_t &grdp) |
Get the element closest to grid point grdp . | |
template<class vec_t , class vec2_t > | |
double | get_val (const vec_t &grdp, const vec2_t &closest) |
Get the element closest to grid point grdp to value val . | |
Memory allocation | |
template<class uint_vec_t > | |
int | tensor_old_allocate (size_t rank, const uint_vec_t &dim) |
Allocate space for a tensor_old of rank rank with sizes given in dim . | |
int | tensor_old_free () |
Free allocated space (also sets rank to zero) | |
Grid manipulation | |
bool | is_grid_set () const |
Return true if the grid has been set. | |
template<class vec_t > | |
int | set_grid (const vec_t &grid) |
Set the grid. | |
int | set_grid_old (double **vals) |
size_t | lookup_grid (size_t i, double val) |
Lookup index for grid closest to val . | |
double | get_grid (size_t i, size_t j) const |
Lookup index for grid closest to val . | |
template<class vec_t , class uint_vec_t > | |
int | lookup_grid_vec (const vec_t &vals, const uint_vec_t &indices) const |
Lookup indices for grid closest point to vals . | |
size_t | lookup_grid_val (size_t i, double &val, double &val2) |
Lookup index for grid closest to val , returning the grid point. | |
Protected Attributes | |
double ** | grd |
A rank-sized set of arrays for the grid points. | |
bool | grid_set |
If true, the grid has been set by the user. | |
base_interp_mgr< double * > * | bim1 |
The interpolation manager. | |
base_interp_mgr < array_const_subvector > * | bim2 |
The subvector interpolation manager. | |
Interpolation | |
def_interp_mgr< double *, linear_interp > | dim1 |
def_interp_mgr < array_const_subvector, linear_interp > | dim2 |
int | set_interp (base_interp_mgr< double * > &bi1, base_interp_mgr< array_const_subvector > &bi2) |
Set interpolation managers. | |
double | interpolate (double *vals) |
Interpolate values vals into the tensor_old, returning the result. |
tensor_old_grid::tensor_old_grid | ( | size_t | rank, |
const uint_vec_t & | dim | ||
) | [inline] |
The parameter dim
must be a pointer to an array of sizes with length rank
. If the user requests any of the sizes to be zero, this constructor will call the error handler, create an empty tensor_old, and will allocate no memory.
Definition at line 546 of file tensor_old.h.
int tensor_old_grid::set_val | ( | const vec_t & | grdp, |
double | val, | ||
vec2_t & | closest | ||
) | [inline] |
The parameters closest
and grdp
may be identical, allowing one to update a vector grdp
with the closest grid point.
Definition at line 604 of file tensor_old.h.
int tensor_old_grid::tensor_old_allocate | ( | size_t | rank, |
const uint_vec_t & | dim | ||
) | [inline] |
The parameter dim
must be a pointer to an array of sizes with length rank
.
If memory was previously allocated, it will be freed before the new allocation and previously specified grid data will be lost.
If the user requests any of the sizes to be zero, this function will call the error handler and will allocate no memory. If memory was previously allocated, the tensor_old is left unmodified and no deallocation is performed.
Reimplemented from tensor_old.
Definition at line 696 of file tensor_old.h.
int tensor_old_grid::set_grid | ( | const vec_t & | grid | ) | [inline] |
The grid must be specified for all of the dimensions at once. Denote as the size of the first dimension,
as the size of the second dimesion, and so on. Then the first
entries in
grid
must be the grid for the first dimension, the next entries must be the grid for the second dimension, and so on. Thus
grid
must be a vector of size
Note that the grid is copied so the function argument may be destroyed by the user after calling set_grid() without affecting the tensor_old grid.
Definition at line 757 of file tensor_old.h.
int tensor_old_grid::lookup_grid_vec | ( | const vec_t & | vals, |
const uint_vec_t & | indices | ||
) | const [inline] |
The values in vals
are not modified by this function.
Definition at line 821 of file tensor_old.h.
double tensor_old_grid::interpolate | ( | double * | vals | ) | [inline] |
This is a quick and dirty implementation of n-dimensional interpolation by recursive application of the 1-dimensional routine from smart_interp_vec, using the base interpolation object specified in the template parameter base_interp_t
. This will be slow for sufficiently large data sets.
Definition at line 886 of file tensor_old.h.
Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).