Feat C++ API
A feature engineering automation tool
n_xor.cc
Go to the documentation of this file.
1 /* FEAT
2 copyright 2017 William La Cava
3 license: GNU/GPL v3
4 */
5 
6 #include "n_xor.h"
7 
8 namespace FT
9 {
10 
11  namespace Pop{
12  namespace Op{
14  {
15  name = "xor";
16  otype = 'b';
17  arity['b'] = 2;
18  complexity = 2;
19  }
20 
21  #ifndef USE_CUDA
23  void NodeXor::evaluate(const Data& data, State& state)
24  {
25  ArrayXb x1 = state.pop<bool>();
26  ArrayXb x2 = state.pop<bool>();
27 
28  ArrayXb res = (x1 != x2).select(ArrayXb::Ones(x1.size()), ArrayXb::Zero(x1.size()));
29 
30  state.push<bool>(res);
31 
32  }
33  #else
34  void NodeXor::evaluate(const Data& data, State& state)
35  {
36  GPU_Xor(state.dev_b, state.idx[otype], state.N);
37  }
38  #endif
39 
41  void NodeXor::eval_eqn(State& state)
42  {
43  state.push<bool>("XOR(" + state.popStr<bool>() + ","
44  + state.popStr<bool>() + ")");
45  }
46 
47  NodeXor* NodeXor::clone_impl() const { return new NodeXor(*this); }
48 
49  NodeXor* NodeXor::rnd_clone_impl() const { return new NodeXor(); }
50  }
51  }
52 
53 }
data holding X, y, and Z data
Definition: data.h:42
void evaluate(const Data &data, State &state)
Evaluates the node and updates the state states.
Definition: n_xor.cc:23
NodeXor * rnd_clone_impl() const override
Definition: n_xor.cc:49
void eval_eqn(State &state)
Evaluates the node symbolically.
Definition: n_xor.cc:41
NodeXor * clone_impl() const override
Definition: n_xor.cc:47
string name
node type
Definition: node.h:56
std::map< char, unsigned int > arity
arity of the operator
Definition: node.h:59
char otype
output type
Definition: node.h:58
int complexity
complexity of node
Definition: node.h:60
Eigen::Array< bool, Eigen::Dynamic, 1 > ArrayXb
Definition: data.h:21
void GPU_Xor(bool *x, size_t idx, size_t N)
main Feat namespace
Definition: data.cc:13
contains various types of State actually used by feat
Definition: state.h:102
string popStr()
Definition: state.h:143
Eigen::Array< T, Eigen::Dynamic, 1 > pop()
Definition: state.h:128
void push(Eigen::Array< T, Eigen::Dynamic, 1 > value)
Definition: state.h:123