aboutsummaryrefslogtreecommitdiff
path: root/tester/main.c
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-29 03:55:18 +0200
committerhachem <im@hachem.wtf>2026-08-29 03:55:18 +0200
commit94612a0be0e691d68bcd27a33e529ad30fa3df43 (patch)
tree8d93b8d03ffa3170e07c10cd86b2366c9ca7a30c /tester/main.c
parenta159f48900f1927b05d4b8f3d04459610eb9897e (diff)
add: complex numbers
Diffstat (limited to 'tester/main.c')
-rw-r--r--tester/main.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/tester/main.c b/tester/main.c
new file mode 100644
index 0000000..eb629fc
--- /dev/null
+++ b/tester/main.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+#include "maths/complex.h"
+#include "psi.h"
+
+int main(void)
+{
+ printf("psi %s\n", psi_version());
+
+ struct PsiComplex a = psi_new_complex(1.0, 2.0);
+ struct PsiComplex b = psi_new_complex(3.0, -1.0);
+
+ struct PsiComplex sum = psi_add_complex(a, b);
+ struct PsiComplex product = psi_mul_complex(a, b);
+
+ printf("a = %g + %gi\n", a.real, a.imaginary);
+ printf("b = %g + %gi\n", b.real, b.imaginary);
+ printf("a + b = %g + %gi\n", sum.real, sum.imaginary);
+ printf("a * b = %g + %gi\n", product.real, product.imaginary);
+ printf("|a| = %g\n", psi_abs_complex(a));
+
+ return 0;
+}