diff options
author | Jasper | 2025-09-08 10:05:32 +0200 |
---|---|---|
committer | Jasper | 2025-09-08 10:05:32 +0200 |
commit | bf8973c4617c30b1474bed2b7e399d6bf7f68839 (patch) | |
tree | 7d70ba956fc68d0e8c720744ceefa60bfed5ad41 /matrix.h | |
parent | 16175429d26b6803fd0249d5bbab6eb4cfe6e60b (diff) |
More functions with '1' suffix
Added more versions of existing functions with suffix '1' that take a matrix
as argument and perform the action (e.g. filling a matrix with random
entries) to the passed matrix.
'matrix_add' and 'matrix_scale' save the result in the matrix passed
first.
Diffstat (limited to 'matrix.h')
-rw-r--r-- | matrix.h | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -19,9 +19,6 @@ #define matrix_is_square(mat) ((mat)->m == (mat)->n) -#define TRUE 1 -#define FALSE 0 - typedef enum { MATRIX_DIAG, MATRIX_TRIAG_UPPER, @@ -51,17 +48,23 @@ Matrix *matrix_from_arr(double arr[], size_t m, size_t n); char *matrix_to_str(const Matrix *mat); Matrix *matrix_id(size_t n); Matrix *matrix_const(size_t m, size_t n, double x); +void matrix_const1(Matrix *mat, double x); Matrix *matrix_copy (const Matrix *mat); +void matrix_copy1(Matrix *A, const Matrix *B); Matrix *matrix_swap(const Matrix *mat, MatrixSwapType t, size_t i, size_t j); void matrix_swap1(Matrix *mat, MatrixSwapType t, size_t i, size_t j); double matrix_trace(const Matrix *mat); Matrix *matrix_transpose(const Matrix *mat); Matrix *matrix_add(const Matrix *A, const Matrix *B); +void matrix_add1(Matrix *A, const Matrix *B); Matrix *matrix_scale(const Matrix *A, double x); +void matrix_scale1(Matrix *A, double x); Matrix *matrix_sub(const Matrix *A, const Matrix *B); +void matrix_sub1(Matrix *A, const Matrix *B); Matrix *matrix_mult(const Matrix *A, const Matrix *B); Matrix *matrix_rand(size_t m, size_t n, int bound_l, int bound_u, MatrixType type); -int matrix_eq(const Matrix *A, const Matrix *B, double tol); +void matrix_rand1(Matrix *mat, int bound_l, int bound_u, MatrixType type); +bool matrix_eq(const Matrix *A, const Matrix *B, double tol); double matrix_norm_frob(const Matrix *mat); Matrix **matrix_LR(const Matrix *A, const Matrix *b); Matrix *matrix_forwardel(const Matrix *L, const Matrix *b); |