From 8c97ea4df1ce38d7ece2dda23440df2f9fdfbc75 Mon Sep 17 00:00:00 2001 From: conrad Date: Tue, 13 Jul 2021 12:23:37 +1000 Subject: [PATCH] add .reset_cache() --- include/armadillo_bits/SpMat_bones.hpp | 1 + include/armadillo_bits/SpMat_meat.hpp | 39 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/armadillo_bits/SpMat_bones.hpp b/include/armadillo_bits/SpMat_bones.hpp index 99a7688d..c529971c 100644 --- a/include/armadillo_bits/SpMat_bones.hpp +++ b/include/armadillo_bits/SpMat_bones.hpp @@ -360,6 +360,7 @@ class SpMat : public SpBase< eT, SpMat > inline const SpMat& sprandn(const SizeMat& s, const double density); inline void reset(); + inline void reset_cache(); //! don't use this unless you're writing internal Armadillo code inline void reserve(const uword in_rows, const uword in_cols, const uword new_n_nonzero); diff --git a/include/armadillo_bits/SpMat_meat.hpp b/include/armadillo_bits/SpMat_meat.hpp index 26a23466..0f1bd545 100644 --- a/include/armadillo_bits/SpMat_meat.hpp +++ b/include/armadillo_bits/SpMat_meat.hpp @@ -4501,6 +4501,45 @@ SpMat::reset() +template +inline +void +SpMat::reset_cache() + { + arma_extra_debug_sigprint(); + + sync_csc(); + + #if defined(ARMA_USE_OPENMP) + { + #pragma omp critical (arma_SpMat_cache) + { + cache.reset(); + + sync_state = 0; + } + } + #elif (!defined(ARMA_DONT_USE_STD_MUTEX)) + { + cache_mutex.lock(); + + cache.reset(); + + sync_state = 0; + + cache_mutex.unlock(); + } + #else + { + cache.reset(); + + sync_state = 0; + } + #endif + } + + + template inline void