Skip to content
Snippets Groups Projects
Commit 2f3a44b8 authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Code compiles, and runs but does not work

Something is wrong with the comparision functions
parent a731c202
No related branches found
No related tags found
No related merge requests found
...@@ -65,7 +65,8 @@ void node_value_arrs::initialize_values_arr( ...@@ -65,7 +65,8 @@ void node_value_arrs::initialize_values_arr(
VALUES_ARR = std::vector<double>(N_STORE_FEATURES * N_SAMPLES); VALUES_ARR = std::vector<double>(N_STORE_FEATURES * N_SAMPLES);
TEST_VALUES_ARR = std::vector<double>(N_STORE_FEATURES * N_SAMPLES_TEST); TEST_VALUES_ARR = std::vector<double>(N_STORE_FEATURES * N_SAMPLES_TEST);
STANDARDIZED_TEST_STORAGE_ARR = std::vector<double>(2 * (N_PRIMARY_FEATURES + 1) * MAX_N_THREADS * N_SAMPLES_TEST); STANDARDIZED_STORAGE_ARR = std::vector<double>(2 * (N_PRIMARY_FEATURES + 1) * N_SAMPLES * MAX_N_THREADS);
STANDARDIZED_TEST_STORAGE_ARR = std::vector<double>(2 * (N_PRIMARY_FEATURES + 1) * N_SAMPLES_TEST * MAX_N_THREADS);
} }
void node_value_arrs::initialize_values_arr( void node_value_arrs::initialize_values_arr(
......
...@@ -304,7 +304,10 @@ namespace node_value_arrs ...@@ -304,7 +304,10 @@ namespace node_value_arrs
*/ */
inline double* access_temp_stand_storage(const unsigned long int arr_ind, const bool for_comp) inline double* access_temp_stand_storage(const unsigned long int arr_ind, const bool for_comp)
{ {
return &STANDARDIZED_STORAGE_ARR[((arr_ind % N_PRIMARY_FEATURES) + for_comp * N_PRIMARY_FEATURES) * N_PRIMARY_FEATURES]; return &STANDARDIZED_STORAGE_ARR[
((arr_ind % N_PRIMARY_FEATURES) + for_comp * N_PRIMARY_FEATURES) * N_SAMPLES +
omp_get_thread_num() * 2 * (N_PRIMARY_FEATURES + 1) * N_SAMPLES
];
} }
/** /**
...@@ -317,7 +320,10 @@ namespace node_value_arrs ...@@ -317,7 +320,10 @@ namespace node_value_arrs
*/ */
inline double* access_temp_stand_storage_test(const unsigned long int arr_ind, const bool for_comp) inline double* access_temp_stand_storage_test(const unsigned long int arr_ind, const bool for_comp)
{ {
return &STANDARDIZED_TEST_STORAGE_ARR[((arr_ind % N_PRIMARY_FEATURES) + for_comp * N_PRIMARY_FEATURES) * N_SAMPLES_TEST]; return &STANDARDIZED_TEST_STORAGE_ARR[
((arr_ind % N_PRIMARY_FEATURES) + for_comp * N_PRIMARY_FEATURES) * N_SAMPLES_TEST +
omp_get_thread_num() * 2 * (N_PRIMARY_FEATURES + 1) * N_SAMPLES_TEST
];
} }
/** /**
......
...@@ -90,12 +90,13 @@ bool comp_feats::valid_feature_against_selected_pearson_max_corr_1( ...@@ -90,12 +90,13 @@ bool comp_feats::valid_feature_against_selected_pearson_max_corr_1(
continue; continue;
} }
double comp_value = std::inner_product( double comp_value = 1.0 / static_cast<double>(n_samp) * std::inner_product(
val_ptr, val_ptr,
val_ptr + n_samp, val_ptr + n_samp,
node_value_arrs::get_stand_d_matrix_ptr(dd), node_value_arrs::get_stand_d_matrix_ptr(dd),
-1.0 * base_val -1.0 * base_val
); );
if(std::abs(comp_value) < 5.0e-9) if(std::abs(comp_value) < 5.0e-9)
{ {
return false; return false;
...@@ -122,7 +123,7 @@ bool comp_feats::valid_feature_against_selected_pearson_max_corr_1_feat_list( ...@@ -122,7 +123,7 @@ bool comp_feats::valid_feature_against_selected_pearson_max_corr_1_feat_list(
continue; continue;
} }
double comp_value = std::inner_product( double comp_value = 1.0 / static_cast<double>(n_samp) * std::inner_product(
val_ptr, val_ptr,
val_ptr + n_samp, val_ptr + n_samp,
selected[ff]->stand_value_ptr(true), selected[ff]->stand_value_ptr(true),
...@@ -154,7 +155,7 @@ bool comp_feats::valid_feature_against_selected_pearson_max_corr_1_mpi_op( ...@@ -154,7 +155,7 @@ bool comp_feats::valid_feature_against_selected_pearson_max_corr_1_mpi_op(
continue; continue;
} }
double comp_value = std::inner_product( double comp_value = 1.0 / static_cast<double>(n_samp) * std::inner_product(
val_ptr, val_ptr,
val_ptr + n_samp, val_ptr + n_samp,
feat_sc._feat->stand_value_ptr(true), feat_sc._feat->stand_value_ptr(true),
...@@ -180,16 +181,20 @@ bool comp_feats::valid_feature_against_selected_pearson( ...@@ -180,16 +181,20 @@ bool comp_feats::valid_feature_against_selected_pearson(
const int start_sel const int start_sel
) )
{ {
if(end_sel <= start_sel)
{
return true;
}
DGEMV_OUT.resize(end_sel - start_sel); DGEMV_OUT.resize(end_sel - start_sel);
double base_val = std::inner_product(val_ptr, val_ptr + n_samp, val_ptr, 0.0); double base_val = std::inner_product(val_ptr, val_ptr + n_samp, val_ptr, 0.0) / static_cast<double>(n_samp);
volatile bool is_valid = true; volatile bool is_valid = true;
dgemv_( dgemv_(
'N', 'N',
DGEMV_OUT.size(), DGEMV_OUT.size(),
n_samp, n_samp,
1.0, 1.0 / static_cast<double>(n_samp),
node_value_arrs::get_stand_d_matrix_ptr(start_sel), node_value_arrs::get_stand_d_matrix_ptr(start_sel),
DGEMV_OUT.size(), DGEMV_OUT.size(),
val_ptr, val_ptr,
...@@ -200,9 +205,10 @@ bool comp_feats::valid_feature_against_selected_pearson( ...@@ -200,9 +205,10 @@ bool comp_feats::valid_feature_against_selected_pearson(
); );
double comp_value = ( double comp_value = (
base_val - std::abs(DGEMV_OUT[idamax_(DGEMV_OUT.size(), DGEMV_OUT.data(), 1)]) base_val - std::abs(DGEMV_OUT[idamax_(DGEMV_OUT.size(), DGEMV_OUT.data(), 1) - 1])
); );
// std::cout << *val_ptr << '\t' << util_funcs::mean(val_ptr, n_samp) << '\t' << util_funcs::stand_dev(val_ptr, n_samp) << std::endl;
std::cout << comp_value << '\t' << base_val << '\t' << DGEMV_OUT[0] << std::endl;
return comp_value < (1.0 - cross_cor_max + 5.0e-9); return comp_value < (1.0 - cross_cor_max + 5.0e-9);
} }
...@@ -219,7 +225,7 @@ bool comp_feats::valid_feature_against_selected_pearson_feat_list( ...@@ -219,7 +225,7 @@ bool comp_feats::valid_feature_against_selected_pearson_feat_list(
for(auto& feat : selected) for(auto& feat : selected)
{ {
double comp_value = std::abs( double comp_value = 1.0 / static_cast<double>(n_samp) * std::abs(
std::inner_product(val_ptr, val_ptr + n_samp, feat->stand_value_ptr(true), -base_val) std::inner_product(val_ptr, val_ptr + n_samp, feat->stand_value_ptr(true), -base_val)
); );
...@@ -243,7 +249,7 @@ bool comp_feats::valid_feature_against_selected_pearson_mpi_op( ...@@ -243,7 +249,7 @@ bool comp_feats::valid_feature_against_selected_pearson_mpi_op(
for(auto& feat_sc : out_vec) for(auto& feat_sc : out_vec)
{ {
double comp_value = std::abs( double comp_value = 1.0 / static_cast<double>(n_samp) * std::abs(
std::inner_product(val_ptr, val_ptr + n_samp, feat_sc._feat->stand_value_ptr(true), -base_val) std::inner_product(val_ptr, val_ptr + n_samp, feat_sc._feat->stand_value_ptr(true), -base_val)
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment