factory-0.3.0.0: Rational arithmetic in an irrational world.

Safe HaskellNone
LanguageHaskell2010

Factory.Math.Summation

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
Provides an alternative algorithm for the summation of rational numbers.

Synopsis

Functions

sum' :: (Num n, NFData n) => ChunkLength -> [n] -> n Source #

  • Sums a list of numbers of arbitrary type.
  • Sparks the summation of (list-length / chunk-size) chunks from the list, each of the specified size (thought the last chunk may be smaller), then recursively sums the list of results from each spark.
  • CAVEAT: unless the numbers are large, Rational (requiring cross-multiplication), or the list long, sum is too light-weight for sparking to be productive, therefore it is more likely to be the parallelised deep evaluation of list-elements which saves time.

sumR' :: Integral i => [Ratio i] -> Ratio i Source #

  • Sums a list of rational type numbers.
  • CAVEAT: though faster than sum, this algorithm has poor space-complexity, making it unsuitable for unrestricted use.

sumR :: (Integral i, NFData i) => ChunkLength -> [Ratio i] -> Ratio i Source #

  • Sums a list of rational numbers.
  • Sparks the summation of (list-length / chunk-length) chunks from the list, each of the specified size (thought the last chunk may be smaller), then recursively sums the list of results from each spark.
  • CAVEAT: memory-use is proportional to chunk-size.