Legofit
infers population history from nucleotide site patterns.
tinyexpr.h
1
31#ifndef __TINYEXPR_H__
32#define __TINYEXPR_H__
33
34#define TE_NAT_LOG
35
36#include "strptrmap.h"
37#include <stdio.h>
38
39typedef struct te_expr {
40 int type;
41 union {
42 double value;
43 const double *bound;
44 void *function;
45 };
46 void *parameters[1];
47} te_expr;
48
49enum {
50 TE_VARIABLE = 0,
51
52 TE_FUNCTION0 = 8, TE_FUNCTION1, TE_FUNCTION2, TE_FUNCTION3,
53 TE_FUNCTION4, TE_FUNCTION5, TE_FUNCTION6, TE_FUNCTION7,
54
55 TE_CLOSURE0 = 16, TE_CLOSURE1, TE_CLOSURE2, TE_CLOSURE3,
56 TE_CLOSURE4, TE_CLOSURE5, TE_CLOSURE6, TE_CLOSURE7,
57
58 TE_FLAG_PURE = 32
59};
60
61typedef struct te_variable {
62 void *address;
63 int type;
64 void *context;
66
67te_variable *te_variable_new(void *address);
68void te_free_variables(StrPtrMap *pars);
69
73double te_interp(const char *expression, int *error);
74
78te_expr *te_compile(const char *expression, StrPtrMap * varmap,
79 int *error);
80
82double te_eval(const te_expr * n);
83
85void te_print(const te_expr * n, FILE * fp);
86
93int te_dependencies(const te_expr *self, int len, const double *ptr[len]);
94
96/* This is safe to call on NULL pointers. */
97void te_free(te_expr * n);
98
100void te_free_func_map(void);
101
102#endif /*__TINYEXPR_H__*/
The hash table.
Definition: strptrmap.c:38
Definition: tinyexpr.h:39
Definition: tinyexpr.h:61