jamesthompson/spire — pull request #3 by jamesthompson (2013-08-09 16:39:32+00:00)
Title: Add polynomial string interpolation support.

This change adds support for the poly"..." interpolator. For example:

import spire.implicits._

val i = 99.3
val j = r"3/17"
val k = BigInt(12345)

poly"${i}x^2 + ${j}x + $k"

This will produce (993/10x^2 + 3/17x + 12345). Any value whose toString
produces a valid rational number will work, even things like:

val s = "5"
poly"${s}x + 1"

For now, this is all happening at runtime, although it would be
possible to write a macro that evaluates these at compile-time, when
there is no interpolation, e.g.:

poly"x^2 + 3x - 6"

Also, this commit adds some cute new factory methods:

Polynomial.constant(3.0)
Polynomial.linear(r"44/7")
Polynomial.quadratic(4)
Polynomial.cubic(BigDecimal(16.23))