Robotran C Documentation
Classes | Functions
lut.h File Reference

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

MbsLut1Dmbs_lut_1D_alloc ()
 Allocate a 1D LUT (Look Up Table) structure. More...
 
MbsLut2Dmbs_lut_2D_alloc ()
 Allocate a 2D LUT (Look Up Table) structure. More...
 
MbsLutResmbs_lut_res_alloc ()
 Allocate a LUT (Look Up Table) structure for results files. More...
 
MbsLut1Dvecmbs_lut_1Dvec_alloc (int nx, int n)
 Allocate a 1Dvec LUT (Look Up Table) structure. More...
 
MbsLut2Dvecmbs_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...
 
MbsLut1Dmbs_lut_1D_load_mxarray (const mxArray *LUT_1D_ptr)
 Load an mxArray and return a new allocated 1D LUT structure. More...
 
MbsLut2Dmbs_lut_2D_load_mxarray (const mxArray *LUT_2D_ptr)
 Load an mxArray and return a new allocated 2D LUT structure. More...
 
MbsLut1Dmbs_lut_1D_load_1vector (const double *LUT_1D_ptr, const int nx)
 Load a vector and return a new allocated 1D LUT structure. More...
 
MbsLut1Dmbs_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...
 
MbsLut1Dmbs_lut_1D_load_file (char *fileName)
 Load a file and return a new allocated 1D LUT structure. More...
 
MbsLut2Dmbs_lut_2D_load_file (char *fileName)
 Load a file and return a new allocated 2D LUT structure. More...
 
MbsLutResmbs_lut_res_load_file (char *fileName)
 Load a file and return a new allocated results LUT structure. More...
 
MbsLut1Dvecmbs_lut_1Dvec_load_file (char *fileName)
 Load a file and return a new allocated results LUT structure. More...
 
MbsLut2Dvecmbs_lut_2Dvec_load_file (char *fileName)
 Load a file and return a new allocated results LUT structure. More...
 
MbsLut1Dmbs_lut_1D_empty (int nx)
 Allocate a look-up-table with of required space with datas set to null. More...
 
MbsLut2Dmbs_lut_2D_empty (int nx, int ny)
 Allocate a 2D LUT structure with of required space with datas set to null. More...
 

Detailed Description

Interpolation of value from array (Look Up Table) main header.

Author
Robotran team

Function Documentation

◆ mbs_lut_1D_alloc()

MbsLut1D* mbs_lut_1D_alloc ( )

Allocate a 1D LUT (Look Up Table) structure.

Returns
An allocated 1D LUT structure

◆ mbs_lut_1D_compute()

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.

Parameters
[in]lut1D LUT structure.
[in]xInput value at which the output has to be interpolated.
[out]yThe value of the output at the specified input value.
Returns
Error code, negative in case of division by zero

◆ mbs_lut_1D_empty()

MbsLut1D* mbs_lut_1D_empty ( int  nx)

Allocate a look-up-table with of required space with datas set to null.

Parameters
nxNumber of input data value
Returns
A new allocated 1D LUT structure without values in coordinates and values, or a NULL in case of failure.

◆ mbs_lut_1D_free()

void mbs_lut_1D_free ( MbsLut1D lut)

Release memory used by 1D LUT structure.

Parameters
[in,out]lut1D LUT structure to release memory

◆ mbs_lut_1D_interp()

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.

Parameters
[in,out]lut1D LUT structure lut::id_x will be modified (saving the last index) if the value x is in the range of the array.
[in]xInput value at which the output has to be interpolated.
[out]yThe value of the output at the specified input value.
Returns
Error code, negative in case of division by zero

◆ mbs_lut_1D_load_1vector()

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.

Parameters
[in]LUT_1D_ptr1D double array containing all the input values and then all the output values, the size is 2*nx
[in]nxNumber of input data value
Returns
A new allocated 1D LUT structure with the data of the array

◆ mbs_lut_1D_load_2vectors()

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.

Parameters
[in]x_ptr1D double array containing all the input values, the size is nx
[in]y_ptr1D double array containing all the output values, the size is nx
[in]nxNumber of input data value
Returns
A new allocated 1D LUT structure with the data of the arrays

◆ mbs_lut_1D_load_file()

MbsLut1D* mbs_lut_1D_load_file ( char *  fileName)

Load a file and return a new allocated 1D LUT structure.

Parameters
[in]fileNameName 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
Returns
A new allocated 1D LUT structure with the data of the file, or NULL in case of failure.

◆ mbs_lut_1D_load_mxarray()

MbsLut1D* mbs_lut_1D_load_mxarray ( const mxArray *  LUT_1D_ptr)

Load an mxArray and return a new allocated 1D LUT structure.

Parameters
[in]LUT_1D_ptrmxArray structure with an "x" field containing the input values and "y" field with the output values. Both are rows vectors, size = 1 x n
Returns
A new allocated 1D LUT structure with the data from mxArray

◆ mbs_lut_1D_step_by_step()

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.

Parameters
[in]lut1D LUT structure.
[in]xInput value at which the output has to be interpolated.
[out]yThe value of the output at the specified input value.
Returns
Error code, negative value are errors: -1: division by zero occurs in evaluation -2: coordinate x lower than input array minimum value -3: coordinate x higher than input array maximum value

◆ mbs_lut_1Dvec_alloc()

MbsLut1Dvec* mbs_lut_1Dvec_alloc ( int  nx,
int  n 
)

