Commit 9e96d36c authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Update value array accessing for new set up

op_slots are now used throughout
parent 76c06f01
......@@ -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
/**
......
......@@ -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));
}
......@@ -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
/**
......
......@@ -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));
}
......@@ -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
/**
......
......@@ -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));
}
......@@ -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
/**
......
......@@ -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));
}
......@@ -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
/**
......
......@@ -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));
}
......@@ -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
/**
......
......@@ -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));
}
......@@ -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
/**
......
......@@ -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));
}
......@@ -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
/**
......
......@@ -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));
}
......@@ -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
/**
......
......@@ -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));
}
......@@ -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
/**
......
......@@ -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()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment