From 940e27224b63e30f5c851f788d89040604239c9a Mon Sep 17 00:00:00 2001 From: Simon Puchert Date: Thu, 7 Dec 2017 16:42:37 +0100 Subject: [PATCH] Small optimization. We can get rid of a scalar*vector operation by restructuring. This also allows tricks like computing theta/sin(theta) directly from cos(theta) and thus bypassing the atan2 operation. --- source/grid/manifold_lib.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/source/grid/manifold_lib.cc b/source/grid/manifold_lib.cc index 3bd2c3c25a..ff3b239193 100644 --- a/source/grid/manifold_lib.cc +++ b/source/grid/manifold_lib.cc @@ -697,7 +697,8 @@ namespace if (std::abs(weights[i])>1.e-15) { vPerp = internal::projected_direction(directions[i], candidate); - const double sintheta = vPerp.norm(); + const double sinthetaSq = vPerp.norm_square(); + const double sintheta = std::sqrt(sinthetaSq); if (sintheta