ifilot / hfcxx

Hartree-Fock C++ code
GNU General Public License v3.0
28 stars 16 forks source link

Speeding up factorial and double factorial #4

Closed aromanro closed 1 year ago

aromanro commented 4 years ago

Hi,

May I suggest an improvement?

There are ways to precompute the values and use the already computed values instead of computing them each time, using tables of values (computed even at compile time). This should speed up computations a little. Here is how I did it:

https://github.com/aromanro/HartreeFock/blob/master/HartreeFock/MathUtils.h https://github.com/aromanro/HartreeFock/blob/master/HartreeFock/MathUtils.cpp

In my case it doesn't make much difference but you use different methods for computing the integrals where it might count more.

ifilot commented 1 year ago

I have implemented look-up tables for the evaluation of the factorials and double factorials. It however does very little to the overall execution times as the factorials taken are small (only using s and p type orbitals). For some cases, the recursive approach is even faster.