TiarkRompf / virtualization-lms-core

A Framework for Runtime Code Generation and Compiled DSLs
http://scala-lms.github.com
BSD 3-Clause "New" or "Revised" License
323 stars 91 forks source link

Allow more heterogenous types in numeric operations #1

Open echu opened 13 years ago

echu commented 13 years ago

Using just LMS numerics, the following code emits errors:

N is of type Rep[Int] xs is of type Vector[Double]

val xbar = 1.0/N * sum(xs)

I am trying to compute the average here. 1.0 is of type Double, but 1.0/N throws an error, since it does not know how to divide a Double by Rep[Int].

When i try unit(1.0)/N, it says it can't divide Const[Double].

TiarkRompf commented 12 years ago

See also #22:

val a = unit(1.0)
val b = unit(1)
val c = a + b // c has type Rep[Double]
TiarkRompf commented 12 years ago

Maybe we should just add explicit arithmetic for all primitive types instead of relying on Numeric.

julienrf commented 11 years ago

See also #36