From 5fd2f59d9f30253cb0c64a06a4a305e90b89e3ae Mon Sep 17 00:00:00 2001 From: Jasper Date: Tue, 9 Sep 2025 12:16:26 +0200 Subject: Variadic functions to free matrices/vectors Renamed 'matrix_freen' to 'matrix_free_many1'. Frees a dynamic array of matrices. --- tests.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests.c') 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 +#include 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() -- cgit v1.2.3