C++ Summation Toolkit

 www.partow.net  .: Home :.   .: Links :.   .: Search :.   .: Contact :. 


Description

The C++ Summation Toolkit is a simple library designed for summing lists of homogeneous Real values comprised of types such as double or float. The fundamental summation routines make use of Kahan summation in order to reduce overall computation error, furthermore they also attempt trivial loop unrolling so as to increase execution performance.

The routines are primarily intended to be used as building blocks for more complex, possibly multi-threaded and precision sensitive summation processes.

Summation Toolkit Library License

Free use of the Summation Toolkit Library is permitted under the guidelines and in accordance with the MIT License.

Download

Compatibility

The C++ Summation Toolkit Library implementation is fully compatible with the following C++ compilers:

  • GNU Compiler Collection (3.5+)
  • Clang/LLVM (1.1+)
  • Microsoft Visual Studio C++ Compiler (7.1+)
  • Intel® C++ Compiler (8.x+)
  • AMD Optimizing C++ Compiler (1.2+)
  • Nvidia C++ Compiler (19.x+)
  • PGI C++ (10.x+)
  • IBM XL C/C++ (9.x+)
  • C++ Builder (XE4+)

Simple Summation Example

The following quick example demonstrates summation of a list of doubles, using the 8-fold loop unrolling summation variant:

#include <cstdio>
#include "sumtk.hpp"

int main()
{
   const std::size_t dsize = 60000007;
   double* d = new double[dsize];

   for (std::size_t i = 0; i < dsize; ++i)
   {
      d[i] = (i & 1) ? 0.0000000123 : 12345.0000000001;
   }

   double sum = sumtk::sum(d,d + dsize,8);

   printf("sum: %35.15f",sum);

   delete[] d;
   return 0;
}
                     



© Arash Partow. All Rights Reserved.