Note
Go to the end to download the full example code.
Benchmark of Error-Free Transforms for summation#
This benchmark compares accuracy and efficiency of several summation algorithms in floating point arithmetics
def naive_sum(x):
return choreo.scipy_plus.cython.eft_lib.FastSumK(x,0)
def builtin_sum(x):
return sum(x)
def np_sum(x):
return np.sum(x)
def m_fsum(x):
return m.fsum(x)
def SumK_1(x):
return choreo.scipy_plus.cython.eft_lib.SumK(x,1)
def SumK_2(x):
return choreo.scipy_plus.cython.eft_lib.SumK(x,2)
def SumK_3(x):
return choreo.scipy_plus.cython.eft_lib.SumK(x,3)
def FastSumK_1(x):
return choreo.scipy_plus.cython.eft_lib.FastSumK(x,1)
def FastSumK_2(x):
return choreo.scipy_plus.cython.eft_lib.FastSumK(x,2)
def FastSumK_3(x):
return choreo.scipy_plus.cython.eft_lib.FastSumK(x,3)
def prepare_x(n):
x = np.random.random(n)
return {'x': x}