#include <float.h>
#include <limits.h>
#include "mbs_matrix.h"
#include "mbs_path.h"
#include "useful_functions.h"
#include "mbs_errors_names.h"
#include "mbs_message.h"
#include "mbs_define.h"
Functions | |
void | transpose (double M[4][4], double Mt[4][4]) |
Compute the transpose of a matrix with first index is 1. More... | |
void | matrix_product (double M[4][4], double v[4], double Mv[4]) |
Compute the product of a matrix by a vector. The first index is 1. More... | |
void | matrix_product_0 (double **M, double *v, double *Mv, int nr, int nc) |
Compute the product of a matrix by a vector. The first index is 0. More... | |
void | matrix_product_1 (double **M, double *v, double *v_out, int nr, int nc) |
Compute the product of a matrix by a vector. The first index is 1. More... | |
void | doublematrix_product (double M1[4][4], double M2[4][4], double M[4][4]) |
Compute the product of two matrices. The first index is 1. 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... | |
void | rotation_matrix (int type, double angle, double R[4][4]) |
Compute the rotation matrix for a specified angle around a specific axis. The first index is 1. More... | |
void | 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 provided matrix is 4x4, given by a pointor. It must be allocated and freed before/after this function. More... | |
void | rotation_matrix_0 (int type, double angle, double R[3][3]) |
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 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... | |
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 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 | 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 **tab1, int **tab2, int x, int y) |
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 x, int y) |
print a [nb_r times nb_c] matrix of integers in console, starting with index 0 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_r1, int nb_c1, double **tab_out, int l2, 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_r1, int nb_c1, double **tab_out, int l2, 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... | |
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 **mat, 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... | |
The header define functions related to 2D (or more) array operation. This include matrix-vector mixed operations. Some functions are still located in file mbs_utilities.c.
Creation date: 2006
(c) Universite catholique de Louvain
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_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 doublematrix_product | ( | double | M1[4][4], |
double | M2[4][4], | ||
double | M[4][4] | ||
) |
Compute the product of two matrices. The first index is 1.
The matrices have unused index 0. See get_dmat_1() to such matrix and vector creation.
[in] | M1 | matrix of size 4x4 with first line and row unused. |
[in] | M2 | matrix of size 4x4 with first line and row unused. |
[in,out] | M | matrix of size 4x4 such as with first line and row unused. |
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
[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
[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) |
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 matrix_product | ( | double | M[4][4], |
double | v[4], | ||
double | Mv[4] | ||
) |
Compute the product of a matrix by a vector. The first index is 1.
The matrices and vector have unused index 0. See get_dmat_1() and get_dvec_1() to such matrix and vector creation.
[in] | M | matrix of size 4x4 with first line and row unused, will be multiplied by v. |
[in] | v | vector of size 4 with first element unused. |
[in,out] | Mv | matrix of size 4x4 such as with first line and row unused. |
void matrix_product_0 | ( | double ** | M, |
double * | v, | ||
double * | Mv, | ||
int | nr, | ||
int | nc | ||
) |
Compute the product of a matrix by a vector. The first index is 0.
See get_dmat_0() and get_dvec_0() to such matrix and vector creation.
[in] | M | matrix of size nr x nc, will be multiplied by v. |
[in] | v | vector of size nc. |
[in] | nr | number of rows of the matrix M and size of the vector Mv. |
[in] | nc | number of columns of the matrix M and size of the vector v. |
[in,out] | Mv | matrix such as with first index 0. |
void matrix_product_1 | ( | double ** | M, |
double * | v, | ||
double * | v_out, | ||
int | nr, | ||
int | nc | ||
) |
Compute the product of a matrix by a vector. The first index is 1.
See get_dmat_1() and get_dvec_1() to such matrix and vector creation.
[in] | M | matrix of size nr x nc (with first line and row unused not counted), will be multiplied by v. |
[in] | v | vector of size nc (with first element unused not counted). |
[in] | nr | number of rows of the matrix M and size of the vector Mv (without counting the unused first row/colum). |
[in] | nc | number of columns of the matrix M and size of the vector v (without counting the unused first row/colum). |
[in,out] | v_out | Vector such as with first index 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 |
void rotation_matrix | ( | int | type, |
double | angle, | ||
double | R[4][4] | ||
) |
Compute the rotation matrix for a specified angle around a specific axis. The first index is 1.
[in] | type | integer for axis selection: ; ; . |
[in] | angle | value of the rotation angle expressed in radian. |
[in,out] | R | corresponding rotation matrix of size 4x4 with first line and row unused. |
void rotation_matrix_0 | ( | int | type, |
double | angle, | ||
double | R[3][3] | ||
) |
void 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 provided matrix is 4x4, given by a pointor. It must be allocated and freed before/after this function.
[in] | type | integer for axis selection: ; ; . |
[in] | angle | value of the rotation angle expressed in radian. |
[in,out] | R | pointor (double) corresponding rotation matrix 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 |