Feat C++ API
A feature engineering automation tool
n_min.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_min.h"
7 
8 namespace FT{
9 
10  namespace Pop{
11  namespace Op{
13  {
14  name = "min";
15  otype = 'f';
16  arity['z'] = 1;
17  complexity = 1;
18  }
19 
20  #ifndef USE_CUDA
22  void NodeMin::evaluate(const Data& data, State& state)
23  {
24  ArrayXf tmp(state.z.top().first.size());
25 
26  int x;
27 
28  for(x = 0; x < state.z.top().first.size(); x++)
29  tmp(x) = limited(state.z.top().first[x]).minCoeff();
30 
31  state.z.pop();
32 
33  state.push<float>(tmp);
34 
35  }
36  #else
37  void NodeMin::evaluate(const Data& data, State& state)
38  {
39 
40  ArrayXf tmp(state.z.top().first.size());
41 
42  int x;
43 
44  for(x = 0; x < state.z.top().first.size(); x++)
45  tmp(x) = limited(state.z.top().first[x]).minCoeff();
46 
47  state.z.pop();
48 
49  GPU_Variable(state.dev_f, tmp.data(), state.idx[otype], state.N);
50 
51 
52  }
53  #endif
54 
56  void NodeMin::eval_eqn(State& state)
57  {
58  state.push<float>("min(" + state.zs.pop() + ")");
59  }
60 
61  NodeMin* NodeMin::clone_impl() const { return new NodeMin(*this); }
62 
63  NodeMin* NodeMin::rnd_clone_impl() const { return new NodeMin(); }
64  }
65  }
66 }
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
void eval_eqn(State &state)
Evaluates the node symbolically.
Definition: n_min.cc:56
NodeMin * clone_impl() const override
Definition: n_min.cc:61
void evaluate(const Data &data, State &state)
Evaluates the node and updates the state states.
Definition: n_min.cc:22
NodeMin * rnd_clone_impl() const override
Definition: n_min.cc:63
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