It turns out that MATLAB’s implementation is significantly faster than my own Fortran implementation.