From 9e96d36c9f70bf89576c5e6b60de01744f09e7bb Mon Sep 17 00:00:00 2001 From: Thomas <purcell@fhi-berlin.mpg.de> Date: Fri, 9 Apr 2021 16:44:22 +0200 Subject: [PATCH] Update value array accessing for new set up op_slots are now used throughout --- .../feature_space/FeatureSpace.cpp | 4 +- src/feature_creation/node/FeatureNode.hpp | 8 +-- src/feature_creation/node/ModelNode.hpp | 8 +-- src/feature_creation/node/Node.hpp | 8 +-- .../node/operator_nodes/OperatorNode.hpp | 18 +++--- .../abs/absolute_value.cpp | 8 +-- .../abs/absolute_value.hpp | 4 +- .../abs_diff/absolute_difference.cpp | 8 +-- .../abs_diff/absolute_difference.hpp | 4 +- .../allowed_operator_nodes/add/add.cpp | 8 +-- .../allowed_operator_nodes/add/add.hpp | 4 +- .../allowed_operator_nodes/cb/cube.cpp | 8 +-- .../allowed_operator_nodes/cb/cube.hpp | 4 +- .../allowed_operator_nodes/cbrt/cube_root.cpp | 8 +-- .../allowed_operator_nodes/cbrt/cube_root.hpp | 4 +- .../allowed_operator_nodes/cos/cos.cpp | 8 +-- .../allowed_operator_nodes/cos/cos.hpp | 4 +- .../allowed_operator_nodes/div/divide.cpp | 8 +-- .../allowed_operator_nodes/div/divide.hpp | 4 +- .../exp/exponential.cpp | 8 +-- .../exp/exponential.hpp | 4 +- .../allowed_operator_nodes/inv/inverse.cpp | 8 +-- .../allowed_operator_nodes/inv/inverse.hpp | 4 +- .../allowed_operator_nodes/log/log.cpp | 8 +-- .../allowed_operator_nodes/log/log.hpp | 4 +- .../allowed_operator_nodes/mult/multiply.cpp | 8 +-- .../allowed_operator_nodes/mult/multiply.hpp | 4 +- .../neg_exp/negative_exponential.cpp | 8 +-- .../neg_exp/negative_exponential.hpp | 4 +- .../allowed_operator_nodes/sin/sin.cpp | 8 +-- .../allowed_operator_nodes/sin/sin.hpp | 4 +- .../allowed_operator_nodes/sp/sixth_power.cpp | 8 +-- .../allowed_operator_nodes/sp/sixth_power.hpp | 4 +- .../allowed_operator_nodes/sq/square.cpp | 8 +-- .../allowed_operator_nodes/sq/square.hpp | 4 +- .../sqrt/square_root.cpp | 8 +-- .../sqrt/square_root.hpp | 4 +- .../allowed_operator_nodes/sub/subtract.cpp | 8 +-- .../allowed_operator_nodes/sub/subtract.hpp | 4 +- .../value_storage/nodes_value_containers.cpp | 23 +++++-- .../value_storage/nodes_value_containers.hpp | 61 ++++++++++++------- src/python/__init__.py | 14 ++++- src/python/bindings_docstring_keyed.cpp | 2 +- src/python/bindings_docstring_keyed.hpp | 12 ++-- src/python/feature_creation/FeatureNode.cpp | 4 +- src/python/feature_creation/FeatureSpace.cpp | 1 + 46 files changed, 186 insertions(+), 181 deletions(-) diff --git a/src/feature_creation/feature_space/FeatureSpace.cpp b/src/feature_creation/feature_space/FeatureSpace.cpp index 86b41bbd..57a66471 100644 --- a/src/feature_creation/feature_space/FeatureSpace.cpp +++ b/src/feature_creation/feature_space/FeatureSpace.cpp @@ -472,14 +472,14 @@ void FeatureSpace::project_generated(double* prop, int size, std::vector<node_pt if(scores_sel_private.size() == _n_sis_select) { generated_phi[inds[ii]]->reindex(node_value_arrs::N_STORE_FEATURES + worst_score_ind + _n_sis_select * (omp_get_thread_num() + _mpi_comm->size())); - generated_phi[inds[ii]]->set_value(); + // generated_phi[inds[ii]]->set_value(); phi_sel_private[worst_score_ind] = generated_phi[inds[ii]]; scores_sel_private[worst_score_ind] = cur_score; } else { generated_phi[inds[ii]]->reindex(node_value_arrs::N_STORE_FEATURES + scores_sel_private.size() + _n_sis_select * (omp_get_thread_num() + _mpi_comm->size())); - generated_phi[inds[ii]]->set_value(); + // generated_phi[inds[ii]]->set_value(); phi_sel_private.push_back(generated_phi[inds[ii]]); scores_sel_private.push_back(cur_score); } diff --git a/src/feature_creation/node/FeatureNode.hpp b/src/feature_creation/node/FeatureNode.hpp index e672e211..fed7e9f7 100644 --- a/src/feature_creation/node/FeatureNode.hpp +++ b/src/feature_creation/node/FeatureNode.hpp @@ -167,7 +167,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - inline void set_value(int offset = -1){std::copy_n(_value.data(), _n_samp, value_ptr());} + inline void set_value(int offset=0){std::copy_n(_value.data(), _n_samp, value_ptr());} // DocString: feat_node_set_test_value /** @@ -175,7 +175,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - inline void set_test_value(int offset = -1){if(!_selected) std::copy_n(_test_value.data(), _n_test_samp, test_value_ptr());} + inline void set_test_value(int offset=0){if(!_selected) std::copy_n(_test_value.data(), _n_test_samp, test_value_ptr());} // DocString: feat_node_is_nan /** @@ -199,14 +199,14 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - inline double* value_ptr(int offset = 0){return _selected ? node_value_arrs::get_d_matrix_ptr(_d_mat_ind) : node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset);} + inline double* value_ptr(int offset=0){return _selected ? node_value_arrs::get_d_matrix_ptr(_d_mat_ind) : node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, 0, offset);} /** * @brief The pointer to where the feature's test data is stored * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - inline double* test_value_ptr(int offset = 0){return node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset);} + inline double* test_value_ptr(int offset=0){return node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, 0, offset);} // DocString: feat_node_rung diff --git a/src/feature_creation/node/ModelNode.hpp b/src/feature_creation/node/ModelNode.hpp index 28cd02d3..4c65f29f 100644 --- a/src/feature_creation/node/ModelNode.hpp +++ b/src/feature_creation/node/ModelNode.hpp @@ -116,7 +116,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - inline void set_value(int offset = -1){return;} + inline void set_value(int offset=0){return;} // DocString: model_node_set_test_value /** @@ -124,7 +124,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - inline void set_test_value(int offset = -1){return;} + inline void set_test_value(int offset=0){return;} // DocString: model_node_is_nan /** @@ -148,14 +148,14 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - inline double* value_ptr(int offset = -1){return _value.data();} + inline double* value_ptr(int offset=0){return _value.data();} /** * @brief The pointer to where the feature's test data is stored * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - inline double* test_value_ptr(int offset = -1){return _test_value.data();} + inline double* test_value_ptr(int offset=0){return _test_value.data();} // DocString: model_node_rung /** diff --git a/src/feature_creation/node/Node.hpp b/src/feature_creation/node/Node.hpp index 084d59a2..49f74688 100644 --- a/src/feature_creation/node/Node.hpp +++ b/src/feature_creation/node/Node.hpp @@ -225,14 +225,14 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - virtual void set_value(int offset = -1) = 0; + virtual void set_value(int offset=0) = 0; /** * @brief The pointer to where the feature's training data is stored * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - virtual double* value_ptr(int offset = -1) = 0; + virtual double* value_ptr(int offset=0) = 0; // DocString: node_set_test_value /** @@ -240,14 +240,14 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - virtual void set_test_value(int offset = -1) = 0; + virtual void set_test_value(int offset=0) = 0; /** * @brief The pointer to where the feature's test data is stored * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - virtual double* test_value_ptr(int offset = -1) = 0; + virtual double* test_value_ptr(int offset=0) = 0; // DocString: node_is_nan /** diff --git a/src/feature_creation/node/operator_nodes/OperatorNode.hpp b/src/feature_creation/node/operator_nodes/OperatorNode.hpp index 579717f4..a3c80b1b 100644 --- a/src/feature_creation/node/operator_nodes/OperatorNode.hpp +++ b/src/feature_creation/node/operator_nodes/OperatorNode.hpp @@ -143,7 +143,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - virtual void set_value(int offset = -1) = 0; + virtual void set_value(int offset=0) = 0; // DocString: op_node_set_test_value /** @@ -151,7 +151,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - virtual void set_test_value(int offset = -1) = 0; + virtual void set_test_value(int offset=0) = 0; /** * @brief Get the pointer to the feature's training data @@ -161,18 +161,17 @@ public: * * @return pointer to the feature's training value */ - double* value_ptr(int offset=-1) + double* value_ptr(int offset=0) { if(_selected) return node_value_arrs::get_d_matrix_ptr(_d_mat_ind); - offset = (offset == -1) ? rung() : offset; - if((rung() > node_value_arrs::N_RUNGS_STORED) && (node_value_arrs::temp_storage_reg(_arr_ind, offset) != _feat_ind)) + if((rung() > node_value_arrs::N_RUNGS_STORED) && (node_value_arrs::temp_storage_reg(_arr_ind, rung(), offset) != _feat_ind)) { set_value(offset); } - return node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset); + return node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset); } /** @@ -183,15 +182,14 @@ public: * * @return pointer to the feature's test values */ - double* test_value_ptr(int offset=-1) + double* test_value_ptr(int offset=0) { - offset = (offset == -1) ? rung() : offset; - if((rung() > node_value_arrs::N_RUNGS_STORED) && (node_value_arrs::temp_storage_test_reg(_arr_ind, offset) != _feat_ind)) + if((rung() > node_value_arrs::N_RUNGS_STORED) && (node_value_arrs::temp_storage_test_reg(_arr_ind, rung(), offset) != _feat_ind)) { set_test_value(offset); } - return node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset); + return node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset); } // DocString: op_node_is_nan diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs/absolute_value.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs/absolute_value.cpp index dc5f96b0..8807bb2b 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs/absolute_value.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs/absolute_value.cpp @@ -66,14 +66,12 @@ void AbsNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_lea void AbsNode::set_value(int offset) { if(_selected) - allowed_op_funcs::abs(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::abs(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::abs(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::abs(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void AbsNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::abs(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::abs(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs/absolute_value.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs/absolute_value.hpp index 82de5a0f..25f3cd9d 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs/absolute_value.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs/absolute_value.hpp @@ -86,7 +86,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: abs_node_set_test_value /** @@ -94,7 +94,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: abs_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.cpp index 91f8054f..7ec232c9 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.cpp @@ -87,14 +87,12 @@ void AbsDiffNode::update_div_mult_leaves(std::map<std::string, double>& div_mult void AbsDiffNode::set_value(int offset) { if(_selected) - allowed_op_funcs::abs_diff(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::abs_diff(_n_samp, _feats[0]->value_ptr(2 * offset), _feats[1]->value_ptr(2 * offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::abs_diff(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::abs_diff(_n_samp, _feats[0]->value_ptr(2 * offset), _feats[1]->value_ptr(2 * offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void AbsDiffNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::abs_diff(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), _feats[1]->test_value_ptr(offset + 1), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::abs_diff(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), _feats[1]->test_value_ptr(2 * offset + 1), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.hpp index 68a2ebc9..330c7512 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/abs_diff/absolute_difference.hpp @@ -89,7 +89,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: abs_diff_node_set_test_value /** @@ -97,7 +97,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: abs_diff_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add/add.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add/add.cpp index e885764f..dca98556 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add/add.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add/add.cpp @@ -80,14 +80,12 @@ void AddNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_lea void AddNode::set_value(int offset) { if(_selected) - allowed_op_funcs::add(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::add(_n_samp, _feats[0]->value_ptr(2 * offset), _feats[1]->value_ptr(2 * offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::add(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::add(_n_samp, _feats[0]->value_ptr(2 * offset), _feats[1]->value_ptr(2 * offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void AddNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::add(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), _feats[1]->test_value_ptr(offset + 1), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::add(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), _feats[1]->test_value_ptr(2 * offset + 1), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add/add.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add/add.hpp index c9e1842f..3b3ca2fa 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add/add.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/add/add.hpp @@ -86,7 +86,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: add_node_set_test_value /** @@ -94,7 +94,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: add_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cb/cube.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cb/cube.cpp index 2db055bc..1a849f02 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cb/cube.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cb/cube.cpp @@ -56,13 +56,11 @@ void CbNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_leav void CbNode::set_value(int offset) { if(_selected) - allowed_op_funcs::cb(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::cb(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::cb(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::cb(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void CbNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::cb(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::cb(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cb/cube.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cb/cube.hpp index e6ac61dd..ecb49fa7 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cb/cube.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cb/cube.hpp @@ -84,7 +84,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: cb_node_set_test_value /** @@ -92,7 +92,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: cb_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cbrt/cube_root.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cbrt/cube_root.cpp index bb999ff8..49a05fe9 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cbrt/cube_root.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cbrt/cube_root.cpp @@ -55,14 +55,12 @@ void CbrtNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_le void CbrtNode::set_value(int offset) { if(_selected) - allowed_op_funcs::cbrt(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::cbrt(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::cbrt(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::cbrt(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void CbrtNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::cbrt(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::cbrt(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cbrt/cube_root.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cbrt/cube_root.hpp index 0803b7cd..e0284b3c 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cbrt/cube_root.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cbrt/cube_root.hpp @@ -84,7 +84,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: cbrt_node_set_test_value /** @@ -92,7 +92,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: cbrt_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos/cos.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos/cos.cpp index 3ea3cf7a..0cac2682 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos/cos.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos/cos.cpp @@ -61,14 +61,12 @@ void CosNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_lea void CosNode::set_value(int offset) { if(_selected) - allowed_op_funcs::cos(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::cos(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::cos(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::cos(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void CosNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::cos(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::cos(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos/cos.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos/cos.hpp index 20cdf7fd..523cb11b 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos/cos.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/cos/cos.hpp @@ -84,7 +84,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: cos_node_set_test_value /** @@ -92,7 +92,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: cos_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/div/divide.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/div/divide.cpp index 6ca45a43..f4a0e005 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/div/divide.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/div/divide.cpp @@ -81,14 +81,12 @@ void DivNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_lea void DivNode::set_value(int offset) { if(_selected) - allowed_op_funcs::div(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::div(_n_samp, _feats[0]->value_ptr(2 * offset), _feats[1]->value_ptr(2 * offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::div(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::div(_n_samp, _feats[0]->value_ptr(2 * offset), _feats[1]->value_ptr(2 * offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void DivNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::div(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), _feats[1]->test_value_ptr(offset + 1), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::div(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), _feats[1]->test_value_ptr(2 * offset + 1), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/div/divide.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/div/divide.hpp index 52b9c79a..e5ef547b 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/div/divide.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/div/divide.hpp @@ -86,7 +86,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: div_node_set_test_value /** @@ -94,7 +94,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: div_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exp/exponential.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exp/exponential.cpp index 6c1c01ea..d844a60f 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exp/exponential.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exp/exponential.cpp @@ -63,14 +63,12 @@ void ExpNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_lea void ExpNode::set_value(int offset) { if(_selected) - allowed_op_funcs::exp(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::exp(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::exp(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::exp(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void ExpNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::exp(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::exp(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exp/exponential.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exp/exponential.hpp index f87c9ce9..2d17a567 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exp/exponential.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/exp/exponential.hpp @@ -84,7 +84,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: exp_node_set_test_value /** @@ -92,7 +92,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: exp_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inv/inverse.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inv/inverse.cpp index 1177493e..aed5c35e 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inv/inverse.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inv/inverse.cpp @@ -56,14 +56,12 @@ void InvNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_lea void InvNode::set_value(int offset) { if(_selected) - allowed_op_funcs::inv(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::inv(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::inv(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::inv(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void InvNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::inv(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::inv(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inv/inverse.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inv/inverse.hpp index c6a7f370..05c455e4 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inv/inverse.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/inv/inverse.hpp @@ -72,7 +72,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: inv_node_set_test_value /** @@ -80,7 +80,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: inv_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log/log.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log/log.cpp index 997a7d85..0343bbd2 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log/log.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log/log.cpp @@ -64,14 +64,12 @@ void LogNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_lea void LogNode::set_value(int offset) { if(_selected) - allowed_op_funcs::log(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::log(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::log(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::log(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void LogNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::log(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::log(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log/log.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log/log.hpp index 92b61d4e..d21bc141 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log/log.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/log/log.hpp @@ -84,7 +84,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: log_node_set_test_value /** @@ -92,7 +92,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: log_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/mult/multiply.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/mult/multiply.cpp index 3e78a6fc..2641379b 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/mult/multiply.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/mult/multiply.cpp @@ -81,14 +81,12 @@ void MultNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_le void MultNode::set_value(int offset) { if(_selected) - allowed_op_funcs::mult(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::mult(_n_samp, _feats[0]->value_ptr(2 * offset), _feats[1]->value_ptr(2 * offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::mult(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::mult(_n_samp, _feats[0]->value_ptr(2 * offset), _feats[1]->value_ptr(2 * offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void MultNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::mult(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), _feats[1]->test_value_ptr(offset + 1), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::mult(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), _feats[1]->test_value_ptr(2 * offset + 1), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/mult/multiply.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/mult/multiply.hpp index 42c06473..b6c73ff7 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/mult/multiply.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/mult/multiply.hpp @@ -87,7 +87,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: mult_node_set_test_value /** @@ -95,7 +95,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: mult_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/neg_exp/negative_exponential.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/neg_exp/negative_exponential.cpp index cdaebd91..1ba3d169 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/neg_exp/negative_exponential.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/neg_exp/negative_exponential.cpp @@ -64,14 +64,12 @@ void NegExpNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_ void NegExpNode::set_value(int offset) { if(_selected) - allowed_op_funcs::neg_exp(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::neg_exp(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::neg_exp(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::neg_exp(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void NegExpNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::neg_exp(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::neg_exp(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/neg_exp/negative_exponential.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/neg_exp/negative_exponential.hpp index 8175f0c8..24880adf 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/neg_exp/negative_exponential.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/neg_exp/negative_exponential.hpp @@ -85,7 +85,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: neg_exp_node_set_test_value /** @@ -93,7 +93,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: neg_exp_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin/sin.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin/sin.cpp index d503053f..1214263b 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin/sin.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin/sin.cpp @@ -61,14 +61,12 @@ void SinNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_lea void SinNode::set_value(int offset) { if(_selected) - allowed_op_funcs::sin(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::sin(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sin(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::sin(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void SinNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sin(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::sin(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin/sin.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin/sin.hpp index 0d7f66a4..3ad4f3de 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin/sin.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sin/sin.hpp @@ -85,7 +85,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: sin_node_set_test_value /** @@ -93,7 +93,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: sin_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sp/sixth_power.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sp/sixth_power.cpp index 7dd1f6b2..3633e456 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sp/sixth_power.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sp/sixth_power.cpp @@ -52,14 +52,12 @@ void SixPowNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_ void SixPowNode::set_value(int offset) { if(_selected) - allowed_op_funcs::sixth_pow(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::sixth_pow(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sixth_pow(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::sixth_pow(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void SixPowNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sixth_pow(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::sixth_pow(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sp/sixth_power.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sp/sixth_power.hpp index 8c940862..524bc61d 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sp/sixth_power.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sp/sixth_power.hpp @@ -85,7 +85,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: six_pow_node_set_test_value /** @@ -93,7 +93,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: six_pow_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sq/square.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sq/square.cpp index 249e6f92..62d6ae37 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sq/square.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sq/square.cpp @@ -53,14 +53,12 @@ void SqNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_leav void SqNode::set_value(int offset) { if(_selected) - allowed_op_funcs::sq(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::sq(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sq(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::sq(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void SqNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sq(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::sq(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sq/square.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sq/square.hpp index ee67280a..b2e0097b 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sq/square.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sq/square.hpp @@ -84,7 +84,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: sq_node_set_test_value /** @@ -92,7 +92,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: sq_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sqrt/square_root.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sqrt/square_root.cpp index ea0fc869..b549f3d5 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sqrt/square_root.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sqrt/square_root.cpp @@ -53,14 +53,12 @@ void SqrtNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_le void SqrtNode::set_value(int offset) { if(_selected) - allowed_op_funcs::sqrt(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::sqrt(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sqrt(_n_samp, _feats[0]->value_ptr(offset + 2), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::sqrt(_n_samp, _feats[0]->value_ptr(2 * offset), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void SqrtNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sqrt(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::sqrt(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sqrt/square_root.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sqrt/square_root.hpp index 2ecb1d4b..fb89ad27 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sqrt/square_root.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sqrt/square_root.hpp @@ -85,7 +85,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: sqrt_node_set_test_value /** @@ -93,7 +93,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: sqrt_node_rung /** diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sub/subtract.cpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sub/subtract.cpp index a338297a..eae864d3 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sub/subtract.cpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sub/subtract.cpp @@ -80,14 +80,12 @@ void SubNode::update_div_mult_leaves(std::map<std::string, double>& div_mult_lea void SubNode::set_value(int offset) { if(_selected) - allowed_op_funcs::sub(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); + allowed_op_funcs::sub(_n_samp, _feats[0]->value_ptr(2 * offset), _feats[1]->value_ptr(2 * offset + 1), node_value_arrs::get_d_matrix_ptr(_d_mat_ind)); - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sub(_n_samp, _feats[0]->value_ptr(offset + 2), _feats[1]->value_ptr(offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::sub(_n_samp, _feats[0]->value_ptr(2 * offset), _feats[1]->value_ptr(2 * offset + 1), node_value_arrs::get_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } void SubNode::set_test_value(int offset) { - offset = (offset == -1) ? rung() : offset; - allowed_op_funcs::sub(_n_test_samp, _feats[0]->test_value_ptr(offset + 2), _feats[1]->test_value_ptr(offset + 1), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, offset)); + allowed_op_funcs::sub(_n_test_samp, _feats[0]->test_value_ptr(2 * offset), _feats[1]->test_value_ptr(2 * offset + 1), node_value_arrs::get_test_value_ptr(_arr_ind, _feat_ind, rung(), offset)); } diff --git a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sub/subtract.hpp b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sub/subtract.hpp index fff6a877..54dc07b0 100644 --- a/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sub/subtract.hpp +++ b/src/feature_creation/node/operator_nodes/allowed_operator_nodes/sub/subtract.hpp @@ -87,7 +87,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_value(int offset = -1); + void set_value(int offset=0); // DocString: sub_node_set_test_value /** @@ -95,7 +95,7 @@ public: * * @param offset(int) Key to determine which part of the temporary storage array to look into */ - void set_test_value(int offset = -1); + void set_test_value(int offset=0); // DocString: sub_node_rung /** diff --git a/src/feature_creation/node/value_storage/nodes_value_containers.cpp b/src/feature_creation/node/value_storage/nodes_value_containers.cpp index c0c0e125..69eb3024 100644 --- a/src/feature_creation/node/value_storage/nodes_value_containers.cpp +++ b/src/feature_creation/node/value_storage/nodes_value_containers.cpp @@ -23,6 +23,12 @@ std::vector<double> node_value_arrs::TEMP_STORAGE_TEST_ARR; void node_value_arrs::initialize_values_arr(int n_samples, int n_samples_test, int n_primary_feat, int max_rung, bool set_task_sz) { + if(max_rung < 0) + throw std::logic_error("Maximum rung of the features is less than 0"); + + if(max_rung == 0) + std::cerr << "Warning requested calculation has a maximum rung of 0" << std::endl; + if(set_task_sz) TASK_SZ_TRAIN = {n_samples}; @@ -76,6 +82,9 @@ void node_value_arrs::set_task_sz_test(std::vector<int> task_sz_test) void node_value_arrs::resize_values_arr(int n_dims, unsigned long int n_feat, bool use_temp) { + if(n_dims > MAX_RUNG) + throw std::logic_error("Requested rung is larger MAX_RUNG."); + N_RUNGS_STORED = n_dims; N_STORE_FEATURES = n_feat; if(N_STORE_FEATURES == 0) @@ -113,22 +122,24 @@ void node_value_arrs::resize_values_arr(int n_dims, unsigned long int n_feat, bo } } -double* node_value_arrs::get_value_ptr(unsigned long int arr_ind, unsigned long int feat_ind, int offset) +double* node_value_arrs::get_value_ptr(unsigned long int arr_ind, unsigned long int feat_ind, int rung, int offset) { if(arr_ind < N_STORE_FEATURES) return access_value_arr(arr_ind); + int op_slot = get_op_slot(rung, offset); - temp_storage_reg(arr_ind, offset) = feat_ind; - return access_temp_storage((arr_ind % N_STORE_FEATURES) + (offset % N_OP_SLOTS) * N_STORE_FEATURES + omp_get_thread_num() * (N_STORE_FEATURES * N_OP_SLOTS + 1)); + temp_storage_reg(arr_ind, op_slot) = feat_ind; + return access_temp_storage((arr_ind % N_STORE_FEATURES) + (op_slot % N_OP_SLOTS) * N_STORE_FEATURES + omp_get_thread_num() * (N_STORE_FEATURES * N_OP_SLOTS + 1)); } -double* node_value_arrs::get_test_value_ptr(unsigned long int arr_ind, unsigned long int feat_ind, int offset) +double* node_value_arrs::get_test_value_ptr(unsigned long int arr_ind, unsigned long int feat_ind, int rung, int offset) { if(arr_ind < N_STORE_FEATURES) return access_test_value_arr(arr_ind); + int op_slot = get_op_slot(rung, offset); - temp_storage_test_reg(arr_ind, offset) = feat_ind; - return access_temp_storage_test((arr_ind % N_STORE_FEATURES) + (offset % N_OP_SLOTS) * N_STORE_FEATURES + omp_get_thread_num() * (N_STORE_FEATURES * N_OP_SLOTS + 1)); + temp_storage_test_reg(arr_ind, op_slot) = feat_ind; + return access_temp_storage_test((arr_ind % N_STORE_FEATURES) + (op_slot % N_OP_SLOTS) * N_STORE_FEATURES + omp_get_thread_num() * (N_STORE_FEATURES * N_OP_SLOTS + 1)); } void node_value_arrs::initialize_d_matrix_arr() diff --git a/src/feature_creation/node/value_storage/nodes_value_containers.hpp b/src/feature_creation/node/value_storage/nodes_value_containers.hpp index 39f1572a..4a2f0881 100644 --- a/src/feature_creation/node/value_storage/nodes_value_containers.hpp +++ b/src/feature_creation/node/value_storage/nodes_value_containers.hpp @@ -54,19 +54,6 @@ namespace node_value_arrs */ void initialize_values_arr(int n_samples, int n_samples_test, int n_primary_feat, int max_rung, bool et_task_sz); - /** - * @brief Initialize the node value arrays - * @details Using the size of the initial feature space constructor the storage arrays - * - * @param n_samples Number of training samples for each feature - * @param n_samples_test Number of test samples for each feature - * @param n_primary_feat Number of primary features - */ - inline void initialize_values_arr(int n_samples, int n_samples_test, int n_primary_feat) - { - initialize_values_arr(n_samples, n_samples_test, n_primary_feat, 0, true); - } - /** * @brief Initialize the node value arrays * @details Using the size of the initial feature space constructor the storage arrays @@ -90,7 +77,7 @@ namespace node_value_arrs * @param n_primary_feat Number of primary features * @param max_rung Largest rung of a feature */ - void initialize_values_arr(std::vector<int> task_sz_train, std::vector<int> task_sz_test, int n_primary_feat, int max_rung=0); + void initialize_values_arr(std::vector<int> task_sz_train, std::vector<int> task_sz_test, int n_primary_feat, int max_rung); /** * @brief Resize the node value arrays @@ -131,25 +118,57 @@ namespace node_value_arrs */ void set_task_sz_test(std::vector<int> task_sz_test); + /** + * @brief Get the operator slot associated with a given rung/offset + * + * @param rung Rung of the feature + * @param offset Offset used to prevent overwrites + * + * @return The operator slot to use + */ + inline int get_op_slot(int rung, int offset){return std::abs(N_OP_SLOTS - static_cast<int>(std::pow(2, MAX_RUNG - rung)) - offset);} + + /** + * @brief Get a reference slot/feature register of the training data + * + * @param ind The Node's arr_ind + * @param op_slot(int) Offset integer for TEMP_STORE_ARRAY + * + * @return The register element for a given feature index and op_slot + */ + inline int& temp_storage_reg(unsigned long int ind, int op_slot = 0){return TEMP_STORAGE_REG[(ind % N_STORE_FEATURES) + (op_slot % N_OP_SLOTS) * N_STORE_FEATURES + omp_get_thread_num() * (N_STORE_FEATURES * N_OP_SLOTS + 1)];} + + /** + * @brief Get a reference slot/feature register of the test data + * + * @param ind The Node's arr_ind + * @param op_slot(int) Offset integer for TEMP_STORE_TEST_ARRAY + * + * @return The register element for a given feature index and op_slot + */ + inline int& temp_storage_test_reg(unsigned long int ind, int op_slot = 0){return TEMP_STORAGE_TEST_REG[(ind % N_STORE_FEATURES) + (op_slot % N_OP_SLOTS) * N_STORE_FEATURES + omp_get_thread_num() * (N_STORE_FEATURES * N_OP_SLOTS + 1)];} + /** * @brief Get a reference slot/feature register of the training data * * @param ind The Node's arr_ind - * @param offset(int) Offset integer for TEMP_STORE_ARRAY + * @param rung Rung of the feature + * @param offset Offset used to prevent overwrites * * @return The register element for a given feature index and offset */ - inline int& temp_storage_reg(unsigned long int ind, int offset = 0){return TEMP_STORAGE_REG[(ind % N_STORE_FEATURES) + (offset % N_OP_SLOTS) * N_STORE_FEATURES + omp_get_thread_num() * (N_STORE_FEATURES * N_OP_SLOTS + 1)];} + inline int& temp_storage_reg(unsigned long int ind, int rung, int offset){return TEMP_STORAGE_REG[(ind % N_STORE_FEATURES) + (get_op_slot(rung, offset) % N_OP_SLOTS) * N_STORE_FEATURES + omp_get_thread_num() * (N_STORE_FEATURES * N_OP_SLOTS + 1)];} /** * @brief Get a reference slot/feature register of the test data * * @param ind The Node's arr_ind - * @param offset(int) Offset integer for TEMP_STORE_TEST_ARRAY + * @param rung Rung of the feature + * @param offset Offset used to prevent overwrites * * @return The register element for a given feature index and offset */ - inline int& temp_storage_test_reg(unsigned long int ind, int offset = 0){return TEMP_STORAGE_TEST_REG[(ind % N_STORE_FEATURES) + (offset % N_OP_SLOTS) * N_STORE_FEATURES + omp_get_thread_num() * (N_STORE_FEATURES * N_OP_SLOTS + 1)];} + inline int& temp_storage_test_reg(unsigned long int ind, int rung, int offset){return TEMP_STORAGE_TEST_REG[(ind % N_STORE_FEATURES) + (get_op_slot(rung, offset) % N_OP_SLOTS) * N_STORE_FEATURES + omp_get_thread_num() * (N_STORE_FEATURES * N_OP_SLOTS + 1)];} /** * @brief Access element of the permanent training data storage array @@ -196,7 +215,7 @@ namespace node_value_arrs * * @return The value pointer */ - double* get_value_ptr(unsigned long int arr_ind, unsigned long int feat_ind, int offset = 0); + double* get_value_ptr(unsigned long int arr_ind, unsigned long int feat_ind, int rung = 0, int offset = 0); /** * @brief Get a Node's test_value_ptr @@ -207,7 +226,7 @@ namespace node_value_arrs * * @return The value pointer */ - double* get_test_value_ptr(unsigned long int arr_ind, unsigned long int feat_ind, int offset = 0); + double* get_test_value_ptr(unsigned long int arr_ind, unsigned long int feat_ind, int rung = 0, int offset = 0); /** * @brief Get the pointer to a particular selected Node from sis @@ -230,7 +249,7 @@ namespace node_value_arrs * @brief Flush the temporary storage register (training data) * @details Reset all slots in the register to -1 */ - inline void clear_temp_reg_thread(){std::fill_n(TEMP_STORAGE_REG.data() + N_STORE_FEATURES * 3 * omp_get_thread_num(), N_STORE_FEATURES * 3, -1);} + inline void clear_temp_reg_thread(){std::fill_n(TEMP_STORAGE_REG.data() + N_STORE_FEATURES * N_OP_SLOTS * omp_get_thread_num(), N_STORE_FEATURES * N_OP_SLOTS, -1);} /** * @brief Flush the temporary storage register (test data) diff --git a/src/python/__init__.py b/src/python/__init__.py index 46cee816..05479679 100644 --- a/src/python/__init__.py +++ b/src/python/__init__.py @@ -53,7 +53,13 @@ def get_unit(header): def generate_phi_0_from_csv( - df, prop_key, cols="all", task_key=None, leave_out_frac=0.0, leave_out_inds=None + df, + prop_key, + cols="all", + task_key=None, + leave_out_frac=0.0, + leave_out_inds=None, + max_rung=None, ): """Create initial feature set from csv file @@ -63,6 +69,7 @@ def generate_phi_0_from_csv( cols (list or str): The columns to include in the initial feature set task_key (str): The key corresponding to which column in the csv file the task differentiation is stored in leave_out_frac (list): List of indices to pull from the training data to act as a test set + max_rung (int): Maximum rung of a feature Returns: phi_0 (list of FeatureNodes): The list of primary features @@ -73,6 +80,8 @@ def generate_phi_0_from_csv( leave_out_frac (float): Fraction of samples to leave out leave_out_inds (list): Indices to use as the test set """ + if not max_rung: + raise ValueError("Maximum rung for the calculation is not defined.") # Load csv file if isinstance(df, str): @@ -166,7 +175,7 @@ def generate_phi_0_from_csv( exprs = list([col.split("(")[0] for col in columns]) units = list([get_unit(col) for col in columns]) - initialize_values_arr(len(train_inds), len(leave_out_inds), len(columns)) + initialize_values_arr(len(train_inds), len(leave_out_inds), len(columns), max_rung) test_values = df.to_numpy().T[:, leave_out_inds] values = df.to_numpy().T[:, train_inds] @@ -295,6 +304,7 @@ def generate_fs_sr_from_csv( task_key=task_key, leave_out_frac=leave_out_frac, leave_out_inds=leave_out_inds, + max_rung=max_phi, ) fs = generate_fs( diff --git a/src/python/bindings_docstring_keyed.cpp b/src/python/bindings_docstring_keyed.cpp index 32d5e90c..e2677c9c 100644 --- a/src/python/bindings_docstring_keyed.cpp +++ b/src/python/bindings_docstring_keyed.cpp @@ -37,7 +37,7 @@ void sisso::register_all() sisso::feature_creation::node::registerSqrtNode(); sisso::feature_creation::node::registerSixPowNode(); - void (*init_val_ar)(int, int, int) = &node_value_arrs::initialize_values_arr; + void (*init_val_ar)(int, int, int, int) = &node_value_arrs::initialize_values_arr; def("phi_selected_from_file", &str2node::phi_selected_from_file_py); def("initialize_values_arr", init_val_ar); diff --git a/src/python/bindings_docstring_keyed.hpp b/src/python/bindings_docstring_keyed.hpp index cee1f5b8..1687d807 100644 --- a/src/python/bindings_docstring_keyed.hpp +++ b/src/python/bindings_docstring_keyed.hpp @@ -42,10 +42,10 @@ namespace sisso inline Unit unit(){return this->get_override("unit")();} inline std::vector<double> value(){return this->get_override("value")();} inline std::vector<double> test_value(){return this->get_override("test_value")();} - inline void set_value(int offset = -1){this->get_override("set_value")();} - inline double* value_ptr(int offset = -1){return this->get_override("value_ptr")();} - inline void set_test_value(int offset = -1){this->get_override("set_test_value")();} - inline double* test_value_ptr(int offset = -1){return this->get_override("test_value_ptr")();} + inline void set_value(int offset=0){this->get_override("set_value")();} + inline double* value_ptr(int offset=0){return this->get_override("value_ptr")();} + inline void set_test_value(int offset=0){this->get_override("set_test_value")();} + inline double* test_value_ptr(int offset=0){return this->get_override("test_value_ptr")();} inline bool is_nan(){return this->get_override("is_nan")();} inline bool is_const(){return this->get_override("is_const")();} inline NODE_TYPE type(){return this->get_override("type")();} @@ -65,8 +65,8 @@ namespace sisso template<int N> struct OperatorNodeWrap : OperatorNode<N>, py::wrapper<OperatorNode<N>> { - inline void set_value(int offset = -1){this->get_override("set_value")();} - inline void set_test_value(int offset = -1){this->get_override("set_test_value")();} + inline void set_value(int offset=0){this->get_override("set_value")();} + inline void set_test_value(int offset=0){this->get_override("set_test_value")();} inline NODE_TYPE type(){return this->get_override("type")();} inline int rung(int cur_rung = 0){return this->get_override("rung")();} inline std::string expr(){return this->get_override("expr")();} diff --git a/src/python/feature_creation/FeatureNode.cpp b/src/python/feature_creation/FeatureNode.cpp index 6b23ab7e..81229abe 100644 --- a/src/python/feature_creation/FeatureNode.cpp +++ b/src/python/feature_creation/FeatureNode.cpp @@ -9,7 +9,7 @@ FeatureNode::FeatureNode(unsigned long int feat_ind, std::string expr, np::ndarr { // Automatically resize the storage arrays if(node_value_arrs::N_STORE_FEATURES == 0) - node_value_arrs::initialize_values_arr(_n_samp, _n_test_samp, 1); + node_value_arrs::initialize_values_arr(_n_samp, _n_test_samp, 1, 0); else if((_n_samp != node_value_arrs::N_SAMPLES) || (_n_test_samp != node_value_arrs::N_SAMPLES_TEST)) throw std::logic_error("Number of samples in current feature is not the same as the others, (" + std::to_string(_n_samp) + " and " + std::to_string(_n_test_samp) + " vs. " + std::to_string(node_value_arrs::N_SAMPLES) + " and " + std::to_string(node_value_arrs::N_SAMPLES_TEST) + ")"); else if(feat_ind >= node_value_arrs::N_STORE_FEATURES) @@ -29,7 +29,7 @@ FeatureNode::FeatureNode(unsigned long int feat_ind, std::string expr, py::list // Automatically resize the storage arrays if(node_value_arrs::N_STORE_FEATURES == 0) - node_value_arrs::initialize_values_arr(_n_samp, _n_test_samp, 1); + node_value_arrs::initialize_values_arr(_n_samp, _n_test_samp, 1, 0); else if((_n_samp != node_value_arrs::N_SAMPLES) || (_n_test_samp != node_value_arrs::N_SAMPLES_TEST)) throw std::logic_error("Number of samples in current feature is not the same as the others, (" + std::to_string(_n_samp) + " and " + std::to_string(_n_test_samp) + " vs. " + std::to_string(node_value_arrs::N_SAMPLES) + " and " + std::to_string(node_value_arrs::N_SAMPLES_TEST) + ")"); else if(feat_ind >= node_value_arrs::N_STORE_FEATURES) diff --git a/src/python/feature_creation/FeatureSpace.cpp b/src/python/feature_creation/FeatureSpace.cpp index 11fe0d00..a1aa8e84 100644 --- a/src/python/feature_creation/FeatureSpace.cpp +++ b/src/python/feature_creation/FeatureSpace.cpp @@ -121,6 +121,7 @@ FeatureSpace::FeatureSpace( std::vector<int> rung_inds = util_funcs::argsort(rungs); _max_phi = *std::max_element(rungs.begin(), rungs.end()); + node_value_arrs::MAX_RUNG = _max_phi; _phi[0] = phi_temp[rung_inds[0]]; for(int ff = 1; ff < _n_feat; ++ff) { -- GitLab