ECF 1.7
Sqrt.h
1#ifndef Sqrt_h
2#define Sqrt_h
3#include "Primitive.h"
4#include <cmath>
5
6namespace Tree {
7namespace Primitives {
8
9 class Sqrt : public Primitive
10 {
11 public:
12 Sqrt(void)
13 {
14 nArguments_ = 1;
15 name_ = "sqrt";
16 }
17
18
19 ~Sqrt(void)
20 { }
21
22
23 void execute(void* result, Tree& tree)
24 {
25 double& arg = *(double*)result;
26 getNextArgument(&arg, tree);
27 if (arg > 0) {
28 arg = sqrt(arg);
29 } else {
30 arg = 0;
31 }
32 }
33 };
34
35}
36}
37
38#endif
void getNextArgument(void *result, Tree &tree)
Execute next child node's primitive (execute next subtree).
Definition Primitive.cpp:71
void execute(void *result, Tree &tree)
Execute the primitive.
Definition Sqrt.h:23
Tree class - implements genotype as a tree.
Definition Tree_c.h:29