diff options
author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-10-18 12:49:39 -0600 |
---|---|---|
committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2023-10-18 12:49:39 -0600 |
commit | 9e7166a52e94d8e15bf2dbfe00026f21f76630a9 (patch) | |
tree | bb4d7114d5f91fa128375347ab4249a4c35408f2 /test/lin.t.c | |
parent | 1b4d91e623a083690ac6554d1aeaa38b75469908 (diff) | |
download | cmath-9e7166a52e94d8e15bf2dbfe00026f21f76630a9.tar.gz cmath-9e7166a52e94d8e15bf2dbfe00026f21f76630a9.zip |
oct 16, 18 notes. add unit tests with utest, and bisection root finding methods
Diffstat (limited to 'test/lin.t.c')
-rw-r--r-- | test/lin.t.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/lin.t.c b/test/lin.t.c new file mode 100644 index 0000000..6ad1613 --- /dev/null +++ b/test/lin.t.c @@ -0,0 +1,20 @@ +#include "lizfcm.test.h" + +UTEST(Lin, least_squares_lin_reg_perfect) { + Array_double *x = InitArray(double, {0, 1, 2, 3, 4}); + Array_double *y = InitArray(double, {1, 2, 3, 4, 5}); + + Line *line = least_squares_lin_reg(x, y); + + EXPECT_EQ(line->m, 1.0); + EXPECT_EQ(line->a, 1.0); +} + +UTEST(Lin, least_squares_lin_reg_estimate) { + Array_double *x = InitArray(double, {1, 2, 3, 4, 5, 6, 7}); + Array_double *y = InitArray(double, {0.5, 3, 2, 3.5, 5, 6, 7.5}); + + Line *line = least_squares_lin_reg(x, y); + + EXPECT_NEAR(line->m, 1.0, 0.2); +} |