Open tomerk opened 9 years ago
oh, that's different than I thought.
try:
def reducePoint[T : BreezeNumeric](x: DenseVector[T], mat: DenseMatrix[T]):
DenseVector[T] = {
val ops = implicitly[BreezeNumerics[T]]
import ops._
(x.t * mat).t
}
Hopefully you're ok with that much magic?
That works, thanks!. But, now I'm trying to do something more complicated:
def colMeans[T : BreezeNumeric](dataMat: DenseMatrix[T]) = {
val ops = implicitly[BreezeNumerics[T]]
import ops._
val means = (mean(dataMat(::, *))).toDenseVector
}
And I'm getting the following error on compilation:
Error:(56, 22) could not find implicit value for parameter impl: breeze.stats.mean.Impl[breeze.linalg.BroadcastedColumns[breeze.linalg.DenseMatrix[T],breeze.linalg.DenseVector[T]],VR]
val means = (mean(dataMat(::, *))).toDenseVector
^
Any suggestions on how to get broadcasting to work correctly here too?
Hrm, I don't think anyone's tried broadcasting using these spaces. Let me see what I can do.
if you look at the MutableOptimizationSpace companion object, you'll be able to see all the implicits that are included. I don't believe that broadcasting is one of them, possibly because the CSC Matrix isn't at parity with dense? Will take a look to cite code locations tomorrow.
@gabeos @dlwh - any further thoughts on this?
We are currently trying to make templatized methods that can operate on various numeric vectors & matrices.
At @dlwh's suggestion we have tried the following:
But on compilation we are getting a diverging implicits error: