### numeric precision of sum function

Posted:

**Wed Jun 24, 2015 6:32 am**mathematicians and probably also it-people will learn that calculating a big sum of floats requires that they are sorted by exponent (or absolute value) first. this way small values are added up first and maybe result in some bigger value which is relevant for higher exponents, instead of introducing the big exponents first and then the small values wont matter at all.

now the reference implementation in pal doesn't do any kind of sorting, guess it is assumed the numbers are already sorted? do we need an additional function for actually doing sorting and summing up in a single step? there isn't much speed-gain possible in summation. (well, on assembler level it might be a good idea to sum up pairs so that next step doesn't depend on the previous, but on epiphany or recent x86 this doesn't matter.) but if you add a naive sorting algorithm it might make a difference. (using the existing sorting, keep in mind that you need the absolute value first.)

btw, a function for partial sum also seems to be missing. on simd it's easy to implement in log time. sum then is a by-product of that algorithm, although it then is lacking the precision from enforcing sorted sum...

to summarize: please add sort_sum and part_sum and maybe sort_part_sum to the function list in the math directory. also a lg function for log2 might be useful for turning products into sums. if not, I'll do it after this month ends...

now the reference implementation in pal doesn't do any kind of sorting, guess it is assumed the numbers are already sorted? do we need an additional function for actually doing sorting and summing up in a single step? there isn't much speed-gain possible in summation. (well, on assembler level it might be a good idea to sum up pairs so that next step doesn't depend on the previous, but on epiphany or recent x86 this doesn't matter.) but if you add a naive sorting algorithm it might make a difference. (using the existing sorting, keep in mind that you need the absolute value first.)

btw, a function for partial sum also seems to be missing. on simd it's easy to implement in log time. sum then is a by-product of that algorithm, although it then is lacking the precision from enforcing sorted sum...

to summarize: please add sort_sum and part_sum and maybe sort_part_sum to the function list in the math directory. also a lg function for log2 might be useful for turning products into sums. if not, I'll do it after this month ends...