You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In particular, the @specialised annotation does not appear to be effecitve. It appears to still emit Generic parameters into the emitted bytecode.
package mat
import scala.reflect.ClassTag
// LLM thinks this is performant
final class MatrixDoubleInternal(val raw: Array[Double], val rows: Int, val cols: Int)
// LLM thinks everything below here sucks.
final class MatrixGeneric2[A](
val raw: Array[A],
val rows: Int,
val cols: Int
)
// Generic final class
trait MatrixGeneric[A](
val raw: Array[A],
val rows: Int,
val cols: Int
)
type DoubleMatrix = MatrixGeneric[Double]
object DoubleMatrix2{
def apply(rows: Int, cols: Int): DoubleMatrix =
new MatrixGeneric[Double](Array.ofDim[Double](rows*cols), rows, cols){}
def apply[A](raw: Array[Double], rows: Int, cols: Int): DoubleMatrix =
new MatrixGeneric[Double](raw, rows, cols){}
}
It also seems to hate the current opaque class implementation for performance reasons.
In fact, there seems to be no compelling reason to not simply have "class" DoubleMatrix.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
As of June 2026, it seems t me, that it is not possible, to have a generic and performant implementation. Some reading;
scala/scala3#15532
scala/scala3#18044
scala/scala3#12161
In particular, the
@specialised
annotation does not appear to be effecitve. It appears to still emit Generic parameters into the emitted bytecode.It also seems to hate the current opaque class implementation for performance reasons.
In fact, there seems to be no compelling reason to not simply have "class" DoubleMatrix.
Beta Was this translation helpful? Give feedback.
All reactions