today i have a question about the multiplication process. ok , so the situation is that a have an array of numbers spanning from 230000..900000. oh, i have a dual core proc. my question is how to multiply the array of numbers but as fast as possible. i prefer not to use log function or gamma function due to some later errors i get(i'm referring to those that see the similarity with factorial function). so what i got for now is to do something like this:
but this is too slow. then i thought ok let paralyze the whole bloody thing... but how should i paralyze it so that it get the procedure going as fastest as it can. should i :my $k=1; for (230000..900000){ $k*=$_ } print $k; # typical alg. for factorial calculation
or maybethread1 : for (230000..565000){ #multiply } thread2: for (565001..900000){ #multiply }
or maybe someone has a shortcut on how to reduce the multiplication stepthread1 : for (230000..397500,732500..900000){ #multiply } thread2: for (397500..732500){ #multiply } # it will run faster
does anyone has an alternative idea. i would like to hear an 'outside the box' opinion :). all comments are welcomed !
cheers
baxy
UPDATE:
First sorry for the misspell, i mistype the word and then just choose the first suggestion the spellchecker gives me without seeing what i have picked. Sorry!
Why do i need this precision. this number is then used in a recursive calculation that reduces the number up to a 1e-300. this is then used for a weighting and the difference in this case is huge, up to a 1e50 , that is 50 orders of magnitude if i use log or Stirling. and this is a problem for me, because depending on the later entropy that i'm calculating this means difference between the some biological signal that is important to me and case where there is no signal.... so ....
Why do i use Perl?
the difference that i'm getting for the brute force alg. that i mentioned between c and Perl is more or less big but not big enough. which means it is not the language that is the problem but the method.
and yes the bignum is used. i was assuming that was clear from the example i gave
the cancellation for such a big array of numbers i haven't considered since this is the canceled form , kind of ...
cheers
In reply to how to multiply an array of number as fast as posible by baxy77bax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |