This commit tears out support for NRoot[Rational] using implicit ApproximationContext[Rational] instances. Now that we have Algebraic and Real, we don't need to support this case. We do still have Numeric[Rational] and Fractional[Rational], but those just use Double approximations. Users who require more precision can reach for Real or Algebraic. Fixes #392.
This commit adds several extra scalac options that will help us catch errors. All warnings have been eliminated, and moving forward we should prevent any new warnings from being added. (Due to inliner warnings, which can't be suppressed, we can't use -Xfatal-warnings, unfortunately.) Eventually I'd like to do more static checking (and maybe enforce some common style/idioms), but this is a good first step.
``` scala> spire.util.Opt("a").toRight(1) res0: Product with Serializable with scala.util.Either[Int,String] = Right(a) ```
As suggested by @denisrosset
Also allow unicode superscripts when parsing polynomials
This commit adds a termsIterator method to Polynomial. This method returns an Iterator[Term[C]] for all non-zero coefficients in the polynomial, from smallest-exponent to largest. This iterator is used to implement equality and hashCode in a standardized way that works for dense and sparse polynomials. The hashing formula used is essentially: val it: Iterator[Term[C]] = p.termsIterator val ns: Iterator[Int] = it.map(t => (0xfeed1257 * t.exp) ^ t.coeff.##) val hashCode: Int = ns.foldLeft(0)(_ ^ _) One useful side-effect is that if the terms iterator is empty (i.e. the polynomial is zero) the hash code is 0. Also, if p consists of a single term whose exponent is zero, the overall hashCode will be identical to the hash code of the term's cofficient. One gotcha with the termsIterator method is that it uses a (_ == 0) test to filter out terms whose coefficient is zero. This necessary in order to support universal equality, and is documented in the method's ScalaDoc comment. We could choose to make this method private to Spire if it is deemed to be "too dangerous".