Feat C++ API
A feature engineering automation tool
n_step.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_step.h"
7 
8 
9 namespace FT{
10 
11  namespace Pop{
12  namespace Op{
14  {
15  name = "step";
16  otype = 'f';
17  arity['f'] = 1;
18  complexity = 1;
19  }
20 
21  #ifndef USE_CUDA
23  void NodeStep::evaluate(const Data& data, State& state)
24  {
25  ArrayXf x = state.pop<float>();
26  ArrayXf res = (x > 0).select(ArrayXf::Ones(x.size()), ArrayXf::Zero(x.size()));
27  state.push<float>(res);
28  }
29  #else
30  void NodeStep::evaluate(const Data& data, State& state)
31  {
32  GPU_Step(state.dev_f, state.idx[otype], state.N);
33  }
34  #endif
35 
38  {
39  state.push<float>("step("+ state.popStr<float>() +")");
40  }
41 
42  NodeStep* NodeStep::clone_impl() const { return new NodeStep(*this); }
43 
44  NodeStep* NodeStep::rnd_clone_impl() const { return new NodeStep(); }
45  }
46  }
47 }
data holding X, y, and Z data
Definition: data.h:42
NodeStep * rnd_clone_impl() const override
Definition: n_step.cc:44
NodeStep * clone_impl() const override
Definition: n_step.cc:42
void evaluate(const Data &data, State &state)
Evaluates the node and updates the state states.
Definition: n_step.cc:23
void eval_eqn(State &state)
Evaluates the node symbolically.
Definition: n_step.cc:37
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_Step(float *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