ECF 1.5
IASqrt.cpp
1#include "GPSymbRegEvalOp.h"
2
3#include "IASqrt.h"
4#include "IATree.h"
5#include <cmath>
6
7void IASqrt::execute(void* result, Tree::Tree& tree)
8{
9 if (!calculateBoundsIfRootNode(result, tree)) {
10 return;
11 }
12
14}
15
16IABounds IASqrt::calculateBounds(Tree::IATree& tree) {
17 // get next argument
18 tree.iNode_++;
19 IAPrimitiveP prim = boost::dynamic_pointer_cast<IAPrimitive>(tree[tree.iNode_]->primitive_);
20 // calculate bounds
21 IABounds bounds = prim->calculateBounds(tree);
22
23 if (!bounds.isWithinBounds) {
24 // subtree not within bounds, delete expression
25 return bounds;
26 } else if (bounds.lowerBound < 0) {
27 IABounds retVal;
28 retVal.isWithinBounds = false;
29 return retVal;
30 } else {
31 // subtree is ok
32 IABounds retVal;
33 retVal.isWithinBounds = true;
34 retVal.isLowerBoundInclusive = bounds.isLowerBoundInclusive;
35 retVal.lowerBound = sqrt(bounds.lowerBound);
36 retVal.isUpperBoundInclusive = bounds.isUpperBoundInclusive;
37 retVal.upperBound = sqrt(bounds.upperBound);
38 return retVal;
39 }
40}
virtual void execute(void *result, Tree::Tree &tree)
Execute the primitive.
Definition: IASqrt.cpp:7
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
uint iNode_
current node index (when parsing the tree)
Definition: Tree_c.h:75