Allocate a 1Dvec LUT (Look Up Table) structure.

Parameters
[in]nxnumber of elements to interpolate.
[in]nsize of the vector elements to interpolate.
Returns
An allocated 1Dvec LUT structure

◆ mbs_lut_1Dvec_free()

void mbs_lut_1Dvec_free ( MbsLut1Dvec lut)

Release memory used by 1Dvec LUT structure.

Parameters
[in,out]lut1Dvec LUT structure to release memory

◆ mbs_lut_1Dvec_interp()

int mbs_lut_1Dvec_interp ( MbsLut1Dvec lut,
double  x,
double *  output 
)

Interpolate the output from a 1Dvec Look Up Table (extrapolation is allowed).

Parameters
[in]lut1Dvec LUT structure
[in]xInput value at which the output has to be interpolated
[out]outputThe value of the output at the specified input value
Returns
1 if time is found in results file, 2 if the coordinates are interpolated, negative number if error !

◆ mbs_lut_1Dvec_load_file()

MbsLut1Dvec* mbs_lut_1Dvec_load_file ( char *  fileName)

Load a file and return a new allocated results LUT structure.

    | ------------------------------------
    | ------------------------------------
    | ------------------------------------
    | ------------------------------------
    | ------------------------------------
Parameters
[in]fileNameName of the file containing the results to load.
The first column contains the x "input" vector.
The other columns contain the "output" vectors.
Returns
A new allocated 1Dvec LUT structure with the data of the file, or NULL in case of failure.

◆ mbs_lut_2D_alloc()

MbsLut2D* mbs_lut_2D_alloc ( )

Allocate a 2D LUT (Look Up Table) structure.

Default values are set, sizes are 0, pointers are NULL.

Returns
An allocated 2D LUT structure

◆ mbs_lut_2D_empty()

MbsLut2D* mbs_lut_2D_empty ( int  nx,
int  ny 
)

Allocate a 2D LUT structure with of required space with datas set to null.

Parameters
nxNumber of input data value along the first dimension.
nyNumber of input data value along the second dimension.
Returns
An allocated 2D LUT structure

◆ mbs_lut_2D_free()

void mbs_lut_2D_free ( MbsLut2D lut)

Release memory used by 2D LUT structure.

Parameters
[in,out]lut2D LUT structure to release memory

◆ mbs_lut_2D_interp()

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.

Parameters
[in]lut2D LUT structure
[in]x,yThe couple of input values at which the output has to be interpolated
Returns
The value of the output at the specified input value

◆ mbs_lut_2D_load_file()

MbsLut2D* mbs_lut_2D_load_file ( char *  fileName)

Load a file and return a new allocated 2D LUT structure.

Parameters
[in]fileNameName 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)
Returns
A new allocated 2D LUT structure with the data of the file, or NULL in case of failure.

◆ mbs_lut_2D_load_mxarray()

MbsLut2D* mbs_lut_2D_load_mxarray ( const mxArray *  LUT_2D_ptr)

Load an mxArray and return a new allocated 2D LUT structure.

Parameters
[in]LUT_2D_ptrmxArray 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.
Returns
A new allocated 2D LUT structure with the data from mxArray

◆ mbs_lut_2Dvec_alloc()

MbsLut2Dvec* mbs_lut_2Dvec_alloc ( int  nx,
int  ny,
int  n 
)

Allocate a 1Dvec LUT (Look Up Table) structure.

Parameters
[in]nxnumber of elements in the array of the first input
[in]nxnumber of elements in the array of the second input
[in]nsize of the vector elements to interpolate
Returns
An allocated 1Dvec LUT structure

◆ mbs_lut_2Dvec_free()

void mbs_lut_2Dvec_free ( MbsLut2Dvec lut)

Release memory used by 2Dvec LUT structure.

Parameters
[in,out]lut2Dvec LUT structure to release memory

◆ mbs_lut_2Dvec_interp()

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).

Parameters
[in]lut2D LUT structure
[in]x,yThe couple of input values at which the output has to be interpolated
Returns
The value of the output at the specified input value

◆ mbs_lut_2Dvec_load_file()

MbsLut2Dvec* mbs_lut_2Dvec_load_file ( char *  fileName)

Load a file and return a new allocated results LUT structure.

    || ------------------------------------
    || ------------------------------------
    || ------------------------------------
    || ------------------------------------
    || ------------------------------------
Parameters
[in]fileNameName 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.
Returns
A new allocated 2Dvec LUT structure with the data of the file, or NULL in case of failure.

◆ mbs_lut_res_alloc()

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.

Returns
An allocated Result LUT structure.

◆ mbs_lut_res_free()

void mbs_lut_res_free ( MbsLutRes lut)

Release memory used by 2D LUT structure.

Parameters
[in,out]lut2D LUT structure to release memory

◆ mbs_lut_res_interp()

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.

Parameters
[in]lutResults LUT structure
[in]tThe time at which the output has to be interpolated
[out]coordThe array (allocated, first index is 1) to store the interpolated value
Returns
1 if time is found in results file, 2 if the coordinates are interpolated, negative number if error !

◆ mbs_lut_res_load_file()

MbsLutRes* mbs_lut_res_load_file ( char *  fileName)

Load a file and return a new allocated results LUT structure.

Parameters
[in]fileNameName of the file containing the results to load.
The first column contains the time.
The other columns contain the coordinate.
Returns
A new allocated results LUT structure with the data of the file, or NULL in case of failure.