An open source method of characteristics neutron transport code.
pairwise_sum.h File Reference

Utility function for the accurate pairwise sum of a list of floating point numbers. More...

Go to the source code of this file.

Functions

template<typename T , typename L >
double pairwise_sum (T *vector, L length)
 Performs a pairwise sum of an array of numbers. More...
 

Detailed Description

Utility function for the accurate pairwise sum of a list of floating point numbers.

Author
William Boyd (wboyd.nosp@m.@mit.nosp@m..edu)
Date
June 13, 2013

Function Documentation

◆ pairwise_sum()

template<typename T , typename L >
double pairwise_sum ( T *  vector,
length 
)
inline

Performs a pairwise sum of an array of numbers.

This type of summation uses a divide-and-conquer algorithm which is necessary to bound the error for summations of large sequences of numbers.

Parameters
vectoran array of numbers
lengththe length of the array
Returns
the sum of all numbers in the array