ECF 1.5
Neg.h
1#ifndef Neg_h
2#define Neg_h
3#include "Primitive.h"
4
5namespace Tree {
6namespace Primitives {
7
14template <class T>
15class NegT : public Primitive
16{
17public:
18 NegT();
19 void execute(void* result, Tree& tree);
20 ~NegT();
21};
22typedef NegT<double> Neg;
23
24
25template <class T>
27{
28 nArguments_ = 1;
29 name_ = "neg";
30 complementName_ = "pos";
31}
32
33
34template <class T>
35NegT<T>::~NegT()
36{ }
37
38
39template <class T>
40void NegT<T>::execute(void* result, Tree& tree)
41{
42 T arg;
43 T& neg = *(T*)result;
44 getNextArgument(&arg, tree);
45 neg = arg < 0 ? arg : 0;
46}
47
48}
49}
50
51#endif
Neg function primitive (Tree genotype)
Definition: Neg.h:16
void execute(void *result, Tree &tree)
Execute the primitive.
Definition: Neg.h:40
Base primitive class (Tree genotype).
Definition: Primitive.h:37
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29