summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--matrix.h19
-rw-r--r--vector.c1
2 files changed, 20 insertions, 0 deletions
diff --git a/matrix.h b/matrix.h
index 75e605e..85dfa2b 100644
--- a/matrix.h
+++ b/matrix.h
@@ -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
diff --git a/vector.c b/vector.c
index e5bf717..bc2fa2f 100644
--- a/vector.c
+++ b/vector.c
@@ -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);
}