Based on discussion on the newsgroup today about the errors in summing large arrays, I implemented the Kahan summation algorithm as a routine in a DLM. Download, unzip, and build it with the following command:

IDL> mg_make_dll, 'mg_analysis.c', /show_all_output

Don’t forget to put the directory with the DLM in your IDL_DLM_PATH.

I thought it would be interesting because of the discussion in the newsgroup and the fact that it was pretty simple to make it work for all the different numeric data types IDL offers (for an example of when it is not so simple, check out the implementation of MG_ARRAY_EQUAL in the source code).

Continue reading “DLM implementing Kahan summation.”