Robotran C Documentation
useful_functions.h
Go to the documentation of this file.
1 /*
2  * Main header of some useful functions
3  *
4  * authors: Nicolas Van der Noot & Aubain Verle
5  */
6 #ifndef _USEFUL_FUNCTIONS_H_
7 #define _USEFUL_FUNCTIONS_H_
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #define MIN(a,b) (((a)<(b))?(a):(b))
14 #define MAX(a,b) (((a)>(b))?(a):(b))
15 
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <math.h>
20 
21 #include "mbs_data.h"
22 #include "mbs_1D_array.h"
23 #include "mbs_matrix.h"
24 
25 #ifndef DBL_MAX
26 #define DBL_MAX 1.7976931348623158e+308
27 #endif
28 
33 void* mbs_free(void *__ptr);
34 
42 void mbs_log(char* msg, ...);
43 
44 
45 // exponents related functions
52 double pow_int(double basis, int expo);
53 
59 int expo_ten_inf(double nb);
60 
61 // sign function
67 double sign(double a);
68 
69 // time function
74 char* get_time_machine();
75 
76 // char related functions
82 char* get_char_vec(int l_v);
91 char** get_char_tab(int nb_r, int nb_c);
96 void free_char_vec(char *vec);
97 
107 char* get_char_cpy(const char *fmt, ...);
108 
113 void free_char_tab(char** mat);
114 
122 double*** get_d3Darray_0(int nb_r, int nb_c, int z);
123 
128 void free_d3Darray_0(double ***array3D);
129 
130 /*
131  * Print values of mbs_data (used for debug)
132  *
133  * WARNING: This function is not updated daily with new functionnalities of MbsData.
134  *
135  */
136 void mbs_print_data(MbsData *mbs_data);
137 
159 void mbs_copy_data(MbsData* s, MbsData* s_copy);
164 void mbs_reset_data(MbsData* s);
165 
176 int mbs_write_data(MbsData *mbs, char *filename, char *function_name);
177 
209 int mbs_compare_data(MbsData *s1, MbsData *s2, int accelred);
210 
219 int mbs_strcmp(const char* __s1, const char* __s2);
220 #ifdef __cplusplus
221 }
222 #endif
223 
224 #endif
get_char_cpy
char * get_char_cpy(const char *fmt,...)
Copy the provided formatted string into a newly allocated memory.
Definition: useful_functions.c:191
get_char_cpy
char * get_char_cpy(const char *fmt,...)
Copy the provided formatted string into a newly allocated memory.
Definition: useful_functions.c:191
free_char_tab
void free_char_tab(char **mat)
release memory for a matrix of chars
Definition: useful_functions.c:217
useful_functions.h
mbs_log
void mbs_log(char *msg,...)
Function for logging messages in a file called "log" where the program is executed.
Definition: useful_functions.c:28
sign
double sign(double a)
sign function
Definition: useful_functions.c:124
mbs_data.h
free_char_vec
void free_char_vec(char *vec)
release memory for a vector of char
Definition: useful_functions.c:186
mbs_write_data
int mbs_write_data(MbsData *mbs, char *filename, char *function_name)
Write a source with a function allocating and setting a MbsData copy of the provided.
Definition: mbs_data.c:231
free_char_vec
void free_char_vec(char *vec)
release memory for a vector of char
Definition: useful_functions.c:186
mbs_strcmp
int mbs_strcmp(const char *__s1, const char *__s2)
Compare two char with strcmp.
Definition: useful_functions.c:261
mbs_reset_data
void mbs_reset_data(MbsData *s)
Reset all fields of a MbsData structure to initial values.
Definition: mbs_data.c:208
mbs_matrix.h
sign
double sign(double a)
sign function
Definition: useful_functions.c:124
get_d3Darray_0
double *** get_d3Darray_0(int nb_r, int nb_c, 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
get_char_vec
char * get_char_vec(int size)
create (with memory allocation) a vector (length l_v) of char
Definition: useful_functions.c:159
mbs_1D_array.h
free_char_tab
void free_char_tab(char **mat)
release memory for a matrix of chars
Definition: useful_functions.c:217
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
mbs_strcmp
int mbs_strcmp(const char *__s1, const char *__s2)
Compare two char with strcmp.
Definition: useful_functions.c:261
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_char_vec
char * get_char_vec(int l_v)
create (with memory allocation) a vector (length l_v) of char
Definition: useful_functions.c:159
mbs_copy_data
void mbs_copy_data(MbsData *s, MbsData *s_copy)
Copy all fields between two MBSdata structures.
Definition: mbs_data.c:88
get_char_tab
char ** get_char_tab(int nb_r, int nb_c)
create (with memory allocation) a [nb_r times nb_c] matrix of chars WARNING: only the first dimension...
Definition: useful_functions.c:170
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_print_data
void mbs_print_data(MbsData *mbs_data)
Definition: mbs_data.c:21
get_time_machine
char * get_time_machine()
returns the current time as a String
Definition: useful_functions.c:131
mbs_message.h
get_char_tab
char ** get_char_tab(int nb_r, int nb_c)
create (with memory allocation) a [nb_r times nb_c] matrix of chars WARNING: only the first dimension...
Definition: useful_functions.c:170
get_time_machine
char * get_time_machine()
returns the current time as a String
Definition: useful_functions.c:131
expo_ten_inf
int expo_ten_inf(double nb)
get log with base 10
Definition: useful_functions.c:89
MbsData
Definition: mbs_data.h:149
mbs_free
void * mbs_free(void *__ptr)
Free the pointor ptr and set it to NULL.
Definition: useful_functions.c:17
expo_ten_inf
int expo_ten_inf(double nb)
get log with base 10
Definition: useful_functions.c:89
pow_int
double pow_int(double basis, int expo)
compute efficiently pow with an integer exponent
Definition: useful_functions.c:60
mbs_log
void mbs_log(char *msg,...)
Function for logging messages in a file called "log" where the program is executed.
Definition: useful_functions.c:28
mbs_warning_msg
void mbs_warning_msg(char *msg,...)
Send a warning message.
Definition: mbs_message.c:89
pow_int
double pow_int(double basis, int expo)
compute efficiently pow with an integer exponent
Definition: useful_functions.c:60
mbs_compare_data
int mbs_compare_data(MbsData *s1, MbsData *s2, int accelred)
Compare two MbsData.
Definition: mbs_data.c:533
mbs_free
void * mbs_free(void *__ptr)
Free the pointor ptr and set it to NULL.
Definition: useful_functions.c:17
mbs_errors_names.h