diff options
Diffstat (limited to 'example/direct.c')
| -rw-r--r-- | example/direct.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/example/direct.c b/example/direct.c index 102c0c3..29da5d3 100644 --- a/example/direct.c +++ b/example/direct.c @@ -1,7 +1,12 @@ -typedef double value_t; + +// direct.c - Example usage of direct.h computation graph + +#include <stdio.h> + +typedef double direct_value_t; + #define DT_IMPLEMENTATION #include "../include/direct.h" -#include <stdio.h> int main() { node_t x0 = {.x = 0.0, .function = dt_add}; @@ -20,7 +25,7 @@ int main() { dt_connect(&x3, &x4); dt_connect(&x4, &x5); dt_connect(&x4, &x6); - dt_connect(&x5, &x2); + dt_connect(&x5, &x6); dt_update_trace(&x0); printf("data: %lf\n", x0.x); @@ -29,5 +34,13 @@ int main() { dt_update_trace(&x0); printf("data: %lf\n", x0.x); + dt_clear_edges(&x0); + dt_clear_edges(&x1); + dt_clear_edges(&x2); + dt_clear_edges(&x3); + dt_clear_edges(&x4); + dt_clear_edges(&x5); + dt_clear_edges(&x6); + return 0; }
\ No newline at end of file |