summaryrefslogtreecommitdiffstats
path: root/example/direct.c
diff options
context:
space:
mode:
authorEthan Werner <mail@ethanwerner.com>2024-04-17 16:00:00 -0700
committerEthan Werner <mail@ethanwerner.com>2026-06-08 16:01:49 +0400
commitf6a144987cc403de8ad6bddd055f756120f8d405 (patch)
tree3b4cfc8c76db7adba8504dc0e079466e2a0d336c /example/direct.c
archival commit
Diffstat (limited to 'example/direct.c')
-rw-r--r--example/direct.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/example/direct.c b/example/direct.c
new file mode 100644
index 0000000..102c0c3
--- /dev/null
+++ b/example/direct.c
@@ -0,0 +1,33 @@
+typedef double value_t;
+#define DT_IMPLEMENTATION
+#include "../include/direct.h"
+#include <stdio.h>
+
+int main() {
+ node_t x0 = {.x = 0.0, .function = dt_add};
+ node_t x1 = {.x = 0.0, .function = dt_one};
+ node_t x2 = {.x = 0.0, .function = dt_add};
+ node_t x3 = {.x = 0.0, .function = dt_add};
+ node_t x4 = {.x = 0.0, .function = dt_add};
+ node_t x5 = {.x = 0.0, .function = dt_add};
+ node_t x6 = {.x = 0.0, .function = dt_one};
+
+ dt_connect(&x0, &x2);
+ dt_connect(&x0, &x1);
+ dt_connect(&x0, &x3);
+ dt_connect(&x2, &x1);
+ dt_connect(&x2, &x4);
+ dt_connect(&x3, &x4);
+ dt_connect(&x4, &x5);
+ dt_connect(&x4, &x6);
+ dt_connect(&x5, &x2);
+
+ dt_update_trace(&x0);
+ printf("data: %lf\n", x0.x);
+ dt_update_trace(&x0);
+ printf("data: %lf\n", x0.x);
+ dt_update_trace(&x0);
+ printf("data: %lf\n", x0.x);
+
+ return 0;
+} \ No newline at end of file