From d8a414fc2c92ed8553fa82d85e1126a403fb9afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=BChle=2C=20Laura=20Christine=20=28lakue103=29?= <laura.kuehle@uni-duesseldorf.de> Date: Fri, 28 Oct 2022 13:43:11 +0200 Subject: [PATCH] Vectorized '_calculate_coarse_projection()' for wavelet detectors. --- scripts/tcd/Troubled_Cell_Detector.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/scripts/tcd/Troubled_Cell_Detector.py b/scripts/tcd/Troubled_Cell_Detector.py index 6d168ac..d33a51a 100644 --- a/scripts/tcd/Troubled_Cell_Detector.py +++ b/scripts/tcd/Troubled_Cell_Detector.py @@ -287,15 +287,8 @@ class WaveletDetector(TroubledCellDetector): projection = projection[:, 1:-1] # Calculate projection on coarse mesh - output_matrix = [] - for i in range(self._mesh.num_cells//2): - new_entry = 0.5 * ( - projection[:, 2 * i] @ basis_projection_left - + projection[:, 2 * i + 1] @ basis_projection_right) - output_matrix.append(new_entry) - coarse_projection = np.transpose(np.array(output_matrix)) - - return coarse_projection + return 0.5 * (basis_projection_left.T @ projection[:, ::2] + + basis_projection_right.T @ projection[:, 1::2]) def create_data_dict(self, projection): """Return dictionary with data necessary to plot troubled cells.""" -- GitLab