Bodigrim / arithmoi

Number theory: primes, arithmetic functions, modular computations, special sequences
http://hackage.haskell.org/package/arithmoi
MIT License
147 stars 40 forks source link

Added ordered Gaussian primes #124

Closed b-mehta closed 6 years ago

b-mehta commented 6 years ago

Resolves #122.

Added orderedPrimes for ordered Gaussian primes. primes may still be faster since Data.List.partition does not appear to fuse as a producer, even though it does fuse as a consumer and thus primes is retained also. That said, it may be hard to do a side-by-side comparison of the two as they have different use cases.

I've also changed the documentation for primes: It does not produce all the Gaussian primes (for instance -1-i is never produced), but it does produce them all up to associates.

Bodigrim commented 6 years ago

Added orderedPrimes for ordered Gaussian primes. primes may still be faster since...

IMHO the drawback of cluttering API with two similar but different functions overweights potential fusion losses. If in some circumstances this happens to be a critical performance bottleneck, a user can reimplement old primes using findPrimes. That said, my vote is to replace old primes with a sorted one, instead of introducing a new entry. What do you think?

b-mehta commented 6 years ago

Sounds good - any other changes you'd suggest?

Bodigrim commented 6 years ago

Everything else look good to me.