Declares all operation betweens matrices, matrice and vector, matrice and scalars. More...
#include <stdio.h>Go to the source code of this file.
Macros | |
| #define | make_transpose_arr_4x4(mat) |
| Get a static array containing the transpose of mat. More... | |
| #define | make_transpose_arr_3x3(mat) |
| Get a static array containing the transpose of mat. More... | |
| #define | make_transpose_arr_4x4_to_3x3(mat) |
| Get a static array containing the transpose of mat changing index convention. More... | |
Functions | |
| void | transpose (double M[4][4], double Mt[4][4]) |
| Compute the transpose of a matrix with first index is 1. More... | |
| void | dot_3x3_arr (double res[3], double mat[3][3], double vec[3]) |
| Compute the dot product of a matrix by a vector. More... | |
| double * | dot_3x3_ptr (double *res, double **mat, double *vec) |
| Compute the dot product of a matrix by a vector. More... | |
| void | dot_4x4_arr (double res[4], double mat[4][4], double vec[4]) |
| Compute the dot product of a matrix by a vector. More... | |
| double * | dot_4x4_ptr (double *res, double **mat, double *vec) |
| Compute the dot product of a matrix by a vector. More... | |
| double * | dot_nxm_ptr_0 (double *res, double **mat, double *vec, int nr, int nc) |
| Compute the dot product of a matrix by a vector. More... | |
| double * | dot_nxm_ptr_1 (double *res, double **mat, double *vec, int nr, int nc) |
| Compute the dot product of a matrix by a vector. More... | |
| void | matrix_product (double M[4][4], double v[4], double Mv[4]) |
| void | matrix_product_0 (double **M, double *v, double *Mv, int nr, int nc) |
| void | matrix_product_1 (double **M, double *v, double *v_out, int nr, int nc) |
| void | matmul_3x3_arr (double res[3][3], double mat_1[3][3], double mat_2[3][3]) |
| Compute the product of two matrices. More... | |
| double ** | matmul_3x3_ptr (double **res, double **mat_1, double **mat_2) |
| Compute the product of two matrices. More... | |
| void | matmul_4x4_arr (double res[4][4], double mat_1[4][4], double mat_2[4][4]) |
| Compute the product of two matrices. More... | |
| double ** | matmul_4x4_ptr (double **res, double **mat_1, double **mat_2) |
| Compute the product of two matrices. More... | |
| void | doublematrix_product (double M1[4][4], double M2[4][4], double M[4][4]) |
| DEPRECATED, see matmul_4x4_arr(). More... | |
| void | doublematrix_product_0 (double **M1, int nb_row_M1, int nb_col_M1, double **M2, int nb_col_M2, double **M) |
| Compute the product of two matrices of given shape. The first index is 0. More... | |
| void | doublematrix_product_1 (double **M1, int nb_row_M1, int nb_col_M1, double **M2, int nb_col_M2, double **M) |
| Compute the product of two matrices of given shape. The first index is 1. More... | |
| int | rotation_matrix (int type, double angle, double R[4][4]) |
| DEPRECATED, see rotation_matrix_4x4_arr(). More... | |
| int | rotation_matrix_4x4_ptr (int type, double angle, double **R) |
| Compute the rotation matrix for a specified angle around a specific axis. More... | |
| int | rotation_matrix_3x3_ptr (int type, double angle, double **R) |
| Compute the rotation matrix for a specified angle around a specific axis. More... | |
| int ** | get_imat_0 (int nb_r, int nb_c) |
| create (with memory allocation) a [nb_r times nb_c] matrix of integers, starting at index 0. The function returns NULL if the requested number of rows or columns is negative or null. More... | |
| int ** | get_imat_1 (int nb_r, int nb_c) |
| create (with memory allocation) a [nb_r times nb_c] matrix of integers, starting at index 1 More... | |
| void | free_imat_0 (int **mat) |
| release memory for a matrix of integers, starting with index 0 More... | |
| void | free_imat_1 (int **mat) |
| release memory for a matrix of integers, starting with index 1 More... | |
| void | copy_imat_0 (int **tab_src, int **tab_dest, int nb_r, int nb_c) |
| Copy the content of a [nb_r times nb_c] matrix of integers to a second matrix, starting with index 0. More... | |
| void | print_imat_0 (int **mat, int nb_r, int nb_c) |
| print a [nb_r times nb_c] matrix of integers in console, starting with index 0 More... | |
| 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 The function returns NULL if the requested number of rows or columns is negative or null. More... | |
| 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 More... | |
| double ** | get_contdmat_1 (int nb_r, int nb_c) |
| create (with memory allocation) a [nb_r times nb_c] matrix of doubles, starting at index 1. The allocated memory is CONTIGUOUS (adapted for Lapack routine) More... | |
| void | free_dmat_0 (double **mat) |
| release memory for a matrix of doubles, starting at index 0 More... | |
| void | free_dmat_1 (double **mat) |
| release memory for a matrix of doubles, starting at index 1 More... | |
| void | copy_3x3_arr (double res[3][3], double src[3][3]) |
| Copy the array into another one. More... | |
| double ** | copy_3x3_ptr (double **res, double **src) |
| Copy the matrix into another one. More... | |
| void | copy_4x4_arr (double res[4][4], double src[4][4]) |
| Copy the array into another one. More... | |
| double ** | copy_4x4_ptr (double **res, double **src) |
| Copy the matrix into another one. More... | |
| void | copy_dmat_0 (double **tab_src, double **tab_dest, int nb_r, int nb_c) |
| Copy the content of a [nb_r times nb_c] matrix of doubles to a second matrix, starting with index 0. More... | |
| void | copy_dmat_1 (double **src, double **dest, int x, int y) |
| Copy the content of a [x times y] matrix of doubles to a second matrix, starting with index 1. More... | |
| double ** | re_copy_dmat_0 (double **src, int s_nx, int s_ny, double **dest, int d_nx, int d_ny) |
| Copy a 2D array of double into another, reallocate the destination if required. More... | |
| double ** | re_copy_dmat_1 (double **src, int s_nx, int s_ny, double **dest, int d_nx, int d_ny) |
| Copy a 2D array of double into another, reallocate the destination if required. More... | |
| void | transpose_dmat_0 (double **tab_src, double **tab_dest, int nb_r, int nb_c) |
| Transpose a [nb_r times nb_c] matrix of doubles and store the results in a [y times nb_r] matrix, starting with index 0. More... | |
| void | transpose_dmat_1 (double **tab_src, double **tab_dest, int x, int y) |
| Transpose a [x times y] matrix of doubles and store the results in a [y times x] matrix, starting with index 1. More... | |
| void | print_dmat_0 (double **mat, int nb_r, int nb_c) |
| print a [nb_r times nb_c] matrix of doubles in console, starting with index 0 More... | |
| void | print_format_dmat_0 (double **mat, int nb_r, int nb_c, char *format) |
| print a [nb_r times nb_c] matrix of doubles in console, starting with index 0 More... | |
| 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 a matrix provided by the user. The first nb_r line of the file are loaded, other lines are ignored. More... | |
| double ** | load_dmat_0 (int nb_r, int nb_c, char *name) |
| load a [nb_r times nb_c] matrix of doubles from a file starting with index 0. The matrix is created (memory allocation) and filled with the values from the file. More... | |
| int | save_dmat_0 (double **mat, int nb_r, int nb_c, char *name) |
| save a [nb_r times nb_c] matrix of doubles to a second matrix, starting with index 0 More... | |
| int | save_format_dmat_0 (double **mat, int nb_r, int nb_c, char *name, char *format) |
| save a [nb_r times nb_c] matrix of doubles to a second matrix, starting with index 0. More... | |
| int | code_dmat_0 (FILE *file_out, double **values, const char *name, int n_row, int n_col) |
| Write C-code to allocate and fill an array of arrays of doubles. More... | |
| int | code_dmat_1 (FILE *file_out, double **values, const char *name, int n_row, int n_col) |
| Write C-code to allocate and fill an array of arrays of doubles. More... | |
| int | slct_dmat_0 (double **tab_src, int nb_r, int nb_c, double **tab_out, int l_vec, int *vec) |
| fill the second [nb_r times l_vec] matrix by selecting the columns of the first [nb_r times nb_c] matrix of doubles. The indexes of the columns are specified in the (l_vec sized) vector, starting with index 0 More... | |
| int | slctr_dmat_0 (double **tab_src, int nb_r, int nb_c, double **tab_dest, int l_vec, int *vec) |
| fill the second [l_vec times nb_c] matrix by selecting the rows of the first [nb_r times nb_c] matrix of doubles. The indexes of the rows are specified in the (l_vec sized) vector, starting with index 0 More... | |
| void | zeros_dmat_0 (double **mat, int nb_r, int nb_c) |
| set all the element of a [nb_r times nb_c] matrix of doubles to zero, starting with index 0 More... | |
| int | set_diag_dmat_0 (double **mat, int size, double value) |
| Set a diagonal matrix with the given value. More... | |
| int | set_identity_dmat_0 (double **mat, int size) |
| Set a matrix to identity matrix. Out-of-diagonal elements are set to zero. More... | |
| double ** | identity_dmat_3x3_ptr (double **mat) |
| Set the matrix to identity (diagonal to 1, outside to 0). More... | |
| double ** | identity_dmat_4x4_ptr (double **mat) |
| Set the matrix to identity (diagonal to 1, outside to 0). More... | |
| int | identity_dmat_3x3_arr (double mat[3][3]) |
| Set the matrix to identity (diagonal to 1, outside to 0). More... | |
| int | identity_dmat_4x4_arr (double mat[4][4]) |
| Set the matrix to identity (diagonal to 1, outside to 0). More... | |
| void | mult_dmat_0 (double **A, double **B, double **C, int n1, int n2, int n3) |
| function to multiply two matrices: A * B = C [n1 n2] [n2 n3] = [n1 n3] More... | |
| void | sum_dmat_0 (double **A, double **B, double **C, int n1, int n2) |
| function to sum two matrices: A + B = C More... | |
| void | diff_dmat_0 (double **A, double **B, double **C, int n1, int n2) |
| function to sum two matrices: A - B = C More... | |
| void | opposite_dmat_0 (double **A, int n1, int n2) |
| function to take the opposite of a given matrix (minus in front of each entry) More... | |
| void | readmatrix (double **matrix, int *n) |
| function to read a matrix (obsolete?) More... | |
| int | get_dmatfiles_size (const char *fileName, int *n_row, int *n_col) |
| Function to load a file and calculate the number of rows and columns. More... | |
| void | update_initzeros (int *initzeros, double **matrix, int *n) |
| function to update the initzeros array (obsolete?) More... | |
| void | arrange_matrix (double **matrix, int *n, int *initzeros) |
| function to arrange matrix (obsolete?) More... | |
| void | scale_matrix (double **matrix, int *n, int *initzeros) |
| function to scale matrix (obsolete?) More... | |
| void | copy_array_dmat_1 (double src[4][4], double **dest) |
| Copy the content of an array of doubles to a pointer of matrix, starting with index 1. More... | |
| int | same_dmat_0 (double **a, double **b, int x, int y) |
| Compare if two 2D arrays of floats are the same. More... | |
Declares all operation betweens matrices, matrice and vector, matrice and scalars.
Some functions are still declared in file mbs_utilities.h.
The function are named (WORK IN PROGRESS):
dmat for array of float or imat for integers.double mat[3][3] (with first index 0).double mat[4][4] (). The index "0" is usually disregarded (ie: for copy, it is not disregarded).double **mat.double **mat.For example to compute the (dot) product between an rotation matrix and a vector, the numpy function ab = numpy.dot(a, b) is here:
double R[3][3] then double *res = dot_3x3_arr(NULL, R, vec),double R[4][4] then double *res = dot_4x4_arr(NULL, R, vec),double **R = get_dmat_0(3,3) then one of:double *res = dot_3x3_arr(NULL, R, vec),double *res = dot_nxm_arr_0(NULL, R, vec, 3, 3),double **R = get_dmat_1(3,3) then one of:double *res = dot_4x4_arr(NULL, R, vec),double *res = dot_nxm_arr_1(NULL, R, vec, 3, 3),If a function allows inplace computation, it is specified in the documentation. Then the res parameter can be the same pointer as any of the other array.
If a function allocate the memory for the results when missing, it is specified in the documentation. Is such a case, NULL is the res function argument, and the returned memory must be freed by the caller.
(c) Universite catholique de Louvain
| #define make_transpose_arr_3x3 | ( | mat | ) |
Get a static array containing the transpose of mat.
| [in] | mat | Pointer (double **mat) or array (double mat[3][3]) of size 3x3. |
mat. | #define make_transpose_arr_4x4 | ( | mat | ) |
Get a static array containing the transpose of mat.
| [in] | mat | Pointer (double **mat) or array (double mat[4][4]) of size 4x4 with unused index 0. |
mat. | #define make_transpose_arr_4x4_to_3x3 | ( | mat | ) |
Get a static array containing the transpose of mat changing index convention.
The input convention is index starting at 1 (0 unused), the output convention is the index starting at 0
| [in] | mat | Pointer (double **mat) or array (double mat[4][4]) of size 4x4 with unused index 0. |
mat. | void arrange_matrix | ( | double ** | matrix, |
| int * | n, | ||
| int * | initzeros | ||
| ) |
function to arrange matrix (obsolete?)
| [in,out] | matrix | the matrix |
| [in] | n | the vector |
| [in,out] | initzeros | the vector to arrange |
| int code_dmat_0 | ( | FILE * | file_out, |
| double ** | values, | ||
| const char * | name, | ||
| int | n_row, | ||
| int | n_col | ||
| ) |
Write C-code to allocate and fill an array of arrays of doubles.
| file_out | Stream in which writing the values. |
| values | Pointer to the array of arrays to be written (index starts at 0). |
| name | Name of the variable to be filled. |
| n_row | The number of rows in the array. |
| n_col | The number of columns in the array. |
| int code_dmat_1 | ( | FILE * | file_out, |
| double ** | values, | ||
| const char * | name, | ||
| int | n_row, | ||
| int | n_col | ||
| ) |
Write C-code to allocate and fill an array of arrays of doubles.
| file_out | Stream in which writing the values. |
| values | Pointer to the array of arrays to be written (index starts at 1). |
| name | Name of the variable to be filled. |
| n_row | The number of rows in the array (not counting index 0). |
| n_col | The number of columns in the array (not counting index 0). |
| void copy_3x3_arr | ( | double | res[3][3], |
| double | src[3][3] | ||
| ) |
Copy the array into another one.
The first index is 0, the dimension of the array is 3x3:
| [out] | res | Destination array for the copy. |
| [in] | src | Source array to be copied. |
| double** copy_3x3_ptr | ( | double ** | res, |
| double ** | src | ||
| ) |
Copy the matrix into another one.
The first index is 0, the pointer should point to 3 pointers of 3 doubles:
A new matrix is allocated if res is NULL. The memory must be freed by the caller.
| [out] | res | Destination pointer for the copy, can be NULL. |
| [in] | src | Source pointer to be copied. |
res except if it was NULL. | void copy_4x4_arr | ( | double | res[4][4], |
| double | src[4][4] | ||
| ) |
Copy the array into another one.
The first index is 1, the dimension of the array is 4x4:
The first row and column are copied even if index 1 is supposed to not be used.
| [out] | res | Destination array for the copy. |
| [in] | src | Source array to be copied. |
| double** copy_4x4_ptr | ( | double ** | res, |
| double ** | src | ||
| ) |
Copy the matrix into another one.
The first index is 1, the pointer should point to 4 pointers of 4 doubles:
The first row and column are copied even if index 1 is supposed to not be used.
A new matrix is allocated if res is NULL. The memory must be freed by the caller.
| [out] | res | Destination pointer for the copy, can be NULL. |
| [in] | src | Source pointer to be copied. |
res except if it was NULL. | void copy_array_dmat_1 | ( | double | src[4][4], |
| double ** | dest | ||
| ) |
Copy the content of an array of doubles to a pointer of matrix, starting with index 1.
Only the content (inner 3x3 submatrix) is copied. The first row and column are not copied.
| [in] | src | The array[4][4] of doubles. |
| [out] | dest | The pointer to the matrix destination |
| void copy_dmat_0 | ( | double ** | tab_src, |
| double ** | tab_dest, | ||
| int | nb_r, | ||
| int | nb_c | ||
| ) |
Copy the content of a [nb_r times nb_c] matrix of doubles to a second matrix, starting with index 0.
| [in] | tab_src | the original matrix of doubles, starting with index 0 |
| [out] | tab_dest | the copy of tab_src, starting with index 0 |
| [in] | nb_r | nb of rows |
| [in] | nb_c | nb of columns |
| void copy_dmat_1 | ( | double ** | src, |
| double ** | dest, | ||
| int | x, | ||
| int | y | ||
| ) |
Copy the content of a [x times y] matrix of doubles to a second matrix, starting with index 1.
| [in] | src | the original matrix of doubles, starting with index 1 |
| [out] | dest | the copy of tab1, starting with index 1 |
| [in] | x | nb of rows (without counting the unused first row) |
| [in] | y | nb of columns (without counting the unused first column) |
| void copy_imat_0 | ( | int ** | tab_src, |
| int ** | tab_dest, | ||
| int | nb_r, | ||
| int | nb_c | ||
| ) |
Copy the content of a [nb_r times nb_c] matrix of integers to a second matrix, starting with index 0.
| [in] | tab_src | the original matrix of integer, starting with index 0 |
| [out] | tab_dest | the copy of tab_src, starting with index 0 |
| [in] | nb_r | nb of rows |
| [in] | nb_c | nb of columns |
| void diff_dmat_0 | ( | double ** | A, |
| double ** | B, | ||
| double ** | C, | ||
| int | n1, | ||
| int | n2 | ||
| ) |
function to sum two matrices: A - B = C
| [in] | A | the matrix A |
| [in] | B | the matrix B |
| [out] | C | the matrix C |
| [in] | n1 | first size |
| [in] | n2 | second size |
| void dot_3x3_arr | ( | double | res[3], |
| double | mat[3][3], | ||
| double | vec[3] | ||
| ) |
Compute the dot product of a matrix by a vector.
The dimension of the array is 3x3:
The function support in place computation.
| [in,out] | res | Vector of size 3 such as . It can be the same as vec. |
| [in] | mat | Array of size 3x3, it will be multiplied by vec. |
| [in] | vec | Vector of size 3. It can be the same as res. |
| double* dot_3x3_ptr | ( | double * | res, |
| double ** | mat, | ||
| double * | vec | ||
| ) |
Compute the dot product of a matrix by a vector.
The first index is 0, the pointer should point to 3 pointers of 3 doubles:
The function support in place computation. A newly allocated array is returned if needed.
| [in,out] | res | Vector of size 3 such as . It can be the same as vec. |
| [in] | mat | Array of size 3x3, it will be multiplied by vec. |
| [in] | vec | Vector of size 3. It can be the same as res. |
res except if it was NULL. | void dot_4x4_arr | ( | double | res[4], |
| double | mat[4][4], | ||
| double | vec[4] | ||
| ) |
Compute the dot product of a matrix by a vector.
The dimension of the array is 4x4:
The function support in place computation.
| [in,out] | res | Vector of size 4 such as . It can be the same as vec. |
| [in] | mat | Array of size 4x4, it will be multiplied by vec. |
| [in] | vec | Vector of size 4. It can be the same as res. |
| double* dot_4x4_ptr | ( | double * | res, |
| double ** | mat, | ||
| double * | vec | ||
| ) |
Compute the dot product of a matrix by a vector.
The first index is 1, the pointer should point to 4 pointers of 4 doubles:
The function support in place computation. A newly allocated array is returned if needed.
| [in,out] | res | Vector of size 4 such as . It can be the same as vec. |
| [in] | mat | Array of size 4x4, it will be multiplied by vec. |
| [in] | vec | Vector of size 4. It can be the same as res. |
res except if it was NULL. | double* dot_nxm_ptr_0 | ( | double * | res, |
| double ** | mat, | ||
| double * | vec, | ||
| int | nr, | ||
| int | nc | ||
| ) |
Compute the dot product of a matrix by a vector.
The first index is 0, the sizes must be provided:
The function support in place computation but the caller must ensure that the size of the input vector great enough.
A newly allocated array is returned if the result vector in NULL.
| [out] | res | Vector of size nr such as . It can be the same as vec (if the latter is big enough). |
| [in] | mat | Array of size [nr x nc], it will be multiplied by vec. |
| [in] | vec | Vector of size nc. It can be the same as res. |
| [in] | nr | The number of rows in the matrix; the number of elements in the result. |
| [in] | nc | The number of columns in the matrix; the number of elements in the input vector. |
res except if it was NULL. | double* dot_nxm_ptr_1 | ( | double * | res, |
| double ** | mat, | ||
| double * | vec, | ||
| int | nr, | ||
| int | nc | ||
| ) |
Compute the dot product of a matrix by a vector.
The first index is 1, the sizes must be provided:
The function support in place computation but the caller must ensure that the size of the input vector great enough.
A newly allocated array is returned if the result vector in NULL.
| [out] | res | Vector of size nr such as . It can be the same as vec (if the latter is big enough). |
| [in] | mat | Array of size [nr x nc], it will be multiplied by vec. |
| [in] | vec | Vector of size nc. It can be the same as res. |
| [in] | nr | The number of rows in the matrix; the number of elements in the result. |
| [in] | nc | The number of columns in the matrix; the number of elements in the input vector. |
res except if it was NULL. | void doublematrix_product | ( | double | M1[4][4], |
| double | M2[4][4], | ||
| double | M[4][4] | ||
| ) |
DEPRECATED, see matmul_4x4_arr().
| void doublematrix_product_0 | ( | double ** | M1, |
| int | nb_row_M1, | ||
| int | nb_col_M1, | ||
| double ** | M2, | ||
| int | nb_col_M2, | ||
| double ** | M | ||
| ) |
Compute the product of two matrices of given shape. The first index is 0.
The memory of the output matrix M must already been allocated. See get_dmat_0() to such matrix creation.
| [in] | M1 | matrix of size (nb_row_M1 x nb_col_M1). |
| [in] | nb_row_M1 | number of rows of the matrix M1. |
| [in] | nb_col_M1 | number of columns of the matrix M1. |
| [in] | M2 | matrix of size (nb_col_M1 x nb_col_M2). |
| [in] | nb_col_M2 | number of columns of the matrix M2. |
| [in,out] | M | matrix of size (nb_row_M1 x nb_col_M2) such as . |
| void doublematrix_product_1 | ( | double ** | M1, |
| int | nb_row_M1, | ||
| int | nb_col_M1, | ||
| double ** | M2, | ||
| int | nb_col_M2, | ||
| double ** | M | ||
| ) |
Compute the product of two matrices of given shape. The first index is 1.
The memory of the output matrix M must already been allocated. See get_dmat_1() to such matrix creation.
| [in] | M1 | matrix of size (nb_row_M1 x nb_col_M1) plus first line and row unused. |
| [in] | nb_row_M1 | number of rows of the matrix M1 (without counting the unused first row/colum). |
| [in] | nb_col_M1 | number of columns of the matrix M1 (without counting the unused first row/colum). |
| [in] | M2 | matrix of size (nb_col_M1 x nb_col_M2) plus first line and row unused. |
| [in] | nb_col_M2 | number of columns of the matrix M2 (without counting the unused first row/colum). |
| [in,out] | M | Matrix of size (nb_row_M1 x nb_col_M2) such as . |
| void free_dmat_0 | ( | double ** | mat | ) |
release memory for a matrix of doubles, starting at index 0
| [out] | mat | matrix of doubles |
| void free_dmat_1 | ( | double ** | mat | ) |
release memory for a matrix of doubles, starting at index 1
| [out] | mat | matrix of doubles |
| void free_imat_0 | ( | int ** | mat | ) |
release memory for a matrix of integers, starting with index 0
| [out] | mat | matrix of integers |
| void free_imat_1 | ( | int ** | mat | ) |
release memory for a matrix of integers, starting with index 1
| [out] | mat | matrix of integers |
| double** get_contdmat_1 | ( | int | nb_r, |
| int | nb_c | ||
| ) |
create (with memory allocation) a [nb_r times nb_c] matrix of doubles, starting at index 1. The allocated memory is CONTIGUOUS (adapted for Lapack routine)
| [in] | nb_r | nb of rows (0 element not taken into account) |
| [in] | nb_c | nb of columns (0 element not taken into account) |
| 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 The function returns NULL if the requested number of rows or columns is negative or null.
| [in] | nb_r | nb of rows |
| [in] | nb_c | nb of columns |
| 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
| [in] | nb_r | nb of rows (0 element not taken into account) |
| [in] | nb_c | nb of columns (0 element not taken into account) |
| int get_dmatfiles_size | ( | const char * | fileName, |
| int * | n_row, | ||
| int * | n_col | ||
| ) |
Function to load a file and calculate the number of rows and columns.
| [in] | fileName | Name of the file containing the results to load. The first column contains the time. The other columns contain the coordinates. |
| [in,out] | n_row | nb of rows |
| [in,out] | n_col | nb of columns |
| int** get_imat_0 | ( | int | nb_r, |
| int | nb_c | ||
| ) |
create (with memory allocation) a [nb_r times nb_c] matrix of integers, starting at index 0. The function returns NULL if the requested number of rows or columns is negative or null.
| [in] | nb_r | = nb of rows |
| [in] | nb_c | = nb of columns |
| int** get_imat_1 | ( | int | nb_r, |
| int | nb_c | ||
| ) |
create (with memory allocation) a [nb_r times nb_c] matrix of integers, starting at index 1
| [in] | nb_r | = nb of rows (0 element not taken into account) |
| [in] | nb_c | = nb of columns (0 element not taken into account) |
| int identity_dmat_3x3_arr | ( | double | mat[3][3] | ) |
Set the matrix to identity (diagonal to 1, outside to 0).
The first index is 0, the dimension of the array is 3x3:
| [in,out] | mat | Pointer to the matrix to be set to identity. |
| double** identity_dmat_3x3_ptr | ( | double ** | mat | ) |
Set the matrix to identity (diagonal to 1, outside to 0).
The first index is 0, the pointer should point to 3 pointers of 3 doubles:
A new matrix is allocated if mat is NULL. The memory must be freed by the caller.
| [in,out] | mat | Pointer to the matrix to be set to identity. NULL can be provided. |
mat except if it was NULL. | int identity_dmat_4x4_arr | ( | double | mat[4][4] | ) |
Set the matrix to identity (diagonal to 1, outside to 0).
The first index is 1, the dimension of the array is 4x4:
| [in,out] | mat | Pointer to the matrix to be set to identity. |
| double** identity_dmat_4x4_ptr | ( | double ** | mat | ) |
Set the matrix to identity (diagonal to 1, outside to 0).
The first index is 1, the pointer should point to 4 pointers of 4 doubles:
The first row and column are copied even if index 1 is supposed to not be used.
A new matrix is allocated if res is NULL. The memory must be freed by the caller.
| [in,out] | mat | Pointer to the matrix to be set to identity. NULL can be provided. |
mat except if it was NULL. | double** load_dmat_0 | ( | int | nb_r, |
| int | nb_c, | ||
| char * | name | ||
| ) |
load a [nb_r times nb_c] matrix of doubles from a file starting with index 0. The matrix is created (memory allocation) and filled with the values from the file.
| [in] | nb_r | nb of rows |
| [in] | nb_c | nb of columns |
| [in] | name | the path an name of the file in which loading the matrix |
| void matmul_3x3_arr | ( | double | res[3][3], |
| double | mat_1[3][3], | ||
| double | mat_2[3][3] | ||
| ) |
Compute the product of two matrices.
The dimension of the array is 3x3:
The function support in place computation.
| [out] | res | The results: (first line and row unused). This can be the same array as mat_1 or mat_2. |
| [in,out] | mat_1 | Matrix of size 3x3. |
| [in,out] | mat_2 | Matrix of size 3x3. |
| double** matmul_3x3_ptr | ( | double ** | res, |
| double ** | mat_1, | ||
| double ** | mat_2 | ||
| ) |
Compute the product of two matrices.
The first index is 0, the pointer should point to 3 pointers of 3 doubles:
The function support in place computation.
A new matrix is allocated if res is NULL. The memory must be freed by the caller.
| [out] | res | The results: (first line and row unused). This can be the same array as mat_1 or mat_2. |
| [in,out] | mat_1 | Matrix of size 3x3. |
| [in,out] | mat_2 | Matrix of size 3x3. |
res except if it was NULL. | void matmul_4x4_arr | ( | double | res[4][4], |
| double | mat_1[4][4], | ||
| double | mat_2[4][4] | ||
| ) |
Compute the product of two matrices.
The first index is 1, the dimension of the array is 4x4:
The function support in place computation.
| [out] | res | The results: (first line and row unused). This can be the same array as mat_1 or mat_2. |
| [in,out] | mat_1 | Matrix of size 4x4 with first line and row unused. |
| [in,out] | mat_2 | Matrix of size 4x4 with first line and row unused. |
| double** matmul_4x4_ptr | ( | double ** | res, |
| double ** | mat_1, | ||
| double ** | mat_2 | ||
| ) |
Compute the product of two matrices.
The first index is 1, the pointer should point to 4 pointers of 4 doubles:
The function support in place computation.
A new matrix is allocated if res is NULL. The memory must be freed by the caller.
| [out] | res | The results: (first line and row unused). This can be the same array as mat_1 or mat_2. |
| [in,out] | mat_1 | Matrix of size 4x4. |
| [in,out] | mat_2 | Matrix of size 4x4. |
res except if it was NULL. | void matrix_product | ( | double | M[4][4], |
| double | v[4], | ||
| double | Mv[4] | ||
| ) |
DEPRECATED, see dot_4x4_arr()
| void matrix_product_0 | ( | double ** | M, |
| double * | v, | ||
| double * | Mv, | ||
| int | nr, | ||
| int | nc | ||
| ) |
DEPRECATED, see dot_ptr_0()
| void matrix_product_1 | ( | double ** | M, |
| double * | v, | ||
| double * | v_out, | ||
| int | nr, | ||
| int | nc | ||
| ) |
DEPRECATED, see dot_ptr_1()
| void mult_dmat_0 | ( | double ** | A, |
| double ** | B, | ||
| double ** | C, | ||
| int | n1, | ||
| int | n2, | ||
| int | n3 | ||
| ) |
function to multiply two matrices: A * B = C [n1 n2] [n2 n3] = [n1 n3]
| [in] | A | the matrix A |
| [in] | B | the matrix B |
| [out] | C | the matrix C |
| [in] | n1 | first size |
| [in] | n2 | second size |
| [in] | n3 | third size |
| void opposite_dmat_0 | ( | double ** | A, |
| int | n1, | ||
| int | n2 | ||
| ) |
function to take the opposite of a given matrix (minus in front of each entry)
| [in] | A | the matrix A |
| [in] | n1 | first size |
| [in] | n2 | second size |
| void print_dmat_0 | ( | double ** | mat, |
| int | nb_r, | ||
| int | nb_c | ||
| ) |
print a [nb_r times nb_c] matrix of doubles in console, starting with index 0
call print_format_dmat_0 with default parameter (format = "% -f").
| [in] | mat | the matrix to be printed |
| [in] | nb_r | nb of rows |
| [in] | nb_c | nb of columns |
| void print_format_dmat_0 | ( | double ** | mat, |
| int | nb_r, | ||
| int | nb_c, | ||
| char * | format | ||
| ) |
print a [nb_r times nb_c] matrix of doubles in console, starting with index 0
| [in] | mat | the matrix to be printed |
| [in] | nb_r | nb of rows |
| [in] | nb_c | nb of columns |
| [in] | format | the chosen format. |
| void print_imat_0 | ( | int ** | mat, |
| int | nb_r, | ||
| int | nb_c | ||
| ) |
print a [nb_r times nb_c] matrix of integers in console, starting with index 0
| [in] | mat | the matrix to be printed |
| [in] | nb_r | nb of rows |
| [in] | nb_c | nb of columns |
| double** re_copy_dmat_0 | ( | double ** | src, |
| int | s_nx, | ||
| int | s_ny, | ||
| double ** | dest, | ||
| int | d_nx, | ||
| int | d_ny | ||
| ) |
Copy a 2D 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 along axis 0 of the source array, 0 value will free dest. |
| [in] | s_ny | Size along axis 1 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 along axis 0 of the source array. If 0, dest is reallocated. |
| [in] | d_ny | Size along axis 1 of the source array. If 0, dest is reallocated. |
dest has been freed, the pointer to the memory containing the copy. If (re)allocation has occured, the memory is CONTIGUOUS. | double** re_copy_dmat_1 | ( | double ** | src, |
| int | s_nx, | ||
| int | s_ny, | ||
| double ** | dest, | ||
| int | d_nx, | ||
| int | d_ny | ||
| ) |
Copy a 2D 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 along axis 0 of the source array. |
| [in] | s_ny | Size along axis 1 of the source array. |
| [out] | dest | Destination array to be filled. The array is reallocated if s_nx and s_ny does not match d_nx and d_ny. It is allocated if NULL is provided. |
| [in] | d_nx | Size along axis 0 of the source array. |
| [in] | d_ny | Size along axis 1 of the source array. |
dest has been freed, the pointer to the memory containing the copy. If (re)allocation has occured, the memory is CONTIGUOUS. | 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 a matrix provided by the user. The first nb_r line of the file are loaded, other lines are ignored.
| [in] | nb_r | nb of rows |
| [in] | nb_c | nb of columns |
| [in] | name | the path an name of the file in which reading the matrix |
| [in,out] | mat | allocated array for storing the file |
| void readmatrix | ( | double ** | matrix, |
| int * | n | ||
| ) |
function to read a matrix (obsolete?)
| [in,out] | matrix | the matrix |
| [in] | n | the vector n |
| int rotation_matrix | ( | int | type, |
| double | angle, | ||
| double | R[4][4] | ||
| ) |
DEPRECATED, see rotation_matrix_4x4_arr().
| int rotation_matrix_3x3_ptr | ( | int | type, |
| double | angle, | ||
| double ** | R | ||
| ) |
Compute the rotation matrix for a specified angle around a specific axis.
The first index is 0, the dimension of the array is 3x3:
Consider:
O: the original frame;D: the destination frame;Then the function returns the matrix
. It allows to pass the coordinates of a vector between frames:
\f\mathbf{vec_D} =$\mathbf{R_D_O}\cdot\mathbf{vec_O}
@_fakenl1=\hat{X}
@_fakenl2=\hat{Y}
@_fakenl3=\hat{Z}
\mathbf{R_D_O} 
| [in] | type | integer for axis selection:
|
| [in] | angle | value of the rotation angle expressed in radians. |
| [in,out] | R | corresponding rotation matrix as pointer of size 3x3 with first line and row unused. |
| int rotation_matrix_4x4_ptr | ( | int | type, |
| double | angle, | ||
| double ** | R | ||
| ) |
Compute the rotation matrix for a specified angle around a specific axis.
The first index is 1, the dimension of the array is 4x4:
Consider:
O: the original frame;D: the destination frame;Then the function returns the matrix
. It allows to pass the coordinates of a vector between frames:
\f\mathbf{vec_D} =$\mathbf{R_D_O}\cdot\mathbf{vec_O}
@_fakenl1=\hat{X}
@_fakenl2=\hat{Y}
@_fakenl3=\hat{Z}
\mathbf{R_D_O} 
| [in] | type | integer for axis selection:
|
| [in] | angle | value of the rotation angle expressed in radians. |
| [in,out] | R | corresponding rotation matrix as pointer of size 4x4 with first line and row unused. |
| int same_dmat_0 | ( | double ** | a, |
| double ** | b, | ||
| int | x, | ||
| int | y | ||
| ) |
Compare if two 2D arrays of floats are the same.
| [in] | a | The first array, starting with index 0. |
| [in] | b | The second array, starting with index 0. |
| [in] | x | The number of rows. |
| [in] | y | The number of cols. |
| int save_dmat_0 | ( | double ** | mat, |
| int | nb_r, | ||
| int | nb_c, | ||
| char * | name | ||
| ) |
save a [nb_r times nb_c] matrix of doubles to a second matrix, starting with index 0
It call save_format_dmat_0() with default parameter (format = "%12.5e").
More details about the behavior, the parameters and errors in save_format_dmat_0().
| [in] | mat | the matrix to save, starting with index 0 |
| [in] | nb_r | nb of rows |
| [in] | nb_c | nb of columns |
| [in] | name | the path and name of the file in which saving the matrix |
| int save_format_dmat_0 | ( | double ** | mat, |
| int | nb_r, | ||
| int | nb_c, | ||
| char * | name, | ||
| char * | format | ||
| ) |
save a [nb_r times nb_c] matrix of doubles to a second matrix, starting with index 0.
The file is open with the option "wt".
The function will create, if missing, the directory for the file.
The value are separated by space, the file ends at the end of the last line of value (no blank final line).
Providing a NULL matrix pointer with null size in both dimension (nb_r, nb_c) write an empty file. Mixing null (NULL or 0) and non-null values generates an error.
| [in] | mat | the matrix to save, starting with index 0. Can be NULL if the number of rows and columns are 0. |
| [in] | nb_r | Number of rows, must be positive (or null under conditions). |
| [in] | nb_c | Number of columns, must be positive (or null under conditions). |
| [in] | name | The path and name of the file in which saving the matrix. The function will try to create the path if needed. |
| [in] | format | The chosen format to print the datas. |
| void scale_matrix | ( | double ** | matrix, |
| int * | n, | ||
| int * | initzeros | ||
| ) |
function to scale matrix (obsolete?)
| [in,out] | matrix | the matrix |
| [in] | n | the vector n |
| [in,out] | initzeros | the vector to arrange |
| int set_diag_dmat_0 | ( | double ** | mat, |
| int | size, | ||
| double | value | ||
| ) |
Set a diagonal matrix with the given value.
Out-of-diagonal elements are set to zero.
| mat | Pointer to the matrix, starting with index 0. |
| size | The size of the matrix. |
| value | The value to be set on the diagonal |
| int set_identity_dmat_0 | ( | double ** | mat, |
| int | size | ||
| ) |
Set a matrix to identity matrix. Out-of-diagonal elements are set to zero.
| mat | Pointer to the matrix, starting with index 0. |
| size | The size of the matrix. |
| int slct_dmat_0 | ( | double ** | tab_src, |
| int | nb_r, | ||
| int | nb_c, | ||
| double ** | tab_out, | ||
| int | l_vec, | ||
| int * | vec | ||
| ) |
fill the second [nb_r times l_vec] matrix by selecting the columns of the first [nb_r times nb_c] matrix of doubles. The indexes of the columns are specified in the (l_vec sized) vector, starting with index 0
| [in] | tab_src | the matrix containing the original values of doubles to be sliced |
| [in] | nb_r | nb of rows of the matrices |
| [in] | nb_c | nb of columns of the first matrix (unused) |
| [out] | tab_out | the sliced matrix such as tab_out[i][j] = tab_src[i][vec[j]], starting with index 0. The matrix have to be already allocated to a sufficient size. |
| [in] | l_vec | the size of the vector vec |
| [in] | vec | the vector containing the indexes of the slices |
| int slctr_dmat_0 | ( | double ** | tab_src, |
| int | nb_r, | ||
| int | nb_c, | ||
| double ** | tab_dest, | ||
| int | l_vec, | ||
| int * | vec | ||
| ) |
fill the second [l_vec times nb_c] matrix by selecting the rows of the first [nb_r times nb_c] matrix of doubles. The indexes of the rows are specified in the (l_vec sized) vector, starting with index 0
| [in] | tab_src | the matrix containing the original values of doubles to be sliced |
| [in] | nb_r | nb of rows of the first matrix (unused) |
| [in] | nb_c | nb of columns of the matrices |
| [out] | tab_dest | the sliced matrix such as tab_dest[i][j] = tab_src[vec[i]][j], starting with index 0. The matrix have to be already allocated to a sufficient size. |
| [in] | l_vec | the size of the vector vec |
| [in] | vec | the vector containing the indexes of the slices |
| void sum_dmat_0 | ( | double ** | A, |
| double ** | B, | ||
| double ** | C, | ||
| int | n1, | ||
| int | n2 | ||
| ) |
function to sum two matrices: A + B = C
| [in] | A | the matrix A |
| [in] | B | the matrix B |
| [out] | C | the matrix C |
| [in] | n1 | first size |
| [in] | n2 | second size |
| void transpose | ( | double | M[4][4], |
| double | Mt[4][4] | ||
| ) |
Compute the transpose of a matrix with first index is 1.
The input and output matrices have unused index 0. See get_dmat_1() to such matrices creation.
| [in] | M | matrix with first line and row unused. |
| [in,out] | Mt | the transpose of M, index starting at 1. |
| void transpose_dmat_0 | ( | double ** | tab_src, |
| double ** | tab_dest, | ||
| int | nb_r, | ||
| int | nb_c | ||
| ) |
Transpose a [nb_r times nb_c] matrix of doubles and store the results in a [y times nb_r] matrix, starting with index 0.
| [in] | tab_src | the original matrix of doubles, starting with index 0 |
| [out] | tab_dest | the transpose of tab_src, starting with index 0 |
| [in] | nb_r | nb of rows of tab_src, nb of columns of tab_dest |
| [in] | nb_c | nb of columns of tab_src, nb of rows of tab_dest |
| void transpose_dmat_1 | ( | double ** | tab_src, |
| double ** | tab_dest, | ||
| int | x, | ||
| int | y | ||
| ) |
Transpose a [x times y] matrix of doubles and store the results in a [y times x] matrix, starting with index 1.
| [in] | tab1 | the original matrix of doubles, starting with index 1 |
| [out] | tab2 | the transpose of tab1, starting with index 1 |
| [in] | x | nb of rows of tab1, nb of columns of tab2 (without counting the unused first row/colum) |
| [in] | y | nb of columns of tab1, nb of rows of tab2 (without counting the unused first row/colum) |
| void update_initzeros | ( | int * | initzeros, |
| double ** | matrix, | ||
| int * | n | ||
| ) |
function to update the initzeros array (obsolete?)
| [in,out] | initzeros | the vector to initialize |
| [in,out] | matrix | the matrix |
| [in] | n | the vector n |
| void zeros_dmat_0 | ( | double ** | mat, |
| int | nb_r, | ||
| int | nb_c | ||
| ) |
set all the element of a [nb_r times nb_c] matrix of doubles to zero, starting with index 0
| [in] | mat | the matrix to be nullified, starting with index 0 |
| [in] | nb_r | nb of rows |
| [in] | nb_c | nb of columns |
1.8.17