#include <tensor.h>
This tensor 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().
Definition at line 360 of file tensor.h.
Public Member Functions | |
tensor_grid () | |
Create an empty tensor with zero rank. | |
tensor_grid (size_t rank, size_t *dim) | |
Create a tensor of rank rank with sizes given in dim . | |
virtual int | set_vals (double *grdp, double val) |
Set the element closest to grid point grdp to value val . | |
virtual int | set_vals (double *grdp, double val, double *closest) |
Set the element closest to grid point grdp to value val . | |
virtual double | get_vals (double *grdp, double val) |
Get the element closest to grid point grdp to value val . | |
virtual double | get_vals (double *grdp, double val, double *closest) |
Get the element closest to grid point grdp to value val . | |
virtual int | set_grid (double **val) |
Set the grid. | |
virtual int | tensor_allocate (size_t rank, size_t *dim) |
Allocate space for a tensor of rank rank with sizes given in dim . | |
virtual int | tensor_free () |
Free allocated space (also sets rank to zero). | |
virtual size_t | lookup_grid (size_t i, double val) |
Lookup index for grid closest to val . | |
virtual double | get_grid (size_t i, size_t j) |
Lookup index for grid closest to val . | |
virtual int | lookup_grid (double *vals, size_t *indices) |
Lookup indices for grid closest to val . | |
virtual size_t | lookup_grid_val (size_t i, double val, double &val2) |
Lookup index for grid closest to val , returning the grid point. | |
virtual double | interpolate (double *vals) |
Interpolate values vals into the tensor, returning the result. | |
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. |
tensor_grid | ( | size_t | rank, | |
size_t * | dim | |||
) | [inline] |
virtual int set_grid | ( | double ** | val | ) | [inline, virtual] |
Set the grid.
The parameter grid
must define the grid, so that val
[i][j] is the jth grid point for the ith index. The size of array grid
[i] should be given by dim
[i] where dim
was the argument given in the constructor or to the function tensor_allocate().
virtual int tensor_allocate | ( | size_t | rank, | |
size_t * | dim | |||
) | [inline, virtual] |
Allocate space for a tensor of rank rank
with sizes given in dim
.
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 is left unmodified and no deallocation is performed.
Reimplemented from tensor.
virtual double interpolate | ( | double * | vals | ) | [inline, virtual] |
Interpolate values vals
into the tensor, returning the result.
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.
Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.
Project hosting provided by
,
O2scl Sourceforge Project Page