diff options
author | Jasper | 2025-09-08 10:50:07 +0200 |
---|---|---|
committer | Jasper | 2025-09-08 10:50:07 +0200 |
commit | f8ec4383f4bdfd9e0d582c2ece55fe22ce08d61c (patch) | |
tree | f07a0c13e7e6fa7b56b8a6edd4c60812183f7743 | |
parent | 1386f6dc5024937c8c9c741efed9274d4861b76f (diff) |
Formatting
-rw-r--r-- | matrix.h | 19 | ||||
-rw-r--r-- | vector.c | 1 |
2 files changed, 20 insertions, 0 deletions
@@ -40,34 +40,53 @@ typedef struct { } Matrix; Matrix *matrix_alloc(size_t m, size_t n); + void matrix_free(Matrix *mat); void matrix_freen(Matrix **mats); + void matrix_print(const Matrix *mat); + Matrix *matrix_from_str(char *str); 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); 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); + Matrix *matrix_backsubst(const Matrix *R, const Matrix *y); #endif @@ -173,6 +173,7 @@ double vector_norm_p(const Vector *v, size_t p) double tmp = 0; vector_foreach(v, it) tmp += pow(ABS(*it), p); + return pow(tmp, 1.0/p); } |