summaryrefslogtreecommitdiff
path: root/tests.c
blob: 9ff18502f081038c376f34b730b4cef2f0b9e9af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "tests.h"

#include "matrix.h"
#include "vector.h"

#include <assert.h>
#include <stdlib.h>

void test_LR()
{
    Matrix *A = matrix_from_str("[2 3 1;4 1 -5;-1 2 3]");
    Vector *b = vector_from_str("[-1;2;3]");

    Matrix **LR = matrix_LR(A, b);
    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()
{
    test_LR();
}