Hi,
I've recently started exploring Scala and Breeze because I want to implement some Bayesian computations for agent based simulations. I am using IntelliJ (worksheet) and I'm aware that the issue I am encountering might be related to the IDE, but I'd like to know for sure I'm not doing anything wrong.
I've written two normalization methods, one that normalizes by rows and one that does so by columns:
def normalizeRows(mapping: DenseMatrix[Double]) : DenseMatrix[Double] = {
val rowSums :DenseVector[Double] = sum(mapping(*,::))
var res : DenseMatrix[Double] = mapping(::,*) / rowSums
return res
}
def normalizeColumns(mapping: DenseMatrix[Double]) : DenseMatrix[Double] = {
val columnSums = sum(mapping(::,*))
var res : DenseMatrix[Double] = mapping(*,::) / columnSums
return res
}
For some reason, compilation errors on the normalizeColumns method with the following message:
Error:(26, 52) could not find implicit value for parameter op: breeze.linalg.operators.OpDiv.Impl2[breeze.linalg.BroadcastedRows[breeze.linalg.DenseMatrix[Double],breeze.linalg.DenseVector[Double]],breeze.linalg.Transpose[breeze.linalg.DenseVector[Double]],That]
var res : DenseMatrix[Double] = mapping(*,::) / columnSums
^
Error:(26, 52) not enough arguments for method /: (implicit op: breeze.linalg.operators.OpDiv.Impl2[breeze.linalg.BroadcastedRows[breeze.linalg.DenseMatrix[Double],breeze.linalg.DenseVector[Double]],breeze.linalg.Transpose[breeze.linalg.DenseVector[Double]],That])That.
Unspecified value parameter op.
var res : DenseMatrix[Double] = mapping(*,::) / columnSums
^
But normalizeRows works just fine if I comment out normalizeColumns. I did my best to add as many types explicitly, but my Scala skills are still quite limited so perhaps I overlooked something? Hope someone can help me out, because I'm really enthusiastic about Scala but for my project I do need a matrix library like Breeze. Thanks!!
Best,
Mark