numeric precision of sum function

Forum for PAL Users and Developers

numeric precision of sum function

Postby piotr5 » 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...
piotr5
 
Posts: 230
Joined: Sun Dec 23, 2012 2:48 pm

Return to PAL

Who is online

Users browsing this forum: No registered users and 1 guest

cron