Feat C++ API
A feature engineering automation tool
n_recent.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_recent.h"
6 
7 namespace FT{
8 
9  namespace Pop{
10  namespace Op{
12  {
13  name = "recent";
14  otype = 'f';
15  arity['z'] = 1;
16  complexity = 1;
17  }
18 
19  #ifndef USE_CUDA
21  void NodeRecent::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  {
28  // find max time
29  ArrayXf::Index maxIdx;
30  float maxtime = state.z.top().second[x].maxCoeff(&maxIdx);
31  // return value at max time
32  tmp(x) = state.z.top().first[x](maxIdx);
33  }
34 
35  state.z.pop();
36 
37  state.push<float>(tmp);
38 
39  }
40  #else
41  void NodeRecent::evaluate(const Data& data, State& state)
42  {
43  ArrayXf tmp(state.z.top().first.size());
44  int x;
45 
46  for(x = 0; x < state.z.top().first.size(); x++)
47  {
48  // find max time
49  ArrayXf::Index maxIdx;
50  float maxtime = state.z.top().second[x].maxCoeff(&maxIdx);
51  // return value at max time
52  tmp(x) = state.z.top().first[x](maxIdx);
53  }
54 
55  state.z.pop();
56 
57  GPU_Variable(state.dev_f, tmp.data(), state.idx[otype], state.N);
58  }
59  #endif
60 
63  {
64  state.push<float>("recent(" + state.zs.pop() + ")");
65  }
66 
67  NodeRecent* NodeRecent::clone_impl() const { return new NodeRecent(*this); }
68 
70  }
71  }
72 }
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
NodeRecent * clone_impl() const override
Definition: n_recent.cc:67
NodeRecent * rnd_clone_impl() const override
Definition: n_recent.cc:69
void eval_eqn(State &state)
Evaluates the node symbolically.
Definition: n_recent.cc:62
void evaluate(const Data &data, State &state)
Evaluates the node and updates the state states.
Definition: n_recent.cc:21
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
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