diff --git a/.vscode/settings.json b/.vscode/settings.json index 4a4643898..e1a94234e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -63,6 +63,9 @@ "thread": "cpp", "typeinfo": "cpp", "variant": "cpp", - "semaphore": "cpp" + "semaphore": "cpp", + "unordered_set": "cpp", + "shared_mutex": "cpp", + "cfenv": "cpp" } } \ No newline at end of file diff --git a/include/barry/model-meat.hpp b/include/barry/model-meat.hpp index 6d2ba9635..b3c550ca4 100644 --- a/include/barry/model-meat.hpp +++ b/include/barry/model-meat.hpp @@ -145,7 +145,7 @@ inline void Model & template inline void Model:: store_psets() noexcept { - // if (with_pset) - // throw std::logic_error("Powerset storage alreay activated."); with_pset = true; return; } @@ -486,7 +484,8 @@ inline void Model -inline size_t Model:: add_array( +inline size_t +Model::add_array( const Array_Type & Array_, bool force_new ) { @@ -615,6 +614,17 @@ inline size_t Model stats_support_sizes_acc; - stats_support_sizes_acc.reserve(stats_support_sizes.size()); - size_t acc = 0u; - for (size_t i = 0u; i < stats_support_sizes.size(); ++i) - { - acc += stats_support_sizes[i]; - stats_support_sizes_acc.push_back(acc); - } - // Checking if this actually has a change of happening if (this->stats_support_sizes[idx] == 0u) return as_log ? -std::numeric_limits::infinity() : 0.0; @@ -754,7 +754,9 @@ inline double Model::const_iterator locator = keys2support.find(key); if (locator == keys2support.end()) { - // throw std::out_of_range("Sampling from an array that has no support in the model."); + size_t stats_support_size = stats_support.size(); // Adding to the map keys2support[key] = stats_support_sizes.size(); @@ -1385,6 +1387,26 @@ inline Array_Type Model::set_tra size_t k = counters->size(); - auto stats_support_old = get_stats_support(); + auto stats_support_old = stats_support; // Applying over the support - for (auto & n : stats_support_sizes) + for (size_t nsupport = 0u; nsupport < stats_support_sizes.size(); ++nsupport) { - // Iterating through the unique sets - // size_t n = s; + // How many observations in the support + size_t n = stats_support_sizes[nsupport]; + + // Iterating through each observation in the nsupport'th for (size_t i = 0; i < n; ++i) { // Applying transformation and adding to the new set auto res = transform_model_fun( &stats_support_old[ - stats_support_sizes_acc[i] * (k + 1u) + 1u - ], + stats_support_sizes_acc[nsupport] * (k + 1u) + + i * (k + 1u) + 1u + ], k ); if (res.size() != transform_model_term_names.size()) - throw std::length_error("The transform vector from -transform_model_fun- does not match the size of -transform_model_term_names-."); + throw std::length_error( + std::string("The transform vector from -transform_model_fun- ") + + std::string(" does not match the size of ") + + std::string("-transform_model_term_names-.") + ); + + // Resizing stats_support if the transform stats do not match the + // previous size + if ((nsupport == 0u) && (i == 0u) && (res.size() != k)) + stats_support.resize( + (res.size() + 1) * ( + stats_support_sizes_acc.back() + + stats_support_sizes.back() + ) + ); // Weigth stats_support[ - stats_support_sizes_acc[i] * (res.size() + 1u) + stats_support_sizes_acc[nsupport] * (res.size() + 1u) + + (res.size() + 1u) * i ] = stats_support_old[ - stats_support_sizes_acc[i] * (k + 1u) + stats_support_sizes_acc[nsupport] * (k + 1u) + + i * (k + 1u) ]; // Copying the rest of the elements for (size_t j = 0u; j < res.size(); ++j) stats_support[ - stats_support_sizes_acc[i] * (res.size() + 1u) + j + 1u + stats_support_sizes_acc[nsupport] * (res.size() + 1u) + + (res.size() + 1u) * i + j + 1u ] = res[j]; } diff --git a/include/barry/support-bones.hpp b/include/barry/support-bones.hpp index a87180c83..e4e984b2d 100644 --- a/include/barry/support-bones.hpp +++ b/include/barry/support-bones.hpp @@ -183,7 +183,6 @@ class Support { size_t max_num_elements_ = 0u ); - std::vector< double > get_counts() const; const std::vector< double > & get_counts() const; std::vector< double > * get_current_stats(); ///< List current statistics. void print() const; diff --git a/include/barry/support-meat.hpp b/include/barry/support-meat.hpp index 04eb6426c..61bda9bf2 100644 --- a/include/barry/support-meat.hpp +++ b/include/barry/support-meat.hpp @@ -553,14 +553,6 @@ inline bool Support -inline std::vector< double > Support::get_counts() const { - - return data.get_data(); - -} - template inline const std::vector< double > & Support::get_counts() const {