ECF 1.5
Sqrt.cpp
1#include "GPSymbRegEvalOp.h"
2
3#include "Sqrt.h"
4#include <cmath>
5
6namespace Tree {
7namespace Primitives {
8
9Sqrt::Sqrt(void)
10{
11 nArguments_ = 1;
12 name_ = "sqrt";
13}
14
15
16Sqrt::~Sqrt(void)
17{ }
18
19
20void Sqrt::execute(void* result, Tree &tree)
21{
22 double& arg = *(double*)result;
23 getNextArgument(&arg, tree);
24 if (arg > 0) {
25 arg = sqrt(arg);
26 } else {
27 arg = 0;
28 }
29}
30
31}
32}
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.cpp:20
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29