summaryrefslogtreecommitdiff
path: root/tests.c
diff options
context:
space:
mode:
authorJasper2025-09-09 12:16:26 +0200
committerJasper2025-09-09 12:16:26 +0200
commit5fd2f59d9f30253cb0c64a06a4a305e90b89e3ae (patch)
tree1fa55449eb91489a428eeb48307d7d314b208860 /tests.c
parent29f92b1c7dad80b40654f561fbe82f5c1d9df7b2 (diff)
Variadic functions to free matrices/vectors
Renamed 'matrix_freen' to 'matrix_free_many1'. Frees a dynamic array of matrices.
Diffstat (limited to 'tests.c')
-rw-r--r--tests.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests.c b/tests.c
index 2a89316..9ff1850 100644
--- a/tests.c
+++ b/tests.c
@@ -4,6 +4,7 @@
#include "vector.h"
#include <assert.h>
+#include <stdlib.h>
void test_LR()
{
@@ -11,15 +12,17 @@ void test_LR()
Vector *b = vector_from_str("[-1;2;3]");
Matrix **LR = matrix_LR(A, b);
- Matrix *L = LR[0];
- Matrix *R = LR[1];
- Vector *y = matrix_forwardel(L, b);
- Vector *x = matrix_backsubst(R, y);
+ Vector *y = matrix_forwardel(LR[0], b);
+ Vector *x = matrix_backsubst(LR[1], y);
vector_print(x);
/* TODO: Implement matrix vector multiplication */
/* assert(matrix_eq(matrix_mult(A, x), b, 0.01)); */
+
+ matrix_free(A);
+ matrix_free_many1(LR);
+ vector_free_many(3, x, y, b);
}
void run_tests()