Feat C++ API
A feature engineering automation tool
n_constant.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_constant.h"
6 
7 namespace FT{
8 
9 namespace Pop{
10 namespace Op{
11 
14 {
15  name = "constant_b";
16  otype = 'b';
17  complexity = 1;
18  b_value = v;
19 }
20 
23 {
24  name = "constant_d";
25  otype = 'f';
26  complexity = 1;
27  d_value = v;
28 }
29 
30 #ifndef USE_CUDA
32 void NodeConstant::evaluate(const Data& data, State& state)
33 {
34  if (otype == 'b')
35  state.push<bool>(ArrayXb::Constant(data.X.cols(),int(b_value)));
36  else
37  state.push<float>(limited(ArrayXf::Constant(data.X.cols(),d_value)));
38 }
39 #else
40 void NodeConstant::evaluate(const Data& data, State& state)
41 {
42  if (otype == 'b')
43  {
44  GPU_Constant(state.dev_b, b_value, state.idx['b'], state.N);
45  }
46  else
47  {
48  GPU_Constant(state.dev_f, d_value, state.idx['f'], state.N);
49  }
50 
51 }
52 #endif
53 
56 {
57  if (otype == 'b')
58  state.push<bool>(std::to_string(b_value));
59  else
60  state.push<float>(std::to_string(d_value));
61 }
62 
63 NodeConstant* NodeConstant::clone_impl() const { return new NodeConstant(*this); }
64 
66 
67 }
68 }
69 }
data holding X, y, and Z data
Definition: data.h:42
MatrixXf & X
Definition: data.h:45
NodeConstant * rnd_clone_impl() const override
Definition: n_constant.cc:65
NodeConstant * clone_impl() const override
Definition: n_constant.cc:63
void evaluate(const Data &data, State &state)
Evaluates the node and updates the state states.
Definition: n_constant.cc:32
float d_value
value, for k and x types
Definition: n_constant.h:18
void eval_eqn(State &state)
Evaluates the node symbolically.
Definition: n_constant.cc:55
string name
node type
Definition: node.h:56
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_Constant(float *dev_x, float value, size_t idx, size_t N)
static Rnd & r
Definition: rnd.h:135
std::string to_string(const T &value)
template function to convert objects to string for logging
Definition: utils.h:422
main Feat namespace
Definition: data.cc:13
contains various types of State actually used by feat
Definition: state.h:102
void push(Eigen::Array< T, Eigen::Dynamic, 1 > value)
Definition: state.h:123