diff options
author | bonmas14 <bonmas14@gmail.com> | 2025-08-23 01:28:41 +0300 |
---|---|---|
committer | bonmas14 <bonmas14@gmail.com> | 2025-08-23 01:28:41 +0300 |
commit | 8ebdc95621bc61fdf3c98cd7ae4ddca67398df23 (patch) | |
tree | 205413ed09ac001e37267889d429a363c37008f2 /tests/un/mathd.c | |
parent | c96c355b360f18f982459e1a866dcbf5864efdb8 (diff) | |
download | ungrateful-main.tar.gz ungrateful-main.zip |
Diffstat (limited to 'tests/un/mathd.c')
-rw-r--r-- | tests/un/mathd.c | 28 |
1 files changed, 28 insertions, 0 deletions
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; } |