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

Jacobi facelifting #103

Closed Bodigrim closed 6 years ago

Bodigrim commented 6 years ago

This is an attempt to facelift Math.NumberTheory.Moduli.Jacobi.

  1. There were two functions jacobi and jacobi', where the first one checked preconditions on arguments and the second one did not. I assume jacobi' was supposed to be "faster", but it is unsafe to use and clutters API. I have written benchmarks and it appeared that performance of both functions is actually pretty much the same. So I've removed jacobi'.

  2. As a part of #100 I've added specialised versions of jacobi on Natural.

  3. As a part of #79 I tried to refactor jac2 using Vector. But, taking closer look, it appeared that the code can be clarified, eliminating any need in either Array or Vector, using only simple bit tests.

  4. Elaborate comments with links to wiki and examples.