#include <stdio.h>
Go to the source code of this file.
Functions | |
double * | mbs_linspace_0 (double start, double stop, int num) |
Allocate an evenly spaced numbers over the specified range. More... | |
double * | mbs_linspace_1 (double start, double stop, int num) |
Allocate an evenly spaced numbers over the specified range. More... | |
double * | mbs_drand_0 (int num, double min, double max) |
Allocate an array with the specified random number in the specified range. More... | |
double * | mbs_drand_1 (int num, double min, double max) |
Allocate an array with the specified random number in the specified range. More... | |
int | get_dinterval_binary_0 (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. More... | |
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. More... | |
int | get_dinterval_binary_from_index_0 (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. More... | |
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. More... | |
int | save_ivec_0 (int *vec, int size, char *name, int row) |
save a (x sized) vector of integers in the specified file, starting with index 0 The file is open with the option "wt" More... | |
int | save_ivec_1 (int *vec, int size, char *name, int row) |
save a (x sized) vector of integers in the specified file, starting with index 0 The file is open with the option "wt" More... | |
double | norm (double v[4]) |
DEPRECATED: See norm_dvec_1(). More... | |
void | normalize (double v[4], double vn[4]) |
DEPRECATED: See normalize_dvec_1() More... | |
double | scalar_product (double v1[4], double v2[4]) |
Compute and return the scalar product of 2 vectors with first index is 1. More... | |
double | scalar_product_0 (double *v1, double *v2, int n) |
Compute and return the scalar product of 2 vectors with first index is 0. More... | |
void | vector_sum (double v1[4], double v2[4], double v_dest[4]) |
Sum each component of 2 vectors in a third vector. The first index is 1. More... | |
void | vector_diff (double v1[4], double v2[4], double v_dest[4]) |
Subtract each component of 2 vectors in a third vector. The first index is 1. More... | |
void | cross_product (double v1[4], double v2[4], double v_dest[4]) |
Compute the cross product of 2 vectors in a third vector. The first index is 1. More... | |
void | number_product (double s, double v1[4], double v_dest[4]) |
Compute the product of a vector by a real. The first index is 1. More... | |
int * | get_ivec_0 (int l_v) |
create (with memory allocation) a vector (length l_v) of integers, starting at index 0 More... | |
int * | get_ivec_1 (int l_v) |
create (with memory allocation) a vector (length l_v) of integers, starting at index 1 More... | |
void | free_ivec_0 (int *vec) |
release memory for a vector of integers, starting with index 0 More... | |
void | free_ivec_1 (int *vec) |
release memory for a vector of integers, starting with index 1 More... | |
void | copy_ivec_0 (int *vec_src, int *vec_dest, int l_v) |
Copy the content of a vector(of size l_v) of integers to a second vector, starting with index 0. More... | |
void | copy_ivec_1 (int *vec_src, int *vec_dest, int l_v) |
Copy the content of a vector (of size l_v) of integers to a second vector, starting with index 1. More... | |
int * | re_copy_ivec_0 (int *src, int s_nx, int *dest, int d_nx) |
Copy an array of int into another, reallocate the destination if required. More... | |
void | print_ivec_0 (int *vec, int l_v) |
print a (l_v sized) vector of integers in console, starting with index 0 More... | |
void | print_ivec_1 (int *vec) |
print a vector (of size specified in vec[0]) of integers in console, starting with index 1 More... | |
int | code_ivec_0 (FILE *file_out, int *values, const char *name, int size) |
Write C-code to allocate and fill an array of integers. More... | |
int | code_ivec_1 (FILE *file_out, int *values, const char *name, int size) |
Write C-code to allocate and fill an array of integers. More... | |
void | sort_ivec_0 (int *vec_src, int *vec_dest, int l_v) |
sort the first (l_v sized) vector of integers into the second vector, starting with index 0 More... | |
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 More... | |
void | sort_ivec_1 (int *vec_src, int *vec_dest, int l_v) |
sort the first (x sized) vector of integers into the second vector, starting with index 1 More... | |
void | sort_inplace_ivec_1 (int *vec, int l_v) |
sort and modify the (x sized) vector of integers, starting with index 1 The "Bubble sort" is used, complexity is O(n^2) More... | |
void | f0123_ivec_0 (int *vec, int l_v) |
Fill the (l_v sized) vector of integers as [0 1 2 3 ... l_v-1], starting with index 0. More... | |
void | conc_ivec_0 (int *vec1_src, int l_v1, int *vec2_src, int l_v2, int *vec_dest) |
concatenate the first (l_v1 sized) vector and the second (l_v2 sized) vectors of integers into the third (size >=l_v1+l_v2) vector (without memory allocation), starting with index 0 More... | |
void | conc_ivec_1 (int *vec1_src, int l_v1, int *vec2_src, int l_v2, int *vec3) |
concatenate the first (l_v1 sized) vector and the second (l_v2 sized) vectors of integers into the third (size >=l_v1+l_v2) vector (without memory allocation), starting with index 1 More... | |
int | slct_ivec_0 (int *vec1_src, int l_v1, int *vec_ind_src, int l_v2, int *vec1_dest) |
fill the third (l_v2 sized) vector by slicing the first (l_v1 sized) vector of integers at the indexes specified in the second (l_v2 sized) vector, starting with index 0 More... | |
int | find_ivec_0 (int *vec, int l_v, int f) |
return the index of the value f in the (x sized) vector vec of integers, starting with index 0. Return -1 if not found. More... | |
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. Return -1 if not found. More... | |
int | find_ivec_1 (int *vec, int l_v, int f) |
return the index of the value f in the (x sized) vector vec of integers, starting with index 1. Return -1 if not found. More... | |
int | same_ivec_0 (int *v1, int *v2, int size) |
Compare if two vector are the same. More... | |
int | same_ivec_1 (int *v1, int *v2) |
Compare if two vector are the same. More... | |
double * | get_dvec_0 (int l_v) |
create (with memory allocation) a vector (length l_v) of doubles, starting at index 0 More... | |
double * | get_dvec_1 (int l_v) |
create (with memory allocation) a vector (length l_v) of doubles, starting at index 1 More... | |
void | free_dvec_0 (double *vec) |
release memory for a vector of doubles, starting at index 0 More... | |
void | free_dvec_1 (double *vec) |
release memory for a vector of doubles, starting at index 1 More... | |
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. More... | |
void | copy_dvec_1 (double *vec_src, double *vec_dest) |
Copy the content of a vector (of size specified in vec_src[0]) of doubles to a second vector, starting with index 1. More... | |
double * | convert_dvec_0_to_1 (double *src, int size, int free_src) |
Copy a dvec0 into a new allocated dvec1. More... | |
double * | convert_dvec_1_to_0 (double *src, int size, int free_src) |
Copy a dvec1 into a new allocated dvec0. More... | |
double * | re_copy_dvec_0 (double *src, int s_nx, double *dest, int d_nx) |
Copy an array of double into another, reallocate the destination if required. More... | |
double * | re_copy_dvec_1 (double *src, int s_nx, double *dest, int d_nx) |
Copy an array of double into another, reallocate the destination if required. More... | |
void | print_dvec_0 (double *vec, int nb_r) |
print a (x sized) vector of doubles in console, starting with index 0 More... | |
void | print_format_dvec_0 (double *vec, int nb_r, char *format) |
print a (x sized) vector of doubles in console, starting with index 0 More... | |
void | print_dvec_1 (double *vec) |
print a vector (of size specified in vec[0]) of doubles in console, starting with index 1 More... | |
int | code_dvec_0 (FILE *file_out, double *values, const char *name, int size) |
Write C-code to allocate and fill an array of double. More... | |
int | code_dvec_1 (FILE *file_out, double *values, const char *name, int size) |
Write C-code to allocate and fill an array of double. More... | |
void | save_dvec_0 (double *vec, int nb_r, char *name) |
save a (x sized) vector of doubles in the specified file, starting with index 0 The file is open with the option "wt" More... | |
void | pick_and_place_dvec_1 (double *src, int *index, int n, double *dest) |
Pick the values from an array and set them in the destination array at the specified index. More... | |
void | pick_and_place_dvec_0 (double *src, int *index, int n, double *dest) |
Pick the values from an array and set them in the destination array at the specified index. More... | |
void | slct_dvec_1 (double *vec1_src, int *vec_ind_src, int l_v, double *vec3) |
fill the third vector by slicing the first vector of doubles at the indexes specified in the second (x sized) vector, starting with index 1 More... | |
int | slct_dvec_0 (double *vec1_src, int l_v1, int *vec_ind_src, int l_v2, double *vec_dest) |
fill the third (l_v2 sized) vector by slicing the first (l_v1 sized) vector of doubles at the indexes specified in the second (l_v2 sized) vector, starting with index 0 More... | |
int | any_dvec_0 (double *vec, int l_v) |
check if all values of a [l_v sized] vector of doubles are equal to 0, return 0 in that case, starting with index 0 More... | |
double | norm_dvec_0 (double *vec, int l_v) |
compute the norm of a [l_v sized] vector of doubles, starting with index 0 More... | |
double | norm_dvec_1 (double *vec, int l_v) |
compute the norm of a [l_v sized] vector of doubles, starting with index 1 More... | |
void | normalize_dvec_0 (double *vec, double *vn, int l_v) |
Compute the normalize vector with starting with index 0. More... | |
void | normalize_dvec_1 (double *vec, double *vn, int l_v) |
Compute the normalize vector with first index is 1. More... | |
void | zeros_dvec_0 (double *vec, int l_v) |
set all the element of a [l_v sized] vector of doubles to zero, starting with index 0 More... | |
void | zeros_dvec_1 (double *vec) |
set all the element of a vector of doubles to zero, starting with index 1 More... | |
void | opposite_dvec_0 (double *vec, int n) |
function to take the opposite of a given vector (minus in front of each entry) More... | |
void | opposite_dvec_1 (double *vec) |
function to take the opposite of a given vector (minus in front of each entry) More... | |
int | same_dvec_0 (double *v1, double *v2, int size) |
Compare if two vector of floats are the same. More... | |
int | same_dvec_1 (double *v1, double *v2) |
Compare if two vector of floats are the same. More... | |
This header defines an example of the header files to be used in MBsysC
Creation date: 19-06-2019
(c) Universite catholique de Louvain
int any_dvec_0 | ( | double * | vec, |
int | l_v | ||
) |
check if all values of a [l_v sized] vector of doubles are equal to 0, return 0 in that case, starting with index 0
[in] | vec | the vector to be checked |
[in] | l_v | the size of the vector |
int code_dvec_0 | ( | FILE * | file_out, |
double * | values, | ||
const char * | name, | ||
int | size | ||
) |
Write C-code to allocate and fill an array of double.
The code will assign the variable to NULL if values
is NULL or size is 0.
file_out | Stream in which writing the values. |
values | Pointer to the array to be written (index starts at 0). |
name | Name of the variable to be filled. |
size | The number of element in the array. |
int code_dvec_1 | ( | FILE * | file_out, |
double * | values, | ||
const char * | name, | ||
int | size | ||
) |
Write C-code to allocate and fill an array of double.
The code will assign the variable to NULL if values
is NULL.
file_out | Stream in which writing the values. |
values | Pointer to the array to be written (index starts at 1). |
name | Name of the variable to be filled. |
size | The number of element in the array (without counting index 0). |
int code_ivec_0 | ( | FILE * | file_out, |
int * | values, | ||
const char * | name, | ||
int | size | ||
) |
Write C-code to allocate and fill an array of integers.
The code will assign the variable to NULL if values
is NULL or size is 0.
file_out | Stream in which writing the values. |
values | Pointer to the array to be written (index starts at 0). |
name | Name of the variable to be filled. |
size | The number of element in the array. |
int code_ivec_1 | ( | FILE * | file_out, |
int * | values, | ||
const char * | name, | ||
int | size | ||
) |
Write C-code to allocate and fill an array of integers.
The code will assign the variable to NULL if values
is NULL.
file_out | Stream in which writing the values. |
values | Pointer to the array to be written (index starts at 1). |
name | Name of the variable to be filled. |
size | The number of element in the array (without counting index 0). |
void conc_ivec_0 | ( | int * | vec1_src, |
int | l_v1, | ||
int * | vec2_src, | ||
int | l_v2, | ||
int * | vec_dest | ||
) |
concatenate the first (l_v1 sized) vector and the second (l_v2 sized) vectors of integers into the third (size >=l_v1+l_v2) vector (without memory allocation), starting with index 0
[in] | vec1_src | the first vector to be concatenated |
[in] | l_v1 | the size of the first vector |
[in] | vec2_src | the second vector to be concatenated |
[in] | l_v2 | the size of the second vector |
[out] | vec_dest | the concatenation of both vector such as vec_dest = [vec1_src vec2_src]. The vector have to be already allocated to a sufficient size. |
void conc_ivec_1 | ( | int * | vec1_src, |
int | l_v1, | ||
int * | vec2_src, | ||
int | l_v2, | ||
int * | vec3 | ||
) |
concatenate the first (l_v1 sized) vector and the second (l_v2 sized) vectors of integers into the third (size >=l_v1+l_v2) vector (without memory allocation), starting with index 1
[in] | vec1_src | the first vector to be concatenated, starting with index 1 |
[in] | l_v1 | the size of the first vector (0 element not taken into account) |
[in] | vec2_src | the second vector to be concatenated, starting with index 1 |
[in] | l_v2 | the size of the second vector (0 element not taken into account) |
[out] | vec3 | the concatenation of both vector such as vec3 = [vec1_src vec2_src], starting with index 1. The vector have to be already allocated to a sufficient size. |
double* convert_dvec_0_to_1 | ( | double * | src, |
int | size, | ||
int | free_src | ||
) |
Copy a dvec0 into a new allocated dvec1.
src | The source array with index starting at 0. |
size | The number of element in the source array. |
free_src | Flag to free the memory pointed by src . |
double* convert_dvec_1_to_0 | ( | double * | src, |
int | size, | ||
int | free_src | ||
) |
Copy a dvec1 into a new allocated dvec0.
src | The source array with index starting at 1. |
size | The number of elements (index 0 not counted) in the source array. |
free_src | Flag to free the memory pointed by src . |
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.
[in] | vec_src | the original vector of doubles, starting with index 0 |
[out] | vec_dest | the copy of vec1_src, starting with index 0 |
[in] |
void copy_dvec_1 | ( | double * | vec_src, |
double * | vec_dest | ||
) |
Copy the content of a vector (of size specified in vec_src[0]) of doubles to a second vector, starting with index 1.
[in] | vec_src | the original vector of doubles(of size specified in vec_src[0]), starting with index 1 |
[out] | vec_dest | (already allocated at size specified in vec_src[0]) the copy of vec1_src, starting with index 1 |
void copy_ivec_0 | ( | int * | vec_src, |
int * | vec_dest, | ||
int | l_v | ||
) |
Copy the content of a vector(of size l_v) of integers to a second vector, starting with index 0.
[in] | vec_src | the original vector of integer, starting with index 0 |
[out] | vec_dst | the copy of vec_src, starting with index 0 |
[in] | l_v | size of the vectors |
void copy_ivec_1 | ( | int * | vec_src, |
int * | vec_dest, | ||
int | l_v | ||
) |
Copy the content of a vector (of size l_v) of integers to a second vector, starting with index 1.
[in] | vec_src | the original vector of integer, starting with index 1 |
[out] | vec_dest | the copy of vec_src, starting with index 1 |
[in] | l_v | size of the vectors (0 element not taken into account) |
void cross_product | ( | double | v1[4], |
double | v2[4], | ||
double | v_dest[4] | ||
) |
Compute the cross product of 2 vectors in a third vector. The first index is 1.
The vectors have unused index 0. See get_dvec_1() to such vector creation.
[in] | v1 | vector of size 4 with first element unused. |
[in] | v2 | vector of size 4 with first element unused. |
[in,out] | v | vector of size 4 such as with first element unused. |
void f0123_ivec_0 | ( | int * | vec, |
int | l_v | ||
) |
Fill the (l_v sized) vector of integers as [0 1 2 3 ... l_v-1], starting with index 0.
[out] | vec | the vector to be filled |
[in] | l_v | the size of the vector |
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. Return -1 if not found.
[in] | vec | a vector of double, starting with index 0 |
[in] | l_v | the size of the vector |
[in] | f | the double to look after in the vector |
int find_ivec_0 | ( | int * | vec, |
int | l_v, | ||
int | f | ||
) |
return the index of the value f in the (x sized) vector vec of integers, starting with index 0. Return -1 if not found.
[in] | vec | a vector of integers, starting with index 0 |
[in] | l_v | the size of the vector |
[in] | f | the integer to look after in the vector |
int find_ivec_1 | ( | int * | vec, |
int | l_v, | ||
int | f | ||
) |
return the index of the value f in the (x sized) vector vec of integers, starting with index 1. Return -1 if not found.
[in] | vec | a vector of integers, starting with index 1 |
[in] | l_v | the size of the vector (0 element not taken into account) |
[in] | f | the integer to look after in the vector |
void free_dvec_0 | ( | double * | vec | ) |
release memory for a vector of doubles, starting at index 0
[out] | vec | a vector of doubles |
void free_dvec_1 | ( | double * | vec | ) |
release memory for a vector of doubles, starting at index 1
[out] | vec | a vector of doubles |
void free_ivec_0 | ( | int * | vec | ) |
release memory for a vector of integers, starting with index 0
[out] | vec | a vector of integers |
void free_ivec_1 | ( | int * | vec | ) |
release memory for a vector of integers, starting with index 1
[out] | vec | a vector of integers |
int get_dinterval_binary_0 | ( | 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.
A binary search algorithm is used accros the whole array range. If the lim_check
is not enabled, the behavior is undefined if the value is outside the array range.
The array is of type get_dvec_0().
[in] | array | Array in which the interval is looked after. The array must be sorted and stricly increasing. |
[in] | size | The number of elements in the array . |
[in] | value | The value to be located. |
[out] | index | Store in this adress the index of the highest element in the array that is lower or equal to value . This index is not modified if the value is outside the range of the array (if lim_check is enable). |
[in] | lim_check | If true (not equal to 0) check that the value is in the range of the array . |
lim_check
is true:value
lower than input array minimum valuevalue
higher than input array maximum value 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.
This function calls get_dinterval_binary_0(), refers to it for implementation details.
The array is of type get_dvec_1().
[in] | array | Array in which the interval is looked after. The array must be sorted and stricly increasing. The first element (index=0) of the array is not considered. |
[in] | size | The number of elements (index 0 not taken into account) in the array . |
[in] | value | The value to be located. |
[out] | index | Store in this adress the index of the highest element in the array that is lower or equal to value . This index is not modified if the value is outside the range of the array (if lim_check is enable). |
[in] | lim_check | If true (not equal to 0) check that the value is in the range of the array . |
lim_check
is true. See get_dinterval_binary_0() for details. int get_dinterval_binary_from_index_0 | ( | 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.
A binary search algorithm is used between the upper or lower end of the array and the currently stored index. If the lim_check
is not enabled, the behavior is undefined if the value is outside the array range.
The array is of type get_dvec_0().
[in] | array | Array in which the interval is looked after. The array must be sorted and stricly increasing. |
[in] | size | The number of elements in the array . |
[in] | value | The value to be located. |
[in,out] | index | Use the index stored in the adress to initialize the binary search. Then store in this adress the index of the highest element in the array that is lower or equal to value . This index is not modified if the value is outside the range of the array (if lim_check is enable). |
[in] | lim_check | If true (not equal to 0) check that the value is in the range of the array . |
[in] | verbose | If true (not equal to 0) a message is raised if the initial index lead to use the full array width. |
lim_check
is true:value
lower than input array minimum valuevalue
higher than input array maximum value 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.
This function calls get_dinterval_binary_from_index_0(), refers to it for implementation details.
The array is of type get_dvec_1().
[in] | array | Array in which the interval is looked after. The array must be sorted and stricly increasing. |
[in] | size | The number of elements in the array . |
[in] | value | The value to be located. |
[in,out] | index | Use the index stored in the adress to initialize the binary search. Then store in this adress the index of the highest element in the array that is lower or equal to value . This index is not modified if the value is outside the range of the array (if lim_check is enable). |
[in] | lim_check | If true (not equal to 0) check that the value is in the range of the array . |
[in] | verbose | If true (not equal to 0) a message is raised if the initial index lead to use the full array width. |
lim_check
is true. See get_dinterval_binary_from_index_0() for details. double* get_dvec_0 | ( | int | l_v | ) |
create (with memory allocation) a vector (length l_v) of doubles, starting at index 0
[in] | l_v | size of the vector |
double* get_dvec_1 | ( | int | l_v | ) |
create (with memory allocation) a vector (length l_v) of doubles, starting at index 1
[in] | l_v | size of the vector (0 element not taken into account) |
int* get_ivec_0 | ( | int | l_v | ) |
create (with memory allocation) a vector (length l_v) of integers, starting at index 0
[in] | l_v | = size of the vector |
int* get_ivec_1 | ( | int | l_v | ) |
create (with memory allocation) a vector (length l_v) of integers, starting at index 1
[in] | l_v | = size of the vector (0 element not taken into account) |
double* mbs_drand_0 | ( | int | num, |
double | min, | ||
double | max | ||
) |
Allocate an array with the specified random number in the specified range.
This function uses the rand() function of stdlib, consider to call srand() to ensure reproductible/non-reproductible randomized vectors.
Providing the same value for min and max will generate an array with all elements to be equal to this value.
The array is of type get_dvec_0().
[in] | num | The number of points (geather than 0). |
[in] | min | The beginning of the range. |
[in] | max | The end point of the range. |
double* mbs_drand_1 | ( | int | num, |
double | min, | ||
double | max | ||
) |
Allocate an array with the specified random number in the specified range.
See mbs_drand_0() for details except that the array is of type get_dvec_1().
[in] | num | The number of points (geather than 0). |
[in] | min | The beginning of the range. |
[in] | max | The end point of the range. |
double* mbs_linspace_0 | ( | double | start, |
double | stop, | ||
int | num | ||
) |
Allocate an evenly spaced numbers over the specified range.
The array is of type get_dvec_0().
[in] | start | The beginning of the range. |
[in] | stop | The end point of the range (included). |
[in] | num | The number of points (geather than 0). |
double* mbs_linspace_1 | ( | double | start, |
double | stop, | ||
int | num | ||
) |
Allocate an evenly spaced numbers over the specified range.
The array is of type get_dvec_1().
[in] | start | The beginning of the range. |
[in] | stop | The end point of the range (included). |
[in] | num | The number of points (geather than 0). |
double norm | ( | double | v[4] | ) |
DEPRECATED: See norm_dvec_1().
Compute the Euclidean norm of a double vector with first index is 1. The vector has unused index 0. See get_dvec_1() to such vector creation.
[in] | v | vector of size 4 with first element unused. |
double norm_dvec_0 | ( | double * | vec, |
int | l_v | ||
) |
compute the norm of a [l_v sized] vector of doubles, starting with index 0
[in] | vec | the vector of doubles |
[in] | l_v | the size of the vector |
double norm_dvec_1 | ( | double * | vec, |
int | l_v | ||
) |
compute the norm of a [l_v sized] vector of doubles, starting with index 1
[in] | vec | the vector of doubles |
[in] | l_v | the size of the vector (0 element not taken into account) |
void normalize | ( | double | v[4], |
double | vn[4] | ||
) |
DEPRECATED: See normalize_dvec_1()
Compute the normalize vector with first index is 1. The vector has unused index 0. See get_dvec_1() to such vector creation.
WARNING: if norm(v) is 0, a division by 0 will occurs.
[in] | v | vector of size 4 with first element unused. |
[in,out] | vn | the normalized vector v, index starting at 1. |
void normalize_dvec_0 | ( | double * | vec, |
double * | vn, | ||
int | l_v | ||
) |
Compute the normalize vector with starting with index 0.
WARNING: if the norm of vec is 0, a division by 0 will occurs.
[in] | vec | vector of double to be normalized. |
[in,out] | vn | the normalized vector vec. |
[in] | l_v | the size of the vector. |
void normalize_dvec_1 | ( | double * | vec, |
double * | vn, | ||
int | l_v | ||
) |
Compute the normalize vector with first index is 1.
The vector has unused index 0. See get_dvec_1() to such vector creation.
WARNING: if norm(v) is 0, a division by 0 will occurs.
[in] | vec | vector of double to be normalized with first element unused. |
[in,out] | vn | the normalized vector vec, with first element unused. |
[in] | l_v | the size of the vector (0 element not taken into account) |
void number_product | ( | double | s, |
double | v1[4], | ||
double | v_dest[4] | ||
) |
Compute the product of a vector by a real. The first index is 1.
The vector has unused index 0. See get_dvec_1() to such vector creation.
[in] | s | real that will multiply the vector. |
[in] | v1 | vector of size 4 to be multiplied. The first index is 1. |
[in,out] | v_dest | vector of size 4 such as . The first index is 1. |
void opposite_dvec_0 | ( | double * | vec, |
int | n | ||
) |
function to take the opposite of a given vector (minus in front of each entry)
[in] | vec | the vector, vec |
[in] | n | the vecotr size, n |
void opposite_dvec_1 | ( | double * | vec | ) |
function to take the opposite of a given vector (minus in front of each entry)
[in] | vec | the vector, vec (starting at one) |
void pick_and_place_dvec_0 | ( | double * | src, |
int * | index, | ||
int | n, | ||
double * | dest | ||
) |
Pick the values from an array and set them in the destination array at the specified index.
This function can be seen as the opposite of slct_dvec_0
. The src
and index
arrays are starting with index 0!
src | the vector containing the original values of doubles to be copied. |
index | the vector containing the indexes of the value in the destination array. |
n | the number of indexes to be read (the first n indexes are read). |
dest | the destination array such as for i=0:n-1 { dest[index[i]] = src[i] } |
void pick_and_place_dvec_1 | ( | double * | src, |
int * | index, | ||
int | n, | ||
double * | dest | ||
) |
Pick the values from an array and set them in the destination array at the specified index.
This function can be seen as the opposite of slct_dvec_0
but for d_vec_1 array. The src
and index
arrays are starting with index 1!
src | the vector containing the original values of doubles to be copied. |
index | the vector containing the indexes of the value in the destination array. |
n | the number of indexes to be read (the first n indexes are read). |
dest | the destination array such as: for i=1:n { dest[index[i]] = src[i] } |
void print_dvec_0 | ( | double * | vec, |
int | nb_r | ||
) |
print a (x sized) vector of doubles in console, starting with index 0
call print_format_dvec_0 with default parameter (format = "%f").
[in] | vec | the vector to be printed |
[in] | nb_r | the size of the vector |
void print_dvec_1 | ( | double * | vec | ) |
print a vector (of size specified in vec[0]) of doubles in console, starting with index 1
[in] | vec | the vector to be printed |
void print_format_dvec_0 | ( | double * | vec, |
int | nb_r, | ||
char * | format | ||
) |
print a (x sized) vector of doubles in console, starting with index 0
[in] | vec | the vector to be printed |
[in] | nb_r | the size of the vector |
[in] | format | the chosen format. |
void print_ivec_0 | ( | int * | vec, |
int | l_v | ||
) |
print a (l_v sized) vector of integers in console, starting with index 0
[in] | vec | the vector to be printed |
[in] | l_v | the size of the vector |
void print_ivec_1 | ( | int * | vec | ) |
print a vector (of size specified in vec[0]) of integers in console, starting with index 1
[in] | vec | the vector to be printed |
double* re_copy_dvec_0 | ( | double * | src, |
int | s_nx, | ||
double * | dest, | ||
int | d_nx | ||
) |
Copy an array of double into another, reallocate the destination if required.
[in] | src | Source array to be copied, NULL pointer will free dest . |
[in] | s_nx | Size of the source array, 0 value will free dest . |
[out] | dest | Destination array to be filled. The array is reallocated if s_nx does not match d_nx . It is allocated if NULL is provided. |
[in] | d_nx | Size of the source array. If 0, dest is reallocated. |
dest
has been freed) or the adress of the filled array double* re_copy_dvec_1 | ( | double * | src, |
int | s_nx, | ||
double * | dest, | ||
int | d_nx | ||
) |
Copy an array of double into another, reallocate the destination if required.
[in] | src | Source array to be copied, NULL pointer will free dest . |
[in] | s_nx | Size of the source array, 0 value will create a dvec_1 of null size. |
[out] | dest | Destination array to be filled. The array is reallocated if s_nx does not match d_nx . It is allocated if NULL is provided. |
[in] | d_nx | Size of the source array. |
dest
has been freed) or the adress of the filled array int* re_copy_ivec_0 | ( | int * | src, |
int | s_nx, | ||
int * | dest, | ||
int | d_nx | ||
) |
Copy an array of int into another, reallocate the destination if required.
[in] | src | Source array to be copied, NULL pointer will free dest . |
[in] | s_nx | Size of the source array, 0 value will free dest . |
[out] | dest | Destination array to be filled. The array is reallocated if s_nx does not match d_nx . It is allocated if NULL is provided. |
[in] | d_nx | Size of the source array. If 0, dest is reallocated. |
dest
has been freed, the adress of the array otherwhise.[in] | src | Source array to be copied, NULL pointer will free dest . |
[in] | s_nx | Size of the source array, 0 value will create a dvec_1 of null size. |
[out] | dest | Destination array to be filled. The array is reallocated if s_nx does not match d_nx . It is allocated if NULL is provided. |
[in] | d_nx | Size of the source array. |
dest
has been freed, the adress of the array otherwhise. int same_dvec_0 | ( | double * | v1, |
double * | v2, | ||
int | size | ||
) |
Compare if two vector of floats are the same.
[in] | v1 | A vector of floats, starting with index 0. |
[in] | v2 | A vector of floats, starting with index 0. |
[in] | size | The number of elements in the arrays. |
int same_dvec_1 | ( | double * | v1, |
double * | v2 | ||
) |
Compare if two vector of floats are the same.
[in] | v1 | A vector of floats, starting with index 1 |
[in] | v2 | A vector of floats, starting with index 1 |
int same_ivec_0 | ( | int * | v1, |
int * | v2, | ||
int | size | ||
) |
Compare if two vector are the same.
[in] | v1 | A vector of integers, starting with index 0. |
[in] | v2 | A vector of integers, starting with index 0. |
[in] | size | The number of elements in the arrays. |
int same_ivec_1 | ( | int * | v1, |
int * | v2 | ||
) |
Compare if two vector are the same.
[in] | v1 | A vector of integers, starting with index 1 |
[in] | v2 | A vector of integers, starting with index 1 |
void save_dvec_0 | ( | double * | vec, |
int | nb_r, | ||
char * | name | ||
) |
save a (x sized) vector of doubles in the specified file, starting with index 0 The file is open with the option "wt"
[in] | vec | the vector to save, starting with index 0 |
[in] | nb_r | the size of the vector |
[in] | name | the path an name of the file in which saving the vector |
int save_ivec_0 | ( | int * | vec, |
int | size, | ||
char * | name, | ||
int | row | ||
) |
save a (x sized) vector of integers in the specified file, starting with index 0 The file is open with the option "wt"
[in] | vec | The vector to save, starting with index 0. If the provided pointer is NULL, but a non-null size is given, an error code is generated. |
[in] | size | The size of the vector. If the size is null, an empty file is created. |
[in] | name | The path an name of the file in which saving the vector. |
[in] | row | If non-zero, the vector is saved as a row in the file (one value per line). Otherwhise the vector is saved on a line. |
int save_ivec_1 | ( | int * | vec, |
int | size, | ||
char * | name, | ||
int | row | ||
) |
save a (x sized) vector of integers in the specified file, starting with index 0 The file is open with the option "wt"
[in] | vec | The vector to save, starting with index 0. If the provided pointer is NULL, but a non-null size is given, an error code is generated. |
[in] | size | The size of the vector. If the size is null, an empty file is created. |
[in] | name | The path an name of the file in which saving the vector. |
[in] | row | If non-zero, the vector is saved as a row in the file (one value per line). Otherwhise the vector is saved on a line. |
double scalar_product | ( | double | v1[4], |
double | v2[4] | ||
) |
Compute and return the scalar product of 2 vectors with first index is 1.
The vectors have unused index 0. See get_dvec_1() to such vector creation.
[in] | v1 | vector of size 4 with first element unused. |
[in] | v2 | vector of size 4 with first element unused. |
double scalar_product_0 | ( | double * | v1, |
double * | v2, | ||
int | n | ||
) |
Compute and return the scalar product of 2 vectors with first index is 0.
The vectors have unused index 0. See get_dvec_1() to such vector creation.
[in] | v1 | first vector. |
[in] | v2 | second vector. |
[in] | n | size of the vector. |
int slct_dvec_0 | ( | double * | vec1_src, |
int | l_v1, | ||
int * | vec_ind_src, | ||
int | l_v2, | ||
double * | vec_dest | ||
) |
fill the third (l_v2 sized) vector by slicing the first (l_v1 sized) vector of doubles at the indexes specified in the second (l_v2 sized) vector, starting with index 0
[in] | vec1_src | the vector containing the original values of doubles to be sliced |
[in] | l_v1 | the size of the vector vec1_src |
[in] | vec_ind_src | the vector containing the indexes of the slices |
[in] | l_v2 | the size of the vector vec_ind_src, |
[out] | vec_dest | the sliced vector such as vec_dest[i] = vec1_src[vec_ind_src[i]], starting with index 0. The vector have to be already allocated to a sufficient (l_v2) size. |
void slct_dvec_1 | ( | double * | vec1_src, |
int * | vec_ind_src, | ||
int | l_v, | ||
double * | vec3 | ||
) |
fill the third vector by slicing the first vector of doubles at the indexes specified in the second (x sized) vector, starting with index 1
[in] | vec1_src | the vector containing the original values of doubles to be sliced |
[in] | vec_ind_src | the vector containing the indexes of the slices |
[in] | l_v | the size of the vector vec_ind_src, |
[out] | vec3 | the sliced vector such as for i=1:x { vec3[i] = vec1_src[vec_ind_src[i]] }, starting with index 1. The vector have to be already allocated to a sufficient size. |
int slct_ivec_0 | ( | int * | vec1_src, |
int | l_v1, | ||
int * | vec_ind_src, | ||
int | l_v2, | ||
int * | vec1_dest | ||
) |
fill the third (l_v2 sized) vector by slicing the first (l_v1 sized) vector of integers at the indexes specified in the second (l_v2 sized) vector, starting with index 0
[in] | vec1_src | the vector containing the original values to be sliced |
[in] | l_v1 | the size of the vector vec1_src |
[in] | vec_ind_src | the vector containing the indexes of the slices |
[in] | l_v2 | the size of the vector vec_ind_src, |
[out] | vec_dest | the sliced vector such as vec3[i] = vec1_src[vec_ind_src[i]], starting with index 0. The vector have to be already allocated to a sufficient (l_v2) size. |
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
[in] | vec_src | the vector to be sorted |
[out] | vec_dest | the sorted vector |
[in] | l_v | the size of the vectors |
void sort_inplace_ivec_1 | ( | int * | vec, |
int | l_v | ||
) |
sort and modify the (x sized) vector of integers, starting with index 1 The "Bubble sort" is used, complexity is O(n^2)
[in,out] | vec | the vector to be sorted |
[in] | l_v | the size of the vector (0 element not taken into account) |
void sort_ivec_0 | ( | int * | vec_src, |
int * | vec_dest, | ||
int | l_v | ||
) |
sort the first (l_v sized) vector of integers into the second vector, starting with index 0
[in] | vec_src | the vector to be sorted |
[out] | vec_dest | the sorted vector |
[in] | l_v | the size of the vectors |
void sort_ivec_1 | ( | int * | vec_src, |
int * | vec_dest, | ||
int | l_v | ||
) |
sort the first (x sized) vector of integers into the second vector, starting with index 1
[in] | vec_src | the vector to be sorted, starting with index 1 |
[out] | vec_dest | the sorted vector, starting with index 1 |
[in] | l_v | the size of the vectors (0 element not taken into account) |
void vector_diff | ( | double | v1[4], |
double | v2[4], | ||
double | v_dest[4] | ||
) |
Subtract each component of 2 vectors in a third vector. The first index is 1.
The vectors have unused index 0. See get_dvec_1() to such vector creation.
[in] | v1 | vector of size 4 with first element unused. |
[in] | v2 | vector of size 4 with first element unused. |
[in,out] | v | vector of size 4 such as with first element unused. |
void vector_sum | ( | double | v1[4], |
double | v2[4], | ||
double | v_dest[4] | ||
) |
Sum each component of 2 vectors in a third vector. The first index is 1.
The vectors have unused index 0. See get_dvec_1() to such vector creation.
[in] | v1 | vector of size 4 with first element unused. |
[in] | v2 | vector of size 4 with first element unused. |
[in,out] | v_dest | vector of size 4 such as |
void zeros_dvec_0 | ( | double * | vec, |
int | l_v | ||
) |
set all the element of a [l_v sized] vector of doubles to zero, starting with index 0
[in] | vec | the vector to be nullified, starting with index 0 |
[in] | l_v | the size of the vector |
void zeros_dvec_1 | ( | double * | vec | ) |
set all the element of a vector of doubles to zero, starting with index 1
[in,out] | vec | the vector to be nullified, starting with index 1 |