logo       

Re: Scala generics for automatic differentiation: msg#00300

lang.scala

Subject: Re: Scala generics for automatic differentiation

2007/1/23, Eric Willigers <ewilligers@xxxxxxxxx>:
Hi Michel,

Your Scala code needs to similarly make Dual a template. One way to do this
appears below. Hopefully it can be made more concise, perhaps fromDouble can
be replaced by an implicit conversion.

Regards,
Eric.

Thanks! I had bits and pieces of the solution earlier on, but was
missing the (in hindsight) obvious step of creating a trait that
MyDouble and Dual both extends. Still familiarizing myself with type
constraints which does not help either.

Regards,



trait Arithmetic[t <: Arithmetic[t]] {

def +(y: t): t

def *(y: t): t

def fromDouble(x: Double): t
}


--
Michel Salim
http://hircus.wordpress.com/

My theology, briefly, is that the universe was dictated but not signed.
-- Christopher Morley



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise