Robotran C Documentation
lut.h
Go to the documentation of this file.
1 
8 #ifndef lut_h
9 #define lut_h
10 /*--------------------*/
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 // -- Structures -- //
19 typedef struct MbsLut1D
20 {
21  int nx;
22  double *x;
23  double *y;
24  int id_x;
25 } MbsLut1D;
26 
29 typedef struct MbsLut2D
30 {
31  int nx;
32  int ny;
33  double *x;
34  double *y;
35  double **z;
36 } MbsLut2D;
37 
40 typedef struct MbsLutRes
41 {
42  int nq;
43  int nt;
44  double **tq;
45  int id_t;
46  int mode;
50 } MbsLutRes;
51 
52 // -- Structures -- //
55 typedef struct MbsLut1Dvec
56 {
57  int nx;
58  int n;
59  double *x;
60  double **mat;
61 } MbsLut1Dvec;
62 
65 typedef struct MbsLut2Dvec
66 {
67  int nx;
68  int ny;
69  int n;
70  double *x;
71  double *y;
72  double ***mat_output;
73 } MbsLut2Dvec;
74 
75 
103 MbsLut1Dvec* mbs_lut_1Dvec_alloc(int nx, int n);
104 
112 MbsLut2Dvec* mbs_lut_2Dvec_alloc(int nx,int ny, int n);
113 
114 
119 void mbs_lut_1D_free(MbsLut1D *lut);
124 void mbs_lut_2D_free(MbsLut2D *lut);
129 void mbs_lut_res_free(MbsLutRes *lut);
140 
141 
155 int mbs_lut_1D_interp(MbsLut1D *lut, double x, double* y);
156 
166 int mbs_lut_1D_compute(MbsLut1D *lut, double x, double *y);
167 
180 int mbs_lut_1D_step_by_step(MbsLut1D *lut, double x, double *y);
181 
188 double mbs_lut_2D_interp(MbsLut2D *lut, double x, double y);
197 int mbs_lut_res_interp(MbsLutRes *lut, double t, double *coord);
205 int mbs_lut_1Dvec_interp(MbsLut1Dvec *lut, double x, double *output);
206 
213 int mbs_lut_2Dvec_interp(MbsLut2Dvec *lut, double x, double y, double *output);
214 
215 #ifdef MATLAB_MEX_FILE
216 #include "matrix.h"
222 MbsLut1D* mbs_lut_1D_load_mxarray(const mxArray *LUT_1D_ptr);
228 MbsLut2D* mbs_lut_2D_load_mxarray(const mxArray *LUT_2D_ptr);
229 #endif
230 
231 
238 MbsLut1D* mbs_lut_1D_load_1vector(const double *LUT_1D_ptr, const int nx);
239 
247 MbsLut1D* mbs_lut_1D_load_2vectors(const double *x_ptr,const double *y_ptr,const int nx);
248 
249 
260 MbsLut1D* mbs_lut_1D_load_file(char* fileName);
271 MbsLut2D* mbs_lut_2D_load_file(char* fileName);
280 MbsLutRes* mbs_lut_res_load_file(char* fileName);
295 MbsLut1Dvec* mbs_lut_1Dvec_load_file(char* fileName);
296 
312 MbsLut2Dvec* mbs_lut_2Dvec_load_file(char* fileName);
313 
321 MbsLut1D* mbs_lut_1D_empty(int nx);
329 MbsLut2D* mbs_lut_2D_empty(int nx, int ny);
330 #ifdef __cplusplus
331 }
332 #endif
333 
334 #endif
MbsLutRes::tq
double ** tq
2D array containing the time (first column) and the corresponding coordinates value
Definition: lut.h:44
mbs_lut_res_free
void mbs_lut_res_free(MbsLutRes *lut)
Release memory used by 2D LUT structure.
Definition: lut.c:105
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.
Definition: lut.c:1173
mbs_lut_2Dvec_free
void mbs_lut_2Dvec_free(MbsLut2Dvec *lut)
Release memory used by 2Dvec LUT structure.
Definition: lut.c:126
MbsLut1Dvec::x
double * x
1D array containing the input values
Definition: lut.h:59
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.
Definition: lut.c:287
mbs_lut_res_free
void mbs_lut_res_free(MbsLutRes *lut)
Release memory used by 2D LUT structure.
Definition: lut.c:105
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.
Definition: lut.c:201
MbsLut2Dvec::y
double * y
1D array containing the second input values (starting at 0)
Definition: lut.h:71
mbs_lut_1D_alloc
MbsLut1D * mbs_lut_1D_alloc()
Allocate a 1D LUT (Look Up Table) structure.
Definition: lut.c:19
useful_functions.h
mbs_lut_1Dvec_free
void mbs_lut_1Dvec_free(MbsLut1Dvec *lut)
Release memory used by 1Dvec LUT structure.
Definition: lut.c:115
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.
Definition: lut.c:287
mbs_lut_2D_free
void mbs_lut_2D_free(MbsLut2D *lut)
Release memory used by 2D LUT structure.
Definition: lut.c:91
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...
Definition: lut.c:442
MbsLut2D::z
double ** z
2D array containing the output to be interpolate at each defined input values
Definition: lut.h:35
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.
Definition: lut.c:1173
mbs_lut_1Dvec_load_file
MbsLut1Dvec * mbs_lut_1Dvec_load_file(char *fileName)
Load a file and return a new allocated results LUT structure.
Definition: lut.c:935
mbs_lut_2Dvec_load_file
MbsLut2Dvec * mbs_lut_2Dvec_load_file(char *fileName)
Load a file and return a new allocated results LUT structure.
Definition: lut.c:1038
get_dvec_0
double * get_dvec_0(int l_v)
create (with memory allocation) a vector (length l_v) of doubles, starting at index 0
Definition: mbs_1D_array.c:880
_MBS_ERR_LOW_FILES
#define _MBS_ERR_LOW_FILES
Low Level error number Error during opening/writing files = -9.
Definition: mbs_errors_names.h:147
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.
Definition: lut.c:645
MbsLutRes::nt
int nt
number of time steps
Definition: lut.h:43
free_dmat_0
void free_dmat_0(double **mat)
release memory for a matrix of doubles, starting at index 0
Definition: mbs_matrix.c:293
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.
Definition: lut.c:1160
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.
Definition: lut.c:645
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...
Definition: lut.c:442
MbsLut1D::y
double * y
1D array containing the output to be interpolate at each defined input values.
Definition: lut.h:23
MbsLut1Dvec
Structure for interpolate a vector (entry by entry) from one input.
Definition: lut.h:55
MbsLut2D::ny
int ny
number of element in the array of the second input
Definition: lut.h:32
MbsLut1D::x
double * x
1D array containing the input values.
Definition: lut.h:22
_MBS_ERR_LOW_NAN
#define _MBS_ERR_LOW_NAN
Low Level error number Number is NaN (not a number) = -7.
Definition: mbs_errors_names.h:142
MbsLut2Dvec
Structure for interpolate a variable from two inputs.
Definition: lut.h:65
mbs_1D_array.h
MbsLut2D::y
double * y
1D array containing the second input values
Definition: lut.h:34
mbs_lut_1Dvec_free
void mbs_lut_1Dvec_free(MbsLut1Dvec *lut)
Release memory used by 1Dvec LUT structure.
Definition: lut.c:115
get_dmat_0
double ** get_dmat_0(int nb_r, int nb_c)
create (with memory allocation) a [nb_r times nb_c] matrix of doubles, starting at index 0
Definition: mbs_matrix.c:238
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.
Definition: lut.c:567
MbsLutRes::nq
int nq
number coordinates
Definition: lut.h:42
MbsLut1Dvec::nx
int nx
number of element in the array
Definition: lut.h:57
mbs_lut_res_load_file
MbsLutRes * mbs_lut_res_load_file(char *fileName)
Load a file and return a new allocated results LUT structure.
Definition: lut.c:827
mbs_lut_2D_alloc
MbsLut2D * mbs_lut_2D_alloc()
Allocate a 2D LUT (Look Up Table) structure.
Definition: lut.c:27
read_files.h
Declare reading text file related functions.
mbs_msg
void mbs_msg(char *msg,...)
Send a message.
Definition: mbs_message.c:76
free_d3Darray_0
void free_d3Darray_0(double ***array3D)
release memory for a 3D array of doubles, starting at index 0
Definition: useful_functions.c:252
get_file_nb_lines_col
int get_file_nb_lines_col(FILE *fp, int *n_line, int *max_width)
Return the number of line and the max line width in remainder of the file.
Definition: read_files.c:32
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).
Definition: lut.c:375
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....
Definition: lut.c:139
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.
Definition: lut.c:611
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....
Definition: lut.c:217
MbsLut2Dvec::n
int n
size of the vectors to interpolate
Definition: lut.h:69
MbsLut2D::nx
int nx
number of element in the array of the first input
Definition: lut.h:31
free_dvec_1
void free_dvec_1(double *vec)
release memory for a vector of doubles, starting at index 1
Definition: mbs_1D_array.c:901
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.
Definition: lut.c:539
get_dinterval_binary_1
int get_dinterval_binary_1(double *array, int size, double value, int *index, int lim_check)
Find the index of the highest value in the array lower or equal than the value.
Definition: mbs_1D_array.c:205
mbs_lut_1D_load_file
MbsLut1D * mbs_lut_1D_load_file(char *fileName)
Load a file and return a new allocated 1D LUT structure.
Definition: lut.c:680
mbs_lut_2D_load_file
MbsLut2D * mbs_lut_2D_load_file(char *fileName)
Load a file and return a new allocated 2D LUT structure.
Definition: lut.c:764
mbs_lut_1Dvec_alloc
MbsLut1Dvec * mbs_lut_1Dvec_alloc(int nx, int n)
Allocate a 1Dvec LUT (Look Up Table) structure.
Definition: lut.c:54
mbs_lut_2D_alloc
MbsLut2D * mbs_lut_2D_alloc()
Allocate a 2D LUT (Look Up Table) structure.
Definition: lut.c:27
mbs_lut_2Dvec_alloc
MbsLut2Dvec * mbs_lut_2Dvec_alloc(int nx, int ny, int n)
Allocate a 1Dvec LUT (Look Up Table) structure.
Definition: lut.c:65
mbs_lut_1Dvec_load_file
MbsLut1Dvec * mbs_lut_1Dvec_load_file(char *fileName)
Load a file and return a new allocated results LUT structure.
Definition: lut.c:935
get_d3Darray_0
double *** get_d3Darray_0(int x, int y, int z)
create (with memory allocation) a [x times y times z] 3D array of doubles, starting at index 0
Definition: useful_functions.c:230
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.
Definition: lut.c:163
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.
Definition: lut.c:539
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....
Definition: lut.c:139
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.
Definition: lut.c:567
get_dinterval_binary_from_index_1
int get_dinterval_binary_from_index_1(double *array, int size, double value, int *index, int lim_check, int verbose)
Find the index of the highest value in the array lower or equal than the value.
Definition: mbs_1D_array.c:268
sort_dvec_0
void sort_dvec_0(double *vec_src, double *vec_dest, int l_v)
sort the first (l_v sized) vector of double into the second vector, starting with index 0
Definition: mbs_1D_array.c:652
find_dvec_0
int find_dvec_0(double *vec, int l_v, double f)
return the index of the value f in the (x sized) vector vec of doubles, starting with index 0....
Definition: mbs_1D_array.c:817
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.
Definition: lut.c:1160
mbs_lut_res_load_file
MbsLutRes * mbs_lut_res_load_file(char *fileName)
Load a file and return a new allocated results LUT structure.
Definition: lut.c:827
lut.h
Interpolation of value from array (Look Up Table) main header.
MbsLut2Dvec::nx
int nx
number of element in the array of the first input
Definition: lut.h:67
mbs_message.h
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.
Definition: lut.c:201
MbsLut2Dvec::x
double * x
1D array containing the first input values (starting at 0)
Definition: lut.h:70
MbsLut1Dvec::n
int n
size of the vector to interpolate
Definition: lut.h:58
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.
Definition: lut.c:611
MbsLutRes::id_t
int id_t
Last index used in the tq array.
Definition: lut.h:45
mbs_lut_2D_free
void mbs_lut_2D_free(MbsLut2D *lut)
Release memory used by 2D LUT structure.
Definition: lut.c:91
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.
Definition: lut.c:163
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....
Definition: lut.c:217
mbs_lut_res_alloc
MbsLutRes * mbs_lut_res_alloc()
Allocate a LUT (Look Up Table) structure for results files.
Definition: lut.c:41
mbs_lut_2Dvec_load_file
MbsLut2Dvec * mbs_lut_2Dvec_load_file(char *fileName)
Load a file and return a new allocated results LUT structure.
Definition: lut.c:1038
MbsLut2D::x
double * x
1D array containing the first input values
Definition: lut.h:33
MbsLut2Dvec::ny
int ny
number of element in the array of the second input
Definition: lut.h:68
MbsLut1D
Structure for interpolate a variable from one input.
Definition: lut.h:19
get_dvec_1
double * get_dvec_1(int l_v)
create (with memory allocation) a vector (length l_v) of doubles, starting at index 1
Definition: mbs_1D_array.c:885
MbsLut2D
Structure for interpolate a variable from two inputs.
Definition: lut.h:29
free_dmat_1
void free_dmat_1(double **mat)
release memory for a matrix of doubles, starting at index 1
Definition: mbs_matrix.c:301
copy_dvec_0
void copy_dvec_0(double *vec_src, double *vec_dest, int l_v)
Copy the content of a vector (of sizel_v) of doubles to a second vector, starting with index 0.
Definition: mbs_1D_array.c:906
free_dvec_0
void free_dvec_0(double *vec)
release memory for a vector of doubles, starting at index 0
Definition: mbs_1D_array.c:896
MbsLut1Dvec::mat
double ** mat
2D array containing the output vectors to be interpolate at each defined input values
Definition: lut.h:60
mbs_lut_1D_free
void mbs_lut_1D_free(MbsLut1D *lut)
Release memory used by 1D LUT structure.
Definition: lut.c:79
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).
Definition: lut.c:375
get_dmat_1
double ** get_dmat_1(int nb_r, int nb_c)
create (with memory allocation) a [nb_r times nb_c] matrix of doubles, starting at index 1
Definition: mbs_matrix.c:255
mbs_lut_1D_free
void mbs_lut_1D_free(MbsLut1D *lut)
Release memory used by 1D LUT structure.
Definition: lut.c:79
MbsLutRes::mode
int mode
Method to look for the correct interval:
Definition: lut.h:46
MbsLut1D::id_x
int id_x
Last index used in the x array.
Definition: lut.h:24
mbs_lut_1D_alloc
MbsLut1D * mbs_lut_1D_alloc()
Allocate a 1D LUT (Look Up Table) structure.
Definition: lut.c:19
read_dmat_0
int read_dmat_0(double **mat, int nb_r, int nb_c, const char *name)
read a [nb_r times nb_c] matrix of doubles from a file starting with index 0 and store the values in ...
Definition: mbs_matrix.c:495
mbs_lut_1D_load_file
MbsLut1D * mbs_lut_1D_load_file(char *fileName)
Load a file and return a new allocated 1D LUT structure.
Definition: lut.c:680
mbs_warning_msg
void mbs_warning_msg(char *msg,...)
Send a warning message.
Definition: mbs_message.c:89
mbs_lut_2D_load_file
MbsLut2D * mbs_lut_2D_load_file(char *fileName)
Load a file and return a new allocated 2D LUT structure.
Definition: lut.c:764
mbs_lut_1Dvec_alloc
MbsLut1Dvec * mbs_lut_1Dvec_alloc(int nx, int n)
Allocate a 1Dvec LUT (Look Up Table) structure.
Definition: lut.c:54
mbs_lut_res_alloc
MbsLutRes * mbs_lut_res_alloc()
Allocate a LUT (Look Up Table) structure for results files.
Definition: lut.c:41
MbsLutRes
Structure for interpolate the trajectories of coordinates.
Definition: lut.h:40
mbs_lut_2Dvec_alloc
MbsLut2Dvec * mbs_lut_2Dvec_alloc(int nx, int ny, int n)
Allocate a 1Dvec LUT (Look Up Table) structure.
Definition: lut.c:65
mbs_errors_names.h
MbsLut2Dvec::mat_output
double *** mat_output
2D array containing in each entry an output vector to be interpolate at each defined input values
Definition: lut.h:72
mbs_lut_2Dvec_free
void mbs_lut_2Dvec_free(MbsLut2Dvec *lut)
Release memory used by 2Dvec LUT structure.
Definition: lut.c:126
MbsLut1D::nx
int nx
number of element in the array.
Definition: lut.h:21