non/scala-numerics-refactor — pull request #6 by tixxit (2012-03-05 02:10:14+00:00)
Title: Add Real, floating point filters (FPFilter) and n-roots (NRoot).

This has the new Real and FPFilter types, as well as the NRoot (and *WithNRoot) type classes.

The new Real type is to Rationals and n-roots what Rationals are to BigInts and division. It implements exact geometric computation so that comparisons and sign tests are always exact for any radical expression (eg. in-circle test).

The FPFilter type provides a wrapper for other numeric types that may improve their speed when used for comparisons (and some conversions, like toInt). It defers evaluation of the wrapped type, instead maintaining a floating point (Double) version of the number along with an error bound. If the floating point number can be used without affecting the result of a comparison or conversion, it'll be used instead, otherwise the deferred evaluation of the underlying type will be forced.

The NRoot and associated type classes add n-roots (and so square roots) to the Numeric hierarchy. Although there is a NRoot trait, you probably want to use EuclideanRingWithNRoot, FieldWithNRoot, NumericWithNRoot, or FractionalWithNRoot, which extend the other standard type classes.

Lastly, a whole bunch of tests were added. Mostly for the floating point filters and Real type. However, there was also a new test suite added for the actual type class hierarchy and memberships (via TypeclassExistenceTest). These test to ensure that the hierarchy works as expected (Ring <: EuclideanRing) and that each number type has the expected type classes with it.