Interpolation of value from array (Look Up Table) main header. More...
#include "matrix.h"
Go to the source code of this file.
Classes | |
struct | MbsLut1D |
Structure for interpolate a variable from one input. More... | |
struct | MbsLut2D |
Structure for interpolate a variable from two inputs. More... | |
struct | MbsLutRes |
Structure for interpolate the trajectories of coordinates. More... | |
struct | MbsLut1Dvec |
Structure for interpolate a vector (entry by entry) from one input. More... | |
struct | MbsLut2Dvec |
Structure for interpolate a variable from two inputs. More... | |
Functions | |
MbsLut1D * | mbs_lut_1D_alloc () |
Allocate a 1D LUT (Look Up Table) structure. More... | |
MbsLut2D * | mbs_lut_2D_alloc () |
Allocate a 2D LUT (Look Up Table) structure. More... | |
MbsLutRes * | mbs_lut_res_alloc () |
Allocate a LUT (Look Up Table) structure for results files. More... | |
MbsLut1Dvec * | mbs_lut_1Dvec_alloc (int nx, int n) |
Allocate a 1Dvec LUT (Look Up Table) structure. More... | |
MbsLut2Dvec * | mbs_lut_2Dvec_alloc (int nx, int ny, int n) |
Allocate a 1Dvec LUT (Look Up Table) structure. More... | |
void | mbs_lut_1D_free (MbsLut1D *lut) |
Release memory used by 1D LUT structure. More... | |
void | mbs_lut_2D_free (MbsLut2D *lut) |
Release memory used by 2D LUT structure. More... | |
void | mbs_lut_res_free (MbsLutRes *lut) |
Release memory used by 2D LUT structure. More... | |
void | mbs_lut_1Dvec_free (MbsLut1Dvec *lut) |
Release memory used by 1Dvec LUT structure. More... | |
void | mbs_lut_2Dvec_free (MbsLut2Dvec *lut) |
Release memory used by 2Dvec LUT structure. More... | |
int | mbs_lut_1D_interp (MbsLut1D *lut, double x, double *y) |
Interpolate the output from a 1D Look Up Table. If lut::id_x is put to zero, it computes the index. If lut::id_x is non zero, it evaluates the table at the specified coordinate using the last index (lut::id_x) to start binary search. More... | |
int | mbs_lut_1D_compute (MbsLut1D *lut, double x, double *y) |
Evaluate the table at the specified coordinate with the index stored in the structure. More... | |
int | mbs_lut_1D_step_by_step (MbsLut1D *lut, double x, double *y) |
Evaluate the table at the specified coordinate testing fro adjacent to adjacent interval. More... | |
double | mbs_lut_2D_interp (MbsLut2D *lut, double x, double y) |
Interpolate the output from a 2D Look Up Table for a specific couple of input value. If the input values are out of bound, the function performs an extrapolation. More... | |
int | mbs_lut_res_interp (MbsLutRes *lut, double t, double *coord) |
Interpolate the coordinates from a Results Look Up Table for a specific time value. More... | |
int | mbs_lut_1Dvec_interp (MbsLut1Dvec *lut, double x, double *output) |
Interpolate the output from a 1Dvec Look Up Table (extrapolation is allowed). More... | |
int | mbs_lut_2Dvec_interp (MbsLut2Dvec *lut, double x, double y, double *output) |
Interpolate the output from a 2D Look Up Table for a specific couple of input value (extrapolation is allowed). More... | |
MbsLut1D * | mbs_lut_1D_load_mxarray (const mxArray *LUT_1D_ptr) |
Load an mxArray and return a new allocated 1D LUT structure. More... | |
MbsLut2D * | mbs_lut_2D_load_mxarray (const mxArray *LUT_2D_ptr) |
Load an mxArray and return a new allocated 2D LUT structure. More... | |
MbsLut1D * | mbs_lut_1D_load_1vector (const double *LUT_1D_ptr, const int nx) |
Load a vector and return a new allocated 1D LUT structure. More... | |
MbsLut1D * | mbs_lut_1D_load_2vectors (const double *x_ptr, const double *y_ptr, const int nx) |
Load two vectors and return a new allocated 1D LUT structure. More... | |
MbsLut1D * | mbs_lut_1D_load_file (char *fileName) |
Load a file and return a new allocated 1D LUT structure. More... | |
MbsLut2D * | mbs_lut_2D_load_file (char *fileName) |
Load a file and return a new allocated 2D LUT structure. More... | |
MbsLutRes * | mbs_lut_res_load_file (char *fileName) |
Load a file and return a new allocated results LUT structure. More... | |
MbsLut1Dvec * | mbs_lut_1Dvec_load_file (char *fileName) |
Load a file and return a new allocated results LUT structure. More... | |
MbsLut2Dvec * | mbs_lut_2Dvec_load_file (char *fileName) |
Load a file and return a new allocated results LUT structure. More... | |
MbsLut1D * | mbs_lut_1D_empty (int nx) |
Allocate a look-up-table with of required space with datas set to null. More... | |
MbsLut2D * | mbs_lut_2D_empty (int nx, int ny) |
Allocate a 2D LUT structure with of required space with datas set to null. More... | |
Interpolation of value from array (Look Up Table) main header.
MbsLut1D* mbs_lut_1D_alloc | ( | ) |
Allocate a 1D LUT (Look Up Table) structure.
int mbs_lut_1D_compute | ( | MbsLut1D * | lut, |
double | x, | ||
double * | y | ||
) |
Evaluate the table at the specified coordinate with the index stored in the structure.
[in] | lut | 1D LUT structure. |
[in] | x | Input value at which the output has to be interpolated. |
[out] | y | The value of the output at the specified input value. |
MbsLut1D* mbs_lut_1D_empty | ( | int | nx | ) |
Allocate a look-up-table with of required space with datas set to null.
nx | Number of input data value |
void mbs_lut_1D_free | ( | MbsLut1D * | lut | ) |
Release memory used by 1D LUT structure.
[in,out] | lut | 1D LUT structure to release memory |
int mbs_lut_1D_interp | ( | MbsLut1D * | lut, |
double | x, | ||
double * | y | ||
) |
Interpolate the output from a 1D Look Up Table. If lut::id_x is put to zero, it computes the index. If lut::id_x is non zero, it evaluates the table at the specified coordinate using the last index (lut::id_x) to start binary search.
[in,out] | lut | 1D LUT structure lut::id_x will be modified (saving the last index) if the value x is in the range of the array. |
[in] | x | Input value at which the output has to be interpolated. |
[out] | y | The value of the output at the specified input value. |
MbsLut1D* mbs_lut_1D_load_1vector | ( | const double * | LUT_1D_ptr, |
const int | nx | ||
) |
Load a vector and return a new allocated 1D LUT structure.
[in] | LUT_1D_ptr | 1D double array containing all the input values and then all the output values, the size is 2*nx |
[in] | nx | Number of input data value |
MbsLut1D* mbs_lut_1D_load_2vectors | ( | const double * | x_ptr, |
const double * | y_ptr, | ||
const int | nx | ||
) |
Load two vectors and return a new allocated 1D LUT structure.
[in] | x_ptr | 1D double array containing all the input values, the size is nx |
[in] | y_ptr | 1D double array containing all the output values, the size is nx |
[in] | nx | Number of input data value |
MbsLut1D* mbs_lut_1D_load_file | ( | char * | fileName | ) |
Load a file and return a new allocated 1D LUT structure.
[in] | fileName | Name of the file containing the Look Up Table to load. The first line describe the contains of the file (first line is not read by the function). The second line contains the number of elements in the input x (nx). The third line contains the x input value The fourth line contains the y ouput value for each x input |
MbsLut1D* mbs_lut_1D_load_mxarray | ( | const mxArray * | LUT_1D_ptr | ) |
Load an mxArray and return a new allocated 1D LUT structure.
[in] | LUT_1D_ptr | mxArray structure with an "x" field containing the input values and "y" field with the output values. Both are rows vectors, size = 1 x n |
int mbs_lut_1D_step_by_step | ( | MbsLut1D * | lut, |
double | x, | ||
double * | y | ||
) |
Evaluate the table at the specified coordinate testing fro adjacent to adjacent interval.
[in] | lut | 1D LUT structure. |
[in] | x | Input value at which the output has to be interpolated. |
[out] | y | The value of the output at the specified input value. |
x
lower than input array minimum value -3: coordinate x
higher than input array maximum value MbsLut1Dvec* mbs_lut_1Dvec_alloc | ( | int | nx, |
int | n | ||
) |
Allocate a 1Dvec LUT (Look Up Table) structure.
[in] | nx | number of elements to interpolate. |
[in] | n | size of the vector elements to interpolate. |
void mbs_lut_1Dvec_free | ( | MbsLut1Dvec * | lut | ) |
Release memory used by 1Dvec LUT structure.
[in,out] | lut | 1Dvec LUT structure to release memory |
int mbs_lut_1Dvec_interp | ( | MbsLut1Dvec * | lut, |
double | x, | ||
double * | output | ||
) |
Interpolate the output from a 1Dvec Look Up Table (extrapolation is allowed).
[in] | lut | 1Dvec LUT structure |
[in] | x | Input value at which the output has to be interpolated |
[out] | output | The value of the output at the specified input value |
MbsLut1Dvec* mbs_lut_1Dvec_load_file | ( | char * | fileName | ) |
Load a file and return a new allocated results LUT structure.
| ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------ | ------------------------------------
[in] | fileName | Name of the file containing the results to load. The first column contains the x "input" vector. The other columns contain the "output" vectors. |
MbsLut2D* mbs_lut_2D_alloc | ( | ) |
Allocate a 2D LUT (Look Up Table) structure.
Default values are set, sizes are 0, pointers are NULL.
MbsLut2D* mbs_lut_2D_empty | ( | int | nx, |
int | ny | ||
) |
Allocate a 2D LUT structure with of required space with datas set to null.
nx | Number of input data value along the first dimension. |
ny | Number of input data value along the second dimension. |
void mbs_lut_2D_free | ( | MbsLut2D * | lut | ) |
Release memory used by 2D LUT structure.
[in,out] | lut | 2D LUT structure to release memory |
double mbs_lut_2D_interp | ( | MbsLut2D * | lut, |
double | x, | ||
double | y | ||
) |
Interpolate the output from a 2D Look Up Table for a specific couple of input value. If the input values are out of bound, the function performs an extrapolation.
[in] | lut | 2D LUT structure |
[in] | x,y | The couple of input values at which the output has to be interpolated |
MbsLut2D* mbs_lut_2D_load_file | ( | char * | fileName | ) |
Load a file and return a new allocated 2D LUT structure.
[in] | fileName | Name of the file containing the Look Up Table to load. The first line describe the contains of the file (first line is not read by the function). The second line contains the number of elements in the input x (nx) and then y (ny). The third line contains the y input value The fourth to (nx+4)th lines contains as first value the x input value and then the output values for each y input value (the size of each line is 1+ny) |
MbsLut2D* mbs_lut_2D_load_mxarray | ( | const mxArray * | LUT_2D_ptr | ) |
Load an mxArray and return a new allocated 2D LUT structure.
[in] | LUT_2D_ptr | mxArray structure with "x" and "y" fields containing the input values and "z" field with the output values. Inputs fields are rows vectors (size "x" = 1 x m and size "y" = 1 x n). Output field "z" is a 2D array of size m x n. |
MbsLut2Dvec* mbs_lut_2Dvec_alloc | ( | int | nx, |
int | ny, | ||
int | n | ||
) |
Allocate a 1Dvec LUT (Look Up Table) structure.
[in] | nx | number of elements in the array of the first input |
[in] | nx | number of elements in the array of the second input |
[in] | n | size of the vector elements to interpolate |
void mbs_lut_2Dvec_free | ( | MbsLut2Dvec * | lut | ) |
Release memory used by 2Dvec LUT structure.
[in,out] | lut | 2Dvec LUT structure to release memory |
int mbs_lut_2Dvec_interp | ( | MbsLut2Dvec * | lut, |
double | x, | ||
double | y, | ||
double * | output | ||
) |
Interpolate the output from a 2D Look Up Table for a specific couple of input value (extrapolation is allowed).
[in] | lut | 2D LUT structure |
[in] | x,y | The couple of input values at which the output has to be interpolated |
MbsLut2Dvec* mbs_lut_2Dvec_load_file | ( | char * | fileName | ) |
Load a file and return a new allocated results LUT structure.
|| ------------------------------------ || ------------------------------------ || ------------------------------------ || ------------------------------------ || ------------------------------------
[in] | fileName | Name of the file containing the results to load. The first column contains the x "input" vector. The second column contains the y"input" vector. The other columns contain the "output" vectors. |
MbsLutRes* mbs_lut_res_alloc | ( | ) |
Allocate a LUT (Look Up Table) structure for results files.
Default values are set, sizes are 0, pointers are NULL. The results files contain the trajectory of coordinates at specified timestep.
void mbs_lut_res_free | ( | MbsLutRes * | lut | ) |
Release memory used by 2D LUT structure.
[in,out] | lut | 2D LUT structure to release memory |
int mbs_lut_res_interp | ( | MbsLutRes * | lut, |
double | t, | ||
double * | coord | ||
) |
Interpolate the coordinates from a Results Look Up Table for a specific time value.
[in] | lut | Results LUT structure |
[in] | t | The time at which the output has to be interpolated |
[out] | coord | The array (allocated, first index is 1) to store the interpolated value |
MbsLutRes* mbs_lut_res_load_file | ( | char * | fileName | ) |
Load a file and return a new allocated results LUT structure.
[in] | fileName | Name of the file containing the results to load. The first column contains the time. The other columns contain the coordinate. |