Graph Framework
Loading...
Searching...
No Matches
graph_c_binding.h
Go to the documentation of this file.
1//------------------------------------------------------------------------------
4//------------------------------------------------------------------------------
5//------------------------------------------------------------------------------
109//------------------------------------------------------------------------------
110
111#ifndef graph_c_binding_h
112#define graph_c_binding_h
113
114#include <stddef.h>
115#include <stdint.h>
116#include <stdbool.h>
117
118//------------------------------------------------------------------------------
122//------------------------------------------------------------------------------
123//------------------------------------------------------------------------------
127//------------------------------------------------------------------------------
128#ifdef USE_METAL
129#define START_GPU @autoreleasepool {
130#define END_GPU }
131#else
132#define START_GPU
133#define END_GPU
134#endif
135
136//------------------------------------------------------------------------------
139//------------------------------------------------------------------------------
140#ifdef __cplusplus
141extern "C" {
142#define STRUCT_TAG
143#else
144#define STRUCT_TAG struct
145#endif
147 typedef void * graph_node;
148
149//------------------------------------------------------------------------------
151//------------------------------------------------------------------------------
153 FLOAT,
154 DOUBLE,
155 COMPLEX_FLOAT,
156 COMPLEX_DOUBLE
157 };
158
159//------------------------------------------------------------------------------
161//------------------------------------------------------------------------------
168
169//------------------------------------------------------------------------------
175//------------------------------------------------------------------------------
177 const bool use_safe_math);
178
179//------------------------------------------------------------------------------
183//------------------------------------------------------------------------------
185
186//------------------------------------------------------------------------------
193//------------------------------------------------------------------------------
195 const size_t size,
196 const char *symbol);
197
198//------------------------------------------------------------------------------
204//------------------------------------------------------------------------------
206 const double value);
207
208//------------------------------------------------------------------------------
214//------------------------------------------------------------------------------
216 graph_node var,
217 const void *source);
218
219//------------------------------------------------------------------------------
226//------------------------------------------------------------------------------
228 const double real_value,
229 const double img_value);
230
231//------------------------------------------------------------------------------
237//------------------------------------------------------------------------------
239 graph_node var);
240
241//------------------------------------------------------------------------------
247//------------------------------------------------------------------------------
249 graph_node var);
250
251//------------------------------------------------------------------------------
258//------------------------------------------------------------------------------
260 graph_node left,
261 graph_node right);
262
263//------------------------------------------------------------------------------
270//------------------------------------------------------------------------------
272 graph_node left,
273 graph_node right);
274
275//------------------------------------------------------------------------------
282//------------------------------------------------------------------------------
284 graph_node left,
285 graph_node right);
286
287//------------------------------------------------------------------------------
294//------------------------------------------------------------------------------
296 graph_node left,
297 graph_node right);
298
299//------------------------------------------------------------------------------
305//------------------------------------------------------------------------------
307 graph_node arg);
308
309//------------------------------------------------------------------------------
315//------------------------------------------------------------------------------
317 graph_node arg);
318
319//------------------------------------------------------------------------------
325//------------------------------------------------------------------------------
327 graph_node arg);
328
329//------------------------------------------------------------------------------
336//------------------------------------------------------------------------------
338 graph_node left,
339 graph_node right);
340
341//------------------------------------------------------------------------------
347//------------------------------------------------------------------------------
349 graph_node arg);
350
351//------------------------------------------------------------------------------
357//------------------------------------------------------------------------------
359 graph_node arg);
360
361//------------------------------------------------------------------------------
367//------------------------------------------------------------------------------
369 graph_node arg);
370
371//------------------------------------------------------------------------------
378//------------------------------------------------------------------------------
380 graph_node left,
381 graph_node right);
382
383//------------------------------------------------------------------------------
389//------------------------------------------------------------------------------
391 const uint32_t seed);
392
393//------------------------------------------------------------------------------
399//------------------------------------------------------------------------------
401 graph_node state);
402
403//------------------------------------------------------------------------------
413//------------------------------------------------------------------------------
415 graph_node arg,
416 const double scale,
417 const double offset,
418 const void *source,
419 const size_t source_size);
420
421//------------------------------------------------------------------------------
435//------------------------------------------------------------------------------
437 const size_t num_cols,
438 graph_node x_arg,
439 const double x_scale,
440 const double x_offset,
441 graph_node y_arg,
442 const double y_scale,
443 const double y_offset,
444 const void *source,
445 const size_t source_size);
446
447//------------------------------------------------------------------------------
452//------------------------------------------------------------------------------
454
455//------------------------------------------------------------------------------
460//------------------------------------------------------------------------------
462 const size_t num);
463
464//------------------------------------------------------------------------------
478//------------------------------------------------------------------------------
480 graph_node *inputs, size_t num_inputs,
481 graph_node *outputs, size_t num_outputs,
482 graph_node *map_inputs,
483 graph_node *map_outputs, size_t num_maps,
484 graph_node random_state,
485 const char *name,
486 const size_t size);
487
488//------------------------------------------------------------------------------
502//------------------------------------------------------------------------------
504 graph_node *inputs, size_t num_inputs,
505 graph_node *outputs, size_t num_outputs,
506 graph_node *map_inputs,
507 graph_node *map_outputs, size_t num_maps,
508 graph_node random_state,
509 const char *name,
510 const size_t size);
511
512//------------------------------------------------------------------------------
528//------------------------------------------------------------------------------
530 graph_node *inputs, size_t num_inputs,
531 graph_node *outputs, size_t num_outputs,
532 graph_node *map_inputs,
533 graph_node *map_outputs, size_t num_maps,
534 graph_node random_state,
535 const char *name,
536 const size_t size,
537 const double tol,
538 const size_t max_iter);
539
540//------------------------------------------------------------------------------
544//------------------------------------------------------------------------------
546
547//------------------------------------------------------------------------------
551//------------------------------------------------------------------------------
553
554//------------------------------------------------------------------------------
558//------------------------------------------------------------------------------
560
561//------------------------------------------------------------------------------
565//------------------------------------------------------------------------------
567
568//------------------------------------------------------------------------------
574//------------------------------------------------------------------------------
576 graph_node node,
577 void *source);
578
579//------------------------------------------------------------------------------
585//------------------------------------------------------------------------------
587 graph_node node,
588 void *destination);
589
590//------------------------------------------------------------------------------
597//------------------------------------------------------------------------------
599 const size_t index,
600 graph_node *nodes,
601 const size_t num_nodes);
602
603//------------------------------------------------------------------------------
609//------------------------------------------------------------------------------
611 graph_node fnode,
612 graph_node xnode);
613#ifdef __cplusplus
614}
615#endif
616
617#endif /* graph_c_binding_h */
graph_node graph_log(STRUCT_TAG graph_c_context *c, graph_node arg)
Create log node.
Definition graph_c_binding.cpp:892
graph_node graph_sin(STRUCT_TAG graph_c_context *c, graph_node arg)
Create sine node.
Definition graph_c_binding.cpp:1068
STRUCT_TAG graph_c_context * graph_construct_context(const enum graph_type type, const bool use_safe_math)
Construct a C context.
Definition graph_c_binding.cpp:40
graph_node graph_exp(STRUCT_TAG graph_c_context *c, graph_node arg)
Create exp node.
Definition graph_c_binding.cpp:828
void graph_destroy_context(STRUCT_TAG graph_c_context *c)
Destroy C context.
graph_node graph_sqrt(STRUCT_TAG graph_c_context *c, graph_node arg)
Create Sqrt node.
Definition graph_c_binding.cpp:764
graph_node graph_constant(STRUCT_TAG graph_c_context *c, const double value)
Create constant node.
Definition graph_c_binding.cpp:164
graph_node graph_pseudo_variable(STRUCT_TAG graph_c_context *c, graph_node var)
Create a pseudo variable.
Definition graph_c_binding.cpp:366
graph_node graph_random(STRUCT_TAG graph_c_context *c, graph_node state)
Create random node.
Definition graph_c_binding.cpp:1335
graph_node graph_add(STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
Create Addition node.
Definition graph_c_binding.cpp:498
void graph_print(STRUCT_TAG graph_c_context *c, const size_t index, graph_node *nodes, const size_t num_nodes)
Print a value from nodes.
Definition graph_c_binding.cpp:3118
void graph_add_item(STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs, graph_node *outputs, size_t num_outputs, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps, graph_node random_state, const char *name, const size_t size)
Add workflow item.
Definition graph_c_binding.cpp:2127
void graph_add_converge_item(STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs, graph_node *outputs, size_t num_outputs, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps, graph_node random_state, const char *name, const size_t size, const double tol, const size_t max_iter)
Add a converge item.
Definition graph_c_binding.cpp:2467
graph_type
Graph base type.
Definition graph_c_binding.h:152
graph_node graph_piecewise_1D(STRUCT_TAG graph_c_context *c, graph_node arg, const double scale, const double offset, const void *source, const size_t source_size)
Create 1D piecewise node.
Definition graph_c_binding.cpp:1454
graph_node graph_cos(STRUCT_TAG graph_c_context *c, graph_node arg)
Create cosine node.
Definition graph_c_binding.cpp:1132
graph_node graph_mul(STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
Create Multiply node.
Definition graph_c_binding.cpp:630
graph_node graph_erfi(STRUCT_TAG graph_c_context *c, graph_node arg)
Create imaginary error function node.
Definition graph_c_binding.cpp:1022
void graph_run(STRUCT_TAG graph_c_context *c)
Run work items.
void graph_set_device_number(STRUCT_TAG graph_c_context *c, const size_t num)
Choose the device number.
Definition graph_c_binding.cpp:1729
graph_node graph_pow(STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
Create Pow node.
Definition graph_c_binding.cpp:957
graph_node graph_variable(STRUCT_TAG graph_c_context *c, const size_t size, const char *symbol)
Create variable node.
Definition graph_c_binding.cpp:99
size_t graph_get_max_concurrency(STRUCT_TAG graph_c_context *c)
Create 2D piecewise node with complex arguments.
void * graph_node
Graph node type for C interface.
Definition graph_c_binding.h:147
graph_node graph_df(STRUCT_TAG graph_c_context *c, graph_node fnode, graph_node xnode)
Take derivative ∂f∂x.
Definition graph_c_binding.cpp:3204
graph_node graph_sub(STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
Create Substract node.
Definition graph_c_binding.cpp:564
void graph_copy_to_host(STRUCT_TAG graph_c_context *c, graph_node node, void *destination)
Copy data to a host buffer.
Definition graph_c_binding.cpp:3064
void graph_copy_to_device(STRUCT_TAG graph_c_context *c, graph_node node, void *source)
Copy data to a device buffer.
Definition graph_c_binding.cpp:3011
graph_node graph_atan(STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
Create arctangent node.
Definition graph_c_binding.cpp:1197
graph_node graph_remove_pseudo(STRUCT_TAG graph_c_context *c, graph_node var)
Remove pseudo.
Definition graph_c_binding.cpp:430
graph_node graph_constant_c(STRUCT_TAG graph_c_context *c, const double real_value, const double img_value)
Create complex constant node.
Definition graph_c_binding.cpp:322
graph_node graph_div(STRUCT_TAG graph_c_context *c, graph_node left, graph_node right)
Create Divide node.
Definition graph_c_binding.cpp:696
void graph_set_variable(STRUCT_TAG graph_c_context *c, graph_node var, const void *source)
Set a variable value.
Definition graph_c_binding.cpp:228
void graph_compile(STRUCT_TAG graph_c_context *c)
Compile the work items.
void graph_add_pre_item(STRUCT_TAG graph_c_context *c, graph_node *inputs, size_t num_inputs, graph_node *outputs, size_t num_outputs, graph_node *map_inputs, graph_node *map_outputs, size_t num_maps, graph_node random_state, const char *name, const size_t size)
Add pre workflow item.
Definition graph_c_binding.cpp:1789
#define STRUCT_TAG
Definition graph_c_binding.h:144
graph_node graph_random_state(STRUCT_TAG graph_c_context *c, const uint32_t seed)
Construct a random state node.
Definition graph_c_binding.cpp:1265
graph_node graph_piecewise_2D(STRUCT_TAG graph_c_context *c, const size_t num_cols, graph_node x_arg, const double x_scale, const double x_offset, graph_node y_arg, const double y_scale, const double y_offset, const void *source, const size_t source_size)
Create 2D piecewise node.
Definition graph_c_binding.cpp:1558
void graph_wait(STRUCT_TAG graph_c_context *c)
Wait for work items to complete.
void graph_pre_run(STRUCT_TAG graph_c_context *c)
Run pre work items.
graph_c_context type.
Definition graph_c_binding.h:162
enum graph_type type
Type of the context.
Definition graph_c_binding.h:164
bool safe_math
Uses safe math.
Definition graph_c_binding.h:166