Feat C++ API
A feature engineering automation tool
n_max.cc
Go to the documentation of this file.
1 /* FEAT
2 copyright 2017 William La Cava
3 license: GNU/GPL v3
4 */
5 #include "n_max.h"
6 
7 namespace FT{
8 
9  namespace Pop{
10  namespace Op{
12  {
13  name = "max";
14  otype = 'f';
15  arity['z'] = 1;
16  complexity = 1;
17  }
18 
19  #ifndef USE_CUDA
21  void NodeMax::evaluate(const Data& data, State& state)
22  {
23  ArrayXf tmp(state.z.top().first.size());
24  int x;
25 
26  for(x = 0; x < state.z.top().first.size(); x++)
27  tmp(x) = limited(state.z.top().first[x]).maxCoeff();
28 
29  state.z.pop();
30 
31  state.push<float>(tmp);
32 
33  }
34  #else
35  void NodeMax::evaluate(const Data& data, State& state)
36  {
37 
38  ArrayXf tmp(state.z.top().first.size());
39  int x;
40 
41  for(x = 0; x < state.z.top().first.size(); x++)
42  tmp(x) = limited(state.z.top().first[x]).maxCoeff();
43 
44  state.z.pop();
45 
46  GPU_Variable(state.dev_f, tmp.data(), state.idx[otype], state.N);
47 
48 
49  }
50  #endif
51 
53  void NodeMax::eval_eqn(State& state)
54  {
55  state.push<float>("max(" + state.zs.pop() + ")");
56  }
57 
58  NodeMax* NodeMax::clone_impl() const { return new NodeMax(*this); }
59 
60  NodeMax* NodeMax::rnd_clone_impl() const { return new NodeMax(); }
61  }
62  }
63 }
data holding X, y, and Z data
Definition: data.h:42
type pop()
returns true or false depending on stack is empty or not
Definition: state.h:55
type & top()
returns element at particular location in stack
Definition: state.h:69
NodeMax * clone_impl() const override
Definition: n_max.cc:58
void eval_eqn(State &state)
Evaluates the node symbolically.
Definition: n_max.cc:53
void evaluate(const Data &data, State &state)
Evaluates the node and updates the state states.
Definition: n_max.cc:21
NodeMax * rnd_clone_impl() const override
Definition: n_max.cc:60
string name
node type
Definition: node.h:56
std::map< char, unsigned int > arity
arity of the operator
Definition: node.h:59
ArrayXf limited(ArrayXf x)
limits node output to be between MIN_FLT and MAX_FLT
Definition: node.cc:37
char otype
output type
Definition: node.h:58
int complexity
complexity of node
Definition: node.h:60
void GPU_Variable(float *dev_x, float *host_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
Stack< string > zs
longitudinal node string stack
Definition: state.h:110
Stack< std::pair< vector< ArrayXf >, vector< ArrayXf > > > z
longitudinal node stack
Definition: state.h:106
void push(Eigen::Array< T, Eigen::Dynamic, 1 > value)
Definition: state.h:123