#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <gandalf/common/misc_defs.h>
#include <gandalf/common/misc_error.h>
#include <gandalf/linalg/linalg_defs.h>
#include <gandalf/linalg/vec_gen.h>
#include <gandalf/linalg/mat_square.h>
Go to the source code of this file.
Classes | |
struct | Gan_Matrix |
Structure definition for double precision general size matrix. More... | |
Defines | |
#define | GAN_MATRIX_STRUCT_DEFINED |
#define | Gan_SquMatrix struct Gan_SquMatrix |
#define | gan_mat_realloc(A, rows, cols) gan_mat_realloc_gen(A,rows,cols) |
Typedefs | |
typedef Gan_Matrix | Gan_Matrix |
Structure definition for double precision general size matrix. | |
Functions | |
void | gan_mat_free (Gan_Matrix *A) |
Free a matrix. | |
Gan_Matrix * | gan_mat_set_dims (Gan_Matrix *A, unsigned long rows, unsigned long cols) |
Set dimensions of generic matrix. | |
Gan_Matrix * | gan_mat_fill_va (Gan_Matrix *A, unsigned long rows, unsigned long cols,...) |
Fill matrix from variable argument list. | |
Gan_Matrix * | gan_mat_fill_vap (Gan_Matrix *A, unsigned long rows, unsigned long cols, va_list *aptr) |
Fill matrix from variable argument list. | |
Gan_Matrix * | gan_mat_fill_const_q (Gan_Matrix *A, unsigned long rows, unsigned long cols, double value) |
Fill all elements of a matrix with the same value. | |
Gan_Bool | gan_mat_read_va (const Gan_Matrix *A, unsigned long rows, unsigned long cols,...) |
Read elements of matrix from variable argument list. | |
Gan_Matrix * | gan_mat_copy_q (const Gan_Matrix *A, Gan_Matrix *B) |
Copy matrix. | |
Gan_Matrix * | gan_mat_scale_q (Gan_Matrix *A, double a, Gan_Matrix *B) |
Multiply matrix by scalar. | |
Gan_Matrix * | gan_mat_divide_q (Gan_Matrix *A, double a, Gan_Matrix *B) |
Divide matrix by scalar. | |
Gan_Matrix * | gan_mat_tpose_q (Gan_Matrix *A, Gan_Matrix *B) |
Transpose matrix. | |
Gan_Matrix * | gan_mat_insertsym (Gan_Matrix *A, unsigned long rA, unsigned long cA, const struct Gan_SquMatrix *B, unsigned long rB, unsigned long cB, unsigned long rows, unsigned long cols) |
Gan_Bool | gan_mat_is_zero (Gan_Matrix *A) |
Checks whether a matrix is zero. | |
void | gan_mat_free_va (Gan_Matrix *A,...) |
Free a NULL terminated variable argument list of matrices. | |
Gan_Matrix * | gan_mat_extract_q (const Gan_Matrix *A, unsigned long r0, unsigned long c0, unsigned long rows, unsigned long cols, Gan_Matrix *B) |
Extracts rectangular part of matrix. | |
double | gan_mat_sumsqr (const Gan_Matrix *A) |
Returns squared Frobenius norm of generic rectangular matrix. | |
double | gan_mat_Fnorm (const Gan_Matrix *A) |
Returns Frobenius norm of generic rectangular matrix. | |
Gan_Matrix * | gan_mat_invert_q (const Gan_Matrix *A, Gan_Matrix *B) |
Inverts general square matrix. | |
Gan_Bool | gan_mat_fprint (FILE *fp, const Gan_Matrix *A, const char *prefix, unsigned indent, const char *fmt) |
Print matrix to file pointer. | |
Gan_Matrix * | gan_mat_fscanf_q (FILE *fp, Gan_Matrix *A, char *prefix, int prefix_len) |
Read matrix from file. | |
Gan_Bool | gan_mat_fwrite (FILE *fp, const Gan_Matrix *A, gan_uint32 magic_number) |
Print matrix to binary file pointer. | |
Gan_Matrix * | gan_mat_fread_q (FILE *fp, Gan_Matrix *A, gan_uint32 *magic_number) |
Read matrix from file in binary format. | |
Gan_Matrix * | gan_mat_alloc (unsigned long rows, unsigned long cols) |
Macro: Allocate and return a generic matrix. | |
Gan_Matrix * | gan_mat_form (Gan_Matrix *A, unsigned long rows, unsigned long cols) |
Macro: Form and return a generic matrix. | |
Gan_Matrix * | gan_mat_form_data (Gan_Matrix *A, unsigned long rows, unsigned long cols, double *data, size_t data_size) |
Macro: Form and return a generic matrix. | |
Gan_Bool | gan_mat_set_el (Gan_Matrix *A, unsigned i, unsigned j, double value) |
Macro: Set specific element of matrix. | |
double | gan_mat_get_el (const Gan_Matrix *A, unsigned i, unsigned j) |
Macro: Get specific element of matrix. | |
Gan_Bool | gan_mat_inc_el (Gan_Matrix *A, unsigned i, unsigned j, double value) |
Macro: Increment specific element of matrix by given value. | |
Gan_Bool | gan_mat_dec_el (Gan_Matrix *A, unsigned i, unsigned j, double value) |
Macro: Decrement specific element of matrix by given value. | |
Gan_Bool | gan_mat_print (const Gan_Matrix *A, const char *prefix, int indent, const char *fmt) |
Macro: Print matrix to standard output. | |
Gan_Matrix * | gan_mat_fill_const_s (unsigned long rows, unsigned long cols, double value) |
Macro: Allocate and fill elements of a matrix with the same value. | |
Gan_Matrix * | gan_mat_fill_zero_q (Gan_Matrix *A, unsigned long rows, unsigned long cols) |
Macro: Fill matrix with zeros. | |
Gan_Matrix * | gan_mat_fill_zero_s (unsigned long rows, unsigned cols) |
Macro: Allocate and fill matrix with zeros. | |
Gan_Matrix * | gan_mat_copy_s (const Gan_Matrix *A) |
Macro: Copy matrix. | |
Gan_Matrix * | gan_mat_scale_s (Gan_Matrix *A, double a) |
Macro: Multiply matrix by scalar. | |
Gan_Matrix * | gan_mat_scale_i (Gan_Matrix *A, double a) |
Macro: Multiply matrix by scalar. | |
Gan_Matrix * | gan_mat_divide_s (Gan_Matrix *A, double a) |
Macro: Divide matrix by scalar. | |
Gan_Matrix * | gan_mat_divide_i (Gan_Matrix *A, double a) |
Macro: Divide matrix by scalar. | |
Gan_Matrix * | gan_mat_negate_q (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Negate matrix. | |
Gan_Matrix * | gan_mat_negate_s (Gan_Matrix *A) |
Macro: Negate matrix. | |
Gan_Matrix * | gan_mat_negate_i (Gan_Matrix *A) |
Macro: Negate matrix. | |
Gan_Matrix * | gan_mat_tpose_s (Gan_Matrix *A) |
Macro: Transpose matrix. | |
Gan_Matrix * | gan_mat_tpose_i (Gan_Matrix *A) |
Macro: Transpose matrix. | |
Gan_Matrix * | gan_mat_add_q (Gan_Matrix *A, Gan_Matrix *B, Gan_Matrix *C) |
Macro: Add two matrices and write result into a third. | |
Gan_Matrix * | gan_mat_add_s (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Add two matrices and return the result as a new matrix. | |
Gan_Matrix * | gan_mat_add_i1 (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Add two matrices and overwrite the first with the result. | |
Gan_Matrix * | gan_mat_add_i2 (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Add two matrices and overwrite the second with the result. | |
Gan_Matrix * | gan_mat_increment (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Increment a matrix with another matrix. | |
Gan_Matrix * | gan_mat_addT_q (Gan_Matrix *A, Gan_Matrix *B, Gan_Matrix *C) |
Macro: Add two matrices, the second transposed, and write result into a third. | |
Gan_Matrix * | gan_mat_addT_s (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Add two matrices, the second transposed, and return a new result matrix. | |
Gan_Matrix * | gan_mat_incrementT (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Increment a matrix with the transpose of another matrix. | |
Gan_SquMatrix * | gan_mat_add_sym_q (const Gan_Matrix *A, const Gan_Matrix *B, Gan_SquMatrix *C) |
Macro: Add two matrices and write result into a symmetric matrix. | |
Gan_SquMatrix * | gan_mat_add_sym_s (const Gan_Matrix *A, Gan_Matrix *B) |
Macro: Add two matrices and return the result as a new symmetric matrix. | |
Gan_SquMatrix * | gan_mat_addT_sym_q (const Gan_Matrix *A, const Gan_Matrix *B, Gan_SquMatrix *C) |
Macro: Add two matrices and write result into a symmetric matrix. | |
Gan_SquMatrix * | gan_mat_addT_sym_s (const Gan_Matrix *A, const Gan_Matrix *B) |
Macro: Add two matrices and return the result as a new symmetric matrix. | |
Gan_SquMatrix * | gan_matT_add_sym_q (const Gan_Matrix *A, const Gan_Matrix *B, Gan_SquMatrix *C) |
Macro: Add two matrices and write result into a symmetric matrix. | |
Gan_SquMatrix * | gan_matT_add_sym_s (const Gan_Matrix *A, const Gan_Matrix *B) |
Macro: Add two matrices and return the result as a new symmetric matrix. | |
Gan_SquMatrix * | gan_matT_addT_sym_q (Gan_Matrix *A, Gan_Matrix *B, Gan_SquMatrix *C) |
Macro: Add two matrices and write result into a symmetric matrix. | |
Gan_SquMatrix * | gan_matT_addT_sym_s (const Gan_Matrix *A, const Gan_Matrix *B) |
Macro: Add two matrices and return the result as a new symmetric matrix. | |
Gan_SquMatrix * | gan_mat_saddT_sym_q (const Gan_Matrix *A, const Gan_SquMatrix *B) |
Macro: Add matrix to itself and write result into a symmetric matrix. | |
Gan_SquMatrix * | gan_mat_saddT_sym_s (const Gan_Matrix *A) |
Macro: Add matrix to itself and return the result as a new symmetric matrix. | |
Gan_SquMatrix * | gan_matT_sadd_sym_q (const Gan_Matrix *A, Gan_SquMatrix *B) |
Macro: Add matrix to itself and write result into a symmetric matrix. | |
Gan_SquMatrix * | gan_matT_sadd_sym_s (const Gan_Matrix *A) |
Macro: Add matrix to itself and return the result as a new symmetric matrix. | |
Gan_Matrix * | gan_mat_sub_q (Gan_Matrix *A, Gan_Matrix *B, Gan_Matrix *C) |
Macro: Subtract two matrices and write result into a third. | |
Gan_Matrix * | gan_mat_sub_s (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Subtract two matrices and return the result as a new matrix. | |
Gan_Matrix * | gan_mat_sub_i1 (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Subtract two matrices and overwrite the first with the result. | |
Gan_Matrix * | gan_mat_sub_i2 (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Subtract two matrices and overwrite the second with the result. | |
Gan_Matrix * | gan_mat_decrement (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Decrement a matrix with another matrix. | |
Gan_Matrix * | gan_mat_subT_q (Gan_Matrix *A, Gan_Matrix *B, Gan_Matrix *C) |
Macro: Subtract two matrices, the second transposed, and write result into a third. | |
Gan_Matrix * | gan_mat_subT_s (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Subtract two matrices, the second transposed, and return new result matrix. | |
Gan_Matrix * | gan_mat_decrementT (Gan_Matrix *A, Gan_Matrix *B) |
Macro: Decrement a matrix with the transpose of another matrix. | |
Gan_Vector * | gan_mat_multv_q (const Gan_Matrix *A, const Gan_Vector *x, Gan_Vector *y) |
Macro: Multiply matrix and a vector, writing the result into another vector. | |
Gan_Vector * | gan_mat_multv_s (const Gan_Matrix *A, const Gan_Vector *x) |
Macro: Multiply matrix and a vector, returning the result as a new vector. | |
Gan_Vector * | gan_matT_multv_q (const Gan_Matrix *A, const Gan_Vector *x, Gan_Vector *y) |
Macro: Multiply the transpose of a matrix by a vector. | |
Gan_Vector * | gan_matT_multv_s (const Gan_Matrix *A, const Gan_Vector *x) |
Macro: Multiply transpose of matrix by a vector. | |
Gan_Matrix * | gan_mat_rmult_q (const Gan_Matrix *A, const Gan_Matrix *B, Gan_Matrix *C) |
Macro: Multiply two matrices and write result into a third. | |
Gan_Matrix * | gan_mat_rmult_s (const Gan_Matrix *A, const Gan_Matrix *B) |
Macro: Multiply two matrices and return the result as a new matrix. | |
Gan_Matrix * | gan_mat_rmultT_q (const Gan_Matrix *A, const Gan_Matrix *B, Gan_Matrix *C) |
Macro: Multiply a matrix by the transpose of another and write result into a third. | |
Gan_Matrix * | gan_mat_rmultT_s (const Gan_Matrix *A, const Gan_Matrix *B) |
Macro: Multiply a matrix by the transpose of another and return a new matrix. | |
Gan_Matrix * | gan_matT_rmult_q (const Gan_Matrix *A, const Gan_Matrix *B, Gan_Matrix *C) |
Macro: Multiply the transpose of a matrix by another matrix. | |
Gan_Matrix * | gan_matT_rmult_s (const Gan_Matrix *A, const Gan_Matrix *B) |
Macro: Multiply the transpose of a matrix by another matrix. | |
Gan_Matrix * | gan_matT_rmultT_q (const Gan_Matrix *A, const Gan_Matrix *B, Gan_Matrix *C) |
Macro: Multiply the transpose of a matrix by the transpose of another matrix. | |
Gan_Matrix * | gan_matT_rmultT_s (const Gan_Matrix *A, const Gan_Matrix *B) |
Macro: Multiply the transpose of a matrix by the transpose of another matrix. | |
Gan_SquMatrix * | gan_mat_rmult_sym_q (const Gan_Matrix *A, const Gan_Matrix *B, Gan_SquMatrix *C) |
Macro: Multiply two matrices and write result into a symmetric matrix. | |
Gan_SquMatrix * | gan_mat_rmult_sym_s (const Gan_Matrix *A, const Gan_Matrix *B) |
Macro: Multiply two matrices and return the result as a new symmetric matrix. | |
Gan_SquMatrix * | gan_mat_rmultT_sym_q (const Gan_Matrix *A, const Gan_Matrix *B, Gan_SquMatrix *C) |
Macro: Multiply two matrices and write result into a symmetric matrix. | |
Gan_SquMatrix * | gan_mat_rmultT_sym_s (const Gan_Matrix *A, const Gan_Matrix *B) |
Macro: Multiply two matrices and return the result as a new symmetric matrix. | |
Gan_SquMatrix * | gan_matT_rmult_sym_q (const Gan_Matrix *A, const Gan_Matrix *B, Gan_SquMatrix *C) |
Macro: Multiply two matrices and write result into a symmetric matrix. | |
Gan_SquMatrix * | gan_matT_rmult_sym_s (const Gan_Matrix *A, const Gan_Matrix *B) |
Macro: Multiply two matrices and return the result as a new symmetric matrix. | |
Gan_SquMatrix * | gan_matT_rmultT_sym_q (const Gan_Matrix *A, const Gan_Matrix *B, Gan_SquMatrix *C) |
Macro: Multiply two matrices and write result into a symmetric matrix. | |
Gan_SquMatrix * | gan_matT_rmultT_sym_s (const Gan_Matrix *A, const Gan_Matrix *B) |
Macro: Multiply two matrices and return the result as a new symmetric matrix. | |
Gan_SquMatrix * | gan_mat_srmultT_q (const Gan_Matrix *A, const Gan_SquMatrix *B) |
Macro: Multiply matrix by itself and write result into a symmetric matrix. | |
Gan_SquMatrix * | gan_mat_srmultT_s (const Gan_Matrix *A) |
Macro: Multiply matrix by itself and return the result as a new symmetric matrix. | |
Gan_SquMatrix * | gan_mat_slmultT_q (const Gan_Matrix *A, Gan_SquMatrix *B) |
Macro: Multiply matrix by itself and write result into a symmetric matrix. | |
Gan_SquMatrix * | gan_mat_slmultT_s (const Gan_Matrix *A) |
Macro: Multiply matrix by itself and return the result as a new symmetric matrix. | |
Gan_Matrix * | gan_mat_invert_s (const Gan_Matrix *A) |
Macro: Inverts general square matrix. | |
Gan_Bool | gan_mat_same_dims (const Gan_Matrix *A, const Gan_Matrix *B) |
Macro: Checks that two matrices have the same number of rows and columns. | |
Gan_Matrix * | gan_mat_insert (Gan_Matrix *A, unsigned long rA, unsigned long cA, const Gan_Matrix *B, unsigned long rB, unsigned long cB, unsigned long rows, unsigned long cols) |
Macro: Insert part of generic matrix in another generic matrix. | |
Gan_Matrix * | gan_mat_insertT (Gan_Matrix *A, unsigned long rA, unsigned long cA, const Gan_Matrix *B, unsigned long rB, unsigned long cB, unsigned long rows, unsigned long cols) |
Macro: Insert transpose of part of generic matrix in another generic matrix. | |
Gan_Matrix * | gan_mat_insertv (Gan_Matrix *A, unsigned long rA, unsigned long cA, const Gan_Vector *x, unsigned long rx, unsigned long rows) |
Macro: Insert part of column vector in a generic matrix. | |
Gan_Matrix * | gan_mat_insertvT (Gan_Matrix *A, unsigned long rA, unsigned long cA, const Gan_Vector *x, unsigned long rx, unsigned long cols) |
Macro: Insert part of row vector in a generic matrix. | |
Gan_Bool | gan_mat_test_dims (const Gan_Matrix *A, unsigned long rows, unsigned long cols) |
Macro: Test dimensions of generic matrix. | |
size_t | gan_mat_data_size (unsigned long rows, unsigned long cols) |
Macro: Returns size of data array in bytes needed to hold matrix data. | |
Gan_Matrix * | gan_mat_extract_s (const Gan_Matrix *A, unsigned long r0, unsigned long c0, unsigned long rows, unsigned long cols) |
Macro: Extracts rectangular part of matrix. | |
Gan_Matrix * | gan_mat_fscanf_s (FILE *fp, const char *prefix, int prefix_len) |
Macro: Read matrix from file. | |
Gan_Matrix * | gan_mat_fread_s (FILE *fp, gan_uint32 *magic_number) |
Macro: Read matrix from file. | |
Gan_Matrix * | gan_mat_form_gen (Gan_Matrix *A, unsigned long rows, unsigned long cols, double *data, size_t data_size) |
Gan_Bool | gan_mat_realloc_gen (Gan_Matrix *A, unsigned long rows, unsigned long cols) |
Gan_Matrix * | gan_mat_add_gen (Gan_Matrix *A, Gan_TposeFlag A_tr, Gan_Matrix *B, Gan_TposeFlag B_tr, Gan_Matrix *C) |
Add general size matrices. | |
Gan_SquMatrix * | gan_mat_add_sym_gen (const Gan_Matrix *A, Gan_TposeFlag A_tr, const Gan_Matrix *B, Gan_TposeFlag B_tr, struct Gan_SquMatrix *C) |
Add general size matrices producing a symmetric matrix. | |
Gan_Matrix * | gan_mat_sub_gen (Gan_Matrix *A, Gan_TposeFlag A_tr, Gan_Matrix *B, Gan_TposeFlag B_tr, Gan_Matrix *C) |
Subtract general size matrices. | |
Gan_Vector * | gan_mat_multv_gen (const Gan_Matrix *A, Gan_TposeFlag A_tr, const Gan_Vector *x, Gan_Vector *y) |
Multiply matrix and a vector. | |
Gan_Matrix * | gan_mat_rmult_gen (const Gan_Matrix *A, Gan_TposeFlag A_tr, const Gan_Matrix *B, Gan_TposeFlag B_tr, Gan_Matrix *C) |
Gan_SquMatrix * | gan_mat_rmult_sym_gen (const Gan_Matrix *A, Gan_TposeFlag A_tr, const Gan_Matrix *B, Gan_TposeFlag B_tr, struct Gan_SquMatrix *C) |
Gan_Matrix * | gan_mat_insert_gen (Gan_Matrix *A, unsigned long rA, unsigned long cA, const Gan_Matrix *B, Gan_TposeFlag B_tr, unsigned long rB, unsigned long cB, unsigned long rows, unsigned long cols) |
Insert part of generic matrix in another generic matrix. | |
Gan_Matrix * | gan_mat_insertv_gen (Gan_Matrix *A, unsigned long rA, unsigned long cA, const struct Gan_Vector *x, Gan_TposeFlag x_tr, unsigned long rx, unsigned long size) |
Part of: Gandalf Library