ECF 1.7
Avg.h
1#ifndef Avg_h
2#define Avg_h
3#include "Primitive.h"
4
5namespace Tree {
6namespace Primitives {
7
12class Avg : public Primitive
13{
14public:
15 Avg(void)
16 {
17 nArguments_ = 2;
18 name_ = "avg";
19 }
20
21 ~Avg(void)
22 { }
23
24 void execute(void* result, Tree& tree)
25 {
26 double& avg = *(double*)result;
27 double first, second;
28 getNextArgument(&first, tree);
29 getNextArgument(&second, tree);
30 avg = (first + second) / 2;
31 }
32};
33
34}
35}
36
37#endif
void execute(void *result, Tree &tree)
Execute the primitive.
Definition Avg.h:24
void getNextArgument(void *result, Tree &tree)
Execute next child node's primitive (execute next subtree).
Definition Primitive.cpp:71
Tree class - implements genotype as a tree.
Definition Tree_c.h:29