-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunc.h
67 lines (53 loc) · 1.13 KB
/
func.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* func.h
* Copyright (C) 2012 Jan Viktorin
*/
#ifndef FUNC_H
#define FUNC_H
#include <stdlib.h>
#include <inttypes.h>
/**
* Functions available for each CGP computation unit.
*/
typedef int func_t;
#define FUNC_FMT "%d"
/**
* Generates a function at random.
*/
void func_gen(func_t *f);
/**
* Mutates the function.
*/
void func_mut(func_t *f);
/**
* How many functions are possible?
*/
size_t func_count(void);
/**
* Evaluates the function on the given array of operands.
* The result is stored in to dst.
* The length of op must be `func_inputs_max()` and
* the length of dst must be `func_outputs_max()`.
*/
void func_eval64(func_t f, uint64_t *op, uint64_t *dst);
/**
* String representation of the function.
*/
const char *func_to_str(func_t f);
/**
* Returns maximal number of inputs from all functions.
*/
size_t func_inputs_max(void);
/**
* Returns maximal number of outputs from all functions.
*/
size_t func_outputs_max(void);
/**
* Returns the number of inputs of function f.
*/
size_t func_inputs(func_t f);
/**
* Returns the number of outputs from function f.
*/
size_t func_outputs(func_t f);
#endif