Ring[Jet[...]] for Double/Float, but not Int/Long/BigInt?

3 views
Skip to first unread message

Kevin Meredith

unread,
Apr 27, 2015, 10:20:31 PM4/27/15
to spire...@googlegroups.com
Why does an implicit exist for Ring[Jet[Double/Float]], but not for Ring[Jet[Int/BigInt/Long]]?

>could not find implicit value for evidence parameter of type spire.algebra.Ring[spire.math.Jet[Int]]

I'm assuming that it's a math reason, i.e. not a programming omission, but double-checking to learn.

Erik Osheim

unread,
Apr 27, 2015, 10:34:51 PM4/27/15
to Kevin Meredith, spire...@googlegroups.com
On Mon, Apr 27, 2015 at 07:20:31PM -0700, Kevin Meredith wrote:
> Why does an implicit exist for Ring[Jet[Double/Float]], but not for
> Ring[Jet[Int/BigInt/Long]]?

In this case it's actually more of a programming reason: the JetIsRing
trait which extends Ring[Jet[T]] requires a Field[T] (among other
things). The reason for this is that most of Jet[T]'s operations
(e.g. + and -) require a Field[T].

Jet[T] exists primarily to facilitate automatic differentiation [1],
something we don't directly support in Spire yet. It should be
possible to relax Jet's operators to only require the minimal
algebraic structures (e.g. an AdditiveSemigroup[T] instead of a
Field[T] for +).

It's not clear to me how useful this change would be -- I don't use
Jet[T] extensively and haven't needed a Jet[Int]. If you have a use
case for Jet[Int] (or even just a desire to "fix" this) I'd be happy
to get a PR that loosens these sorts of constraints.

Thanks,

-- Erik

[1] https://en.wikipedia.org/wiki/Automatic_differentiation
Reply all
Reply to author
Forward
0 new messages