factory-0.0.0.2: Rational arithmetic in an irrational world.

Factory.Math.Summation

Contents

Description

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

Synopsis

Functions

sum'Source

Arguments

:: (Num n, NFData n) 
=> Int

The Chunk-length.

-> [n] 
-> n 
  • 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 iSource

sumRSource

Arguments

:: (Integral i, NFData i) 
=> Int

The Chunk-length.

-> [Ratio i] 
-> Ratio i 
  • 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.