TRIQS / triqs

a Toolbox for Research on Interacting Quantum Systems
https://triqs.github.io
GNU General Public License v3.0
139 stars 72 forks source link

Micro optimize closest_mesh_pt #856

Closed hmenke closed 2 years ago

hmenke commented 2 years ago

Benchmarking CT-INT revealed that this code is incredibly hot, so it is worthwhile to spend some time micro optimizing it. We make use of the fact that this function only properly works for mesh points that are within the range of the mesh. This allows to completely elide the call to std::floor since for positive values this is equivalent to truncation. Futhermore division is replaced by multiplication with the precomputed inverse.

Co-authored-by: @Wentzell