From 8ebdc95621bc61fdf3c98cd7ae4ddca67398df23 Mon Sep 17 00:00:00 2001 From: bonmas14 Date: Sat, 23 Aug 2025 01:28:41 +0300 Subject: Ungrateful changes, added more stuff --- tests/un/mathd.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/un/mathd.c') diff --git a/tests/un/mathd.c b/tests/un/mathd.c index 3381dfb..829a4a6 100644 --- a/tests/un/mathd.c +++ b/tests/un/mathd.c @@ -276,5 +276,33 @@ int main() { un_memory_set((void*)v, 0, sizeof(*v) * 4); } + { // Complex + f64 v[2], a[2] = { 1, 2 }, b[2] = { 3, 4 }, c[2] = { 1, 0 }, d[3] = { 0, 1 }; + + un_m_complex_addd(v, a, b); + assert((v[0] - 4.0) < EPSILON); + assert((v[1] - 6.0) < EPSILON); + un_memory_set((void*)v, 0, sizeof(*v) * 2); + + un_m_complex_subd(v, a, b); + assert((v[0] + 2.0) < EPSILON); + assert((v[1] + 2.0) < EPSILON); + un_memory_set((void*)v, 0, sizeof(*v) * 2); + + un_m_complex_muld(v, a, b); + assert((v[0] + 5.0) < EPSILON); + assert((v[1] - 10.0) < EPSILON); + un_memory_set((void*)v, 0, sizeof(*v) * 2); + + un_m_complex_divd(v, c, d); + assert(v[0] < EPSILON); + assert((v[1] + 1.0) < EPSILON); + un_memory_set((void*)v, 0, sizeof(*v) * 2); + + un_m_complex_magnituded(v, c); + assert((v[0] - 1.0) < EPSILON); + un_memory_set((void*)v, 0, sizeof(*v) * 2); + } + return 0; } -- cgit v1.2.3-70-g09d2