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 
147 void mbs_lut_1D_print(MbsLut1D *lut, char *format);
148 
149 
163 int mbs_lut_1D_interp(MbsLut1D *lut, double x, double* y);
164 
174 int mbs_lut_1D_compute(MbsLut1D *lut, double x, double *y);
175 
188 int mbs_lut_1D_step_by_step(MbsLut1D *lut, double x, double *y);
189 
196 double mbs_lut_2D_interp(MbsLut2D *lut, double x, double y);
205 int mbs_lut_res_interp(MbsLutRes *lut, double t, double *coord);
213 int mbs_lut_1Dvec_interp(MbsLut1Dvec *lut, double x, double *output);
214 
221 int mbs_lut_2Dvec_interp(MbsLut2Dvec *lut, double x, double y, double *output);
222 
223 #ifdef MATLAB_MEX_FILE
224 #include "matrix.h"
230 MbsLut1D* mbs_lut_1D_load_mxarray(const mxArray *LUT_1D_ptr);
236 MbsLut2D* mbs_lut_2D_load_mxarray(const mxArray *LUT_2D_ptr);
237 #endif
238 
239 
246 MbsLut1D* mbs_lut_1D_load_1vector(const double *LUT_1D_ptr, const int nx);
247 
255 MbsLut1D* mbs_lut_1D_load_2vectors(const double *x_ptr,const double *y_ptr,const int nx);
256 
257 
268 MbsLut1D* mbs_lut_1D_load_file(char* fileName);
279 MbsLut2D* mbs_lut_2D_load_file(char* fileName);
288 MbsLutRes* mbs_lut_res_load_file(char* fileName);
303 MbsLut1Dvec* mbs_lut_1Dvec_load_file(char* fileName);
304 
320 MbsLut2Dvec* mbs_lut_2Dvec_load_file(char* fileName);
321 
329 MbsLut1D* mbs_lut_1D_empty(int nx);
337 MbsLut2D* mbs_lut_2D_empty(int nx, int ny);
338 #ifdef __cplusplus
339 }
340 #endif
341 
342 #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:108
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:1250
mbs_lut_2Dvec_free
void mbs_lut_2Dvec_free(MbsLut2Dvec *lut)
Release memory used by 2Dvec LUT structure.
Definition: lut.c:129
MbsLut1Dvec::x
double * x
1D array containing the input values
Definition: lut.h:59
mbs_msg
void mbs_msg(const char *msg,...)
Send a message.
Definition: mbs_message.c:87
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:364
mbs_lut_res_free
void mbs_lut_res_free(MbsLutRes *lut)
Release memory used by 2D LUT structure.
Definition: lut.c:108
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:278
MbsLut2Dvec::y
double * y
1D array containing the second input values (starting at 0)
Definition: lut.h:71
get_char_cpy
char * get_char_cpy(const char *fmt,...)
Copy the provided formatted string into a newly allocated memory.
Definition: useful_functions.c:196
mbs_lut_1D_alloc
MbsLut1D * mbs_lut_1D_alloc()
Allocate a 1D LUT (Look Up Table) structure.
Definition: lut.c:22
useful_functions.h
mbs_lut_1Dvec_free
void mbs_lut_1Dvec_free(MbsLut1Dvec *lut)
Release memory used by 1Dvec LUT structure.
Definition: lut.c:118
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:364
mbs_lut_2D_free
void mbs_lut_2D_free(MbsLut2D *lut)
Release memory used by 2D LUT structure.
Definition: lut.c:94
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:519
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:1250
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:1012
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:1115
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:955
_MBS_ERR_LOW_FILES
#define _MBS_ERR_LOW_FILES
Low Level error number Error during opening/writing files = -9.
Definition: mbs_errors_names.h:157
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:722
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:332
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:1237
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:722
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:519
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
mbs_warning_msg
void mbs_warning_msg(const char *msg,...)
Send a warning message.
Definition: mbs_message.c:100
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:147
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:118
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:277
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:644
MbsLutRes::nq
int nq
number coordinates
Definition: lut.h:42
MbsLut1Dvec::nx
int nx
number of element in the array
Definition: lut.h:57
MSG_PRE
#define MSG_PRE
Definition: lut.c:20
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:904
mbs_lut_2D_alloc
MbsLut2D * mbs_lut_2D_alloc()
Allocate a 2D LUT (Look Up Table) structure.
Definition: lut.c:30
read_files.h
Declare reading text file related functions.
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:379
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:452
MSG_ERR
#define MSG_ERR
Definition: lut.c:19
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:208
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:688
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:294
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:976
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:616
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:278
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:757
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:841
mbs_lut_1Dvec_alloc
MbsLut1Dvec * mbs_lut_1Dvec_alloc(int nx, int n)
Allocate a 1Dvec LUT (Look Up Table) structure.
Definition: lut.c:57
mbs_lut_2D_alloc
MbsLut2D * mbs_lut_2D_alloc()
Allocate a 2D LUT (Look Up Table) structure.
Definition: lut.c:30
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:68
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:1012
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:352
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:240
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:616
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:208
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:644
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:341
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:727
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:892
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:1237
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:904
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:278
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:688
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:94
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:240
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:294
mbs_lut_res_alloc
MbsLutRes * mbs_lut_res_alloc()
Allocate a LUT (Look Up Table) structure for results files.
Definition: lut.c:44
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:1115
mbs_lut_1D_print
void mbs_lut_1D_print(MbsLut1D *lut, char *format)
Print the content of the look-up table.
Definition: lut.c:142
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:960
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:340
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:981
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:971
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:82
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:452
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:294
mbs_lut_1D_print
void mbs_lut_1D_print(MbsLut1D *lut, char *format)
Print the content of the look-up table.
Definition: lut.c:142
mbs_lut_1D_free
void mbs_lut_1D_free(MbsLut1D *lut)
Release memory used by 1D LUT structure.
Definition: lut.c:82
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:22
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:537
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:757
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:841
mbs_lut_1Dvec_alloc
MbsLut1Dvec * mbs_lut_1Dvec_alloc(int nx, int n)
Allocate a 1Dvec LUT (Look Up Table) structure.
Definition: lut.c:57
mbs_lut_res_alloc
MbsLutRes * mbs_lut_res_alloc()
Allocate a LUT (Look Up Table) structure for results files.
Definition: lut.c:44
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:68
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:129
MbsLut1D::nx
int nx
number of element in the array.
Definition: lut.h:21