From 1b78490e023cc34fdf785789e814e0364ee9ca3e Mon Sep 17 00:00:00 2001 From: Eduard Valeyev Date: Sun, 23 May 2021 23:32:36 -0400 Subject: [PATCH] SparseShape ctor taking scaled norms zeroes out values below threshold, just like that taking proper norms --- src/TiledArray/sparse_shape.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/TiledArray/sparse_shape.h b/src/TiledArray/sparse_shape.h index 06f660cb0a..502620ca8a 100644 --- a/src/TiledArray/sparse_shape.h +++ b/src/TiledArray/sparse_shape.h @@ -250,10 +250,14 @@ class SparseShape { return result_size_vectors; } - decltype(zero_tile_count_) compute_zero_tile_count() { + /// @brief screens out zero tiles by zeroing out the norms of tiles below + /// the threshold + /// @return the number of zero tiles + auto screen_out_zero_tiles() { decltype(zero_tile_count_) zero_tile_count = 0; - for (auto&& n : tile_norms_) { + for (auto& n : tile_norms_) { if (n < threshold()) { + n = 0; ++zero_tile_count; } } @@ -308,7 +312,7 @@ class SparseShape { zero_tile_count_ = scale_tile_norms( tile_norms_, size_vectors_.get()); } else { - zero_tile_count_ = compute_zero_tile_count(); + zero_tile_count_ = screen_out_zero_tiles(); } } @@ -382,7 +386,7 @@ class SparseShape { tile_norms_, size_vectors_.get()); ; } else { - zero_tile_count_ = compute_zero_tile_count(); + zero_tile_count_ = screen_out_zero_tiles(); } } @@ -406,7 +410,7 @@ class SparseShape { const TiledRange& trange) : SparseShape(tile_norms, trange) { world.gop.max(tile_norms_.data(), tile_norms_.size()); - zero_tile_count_ = compute_zero_tile_count(); + zero_tile_count_ = screen_out_zero_tiles(); } /// Copy constructor