Skip to content

Commit 6aa69b0

Browse files
committed
optimize code thanks to HanatoK's recommendations
1 parent 086ee65 commit 6aa69b0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/colvargrid_integrate.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,10 @@ void colvargrid_integrate::prepare_calculations()
993993
cvm::real multiplicity = laplacian_stencil.size();
994994
// Precalculation of the laplacian coefficient
995995
cvm::real diagonal_coeff;
996+
size_t coeff_address;
996997
for (std::vector<int> ix = computation_grid->new_index(); computation_grid->index_ok(ix);
997998
computation_grid->incr(ix)) {
999+
coeff_address = computation_grid->address(ix) * multiplicity;
9981000
diagonal_coeff = 0;
9991001
for (size_t i = 0; i < laplacian_stencil.size() - 1; i++) {
10001002
std::vector<int> neighbor_relative_position = laplacian_stencil[i];
@@ -1014,10 +1016,10 @@ void colvargrid_integrate::prepare_calculations()
10141016
coefficient += regularized_weights[gradients->address(weight_coordinate)];
10151017
}
10161018
coefficient *= weight_counts[i];
1017-
laplacian_coefficients[computation_grid->address(ix) * multiplicity + i] += coefficient;
1019+
laplacian_coefficients[coeff_address + i] += coefficient;
10181020
diagonal_coeff += coefficient;
10191021
}
1020-
laplacian_coefficients[computation_grid->address(ix) * multiplicity + (2 * nd)] +=
1022+
laplacian_coefficients[coeff_address + (2 * nd)] +=
10211023
-diagonal_coeff;
10221024
}
10231025
}

0 commit comments

Comments
 (0)