diff options
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; } |