在下面的方法中,我试图将 DenseVector 乘以 DenseVector ,其中 DenseVector 之一是方法参数:
def mult(features : DenseVector[Array[Int]]) = {
val dv = new DenseVector(Array(-30, 20 , 20))
features :* dv
}
这会导致编译器错误:
Multiple markers at this line:
◾could not find implicit value for parameter op: breeze.linalg.operators.OpMulScalar.Impl2[breeze.linalg.DenseVector[Array[Int]],breeze.linalg.DenseVector[Int],That]
◾not enough arguments for method :*: (implicit op: breeze.linalg.operators.OpMulScalar.Impl2[breeze.linalg.DenseVector[Array[Int]],breeze.linalg.DenseVector[Int],That])That. Unspecified value parameter op.
◾could not find implicit value for parameter op: breeze.linalg.operators.OpMulScalar.Impl2[breeze.linalg.DenseVector[Array[Int]],breeze.linalg.DenseVector[Int],That]
◾not enough arguments for method :*: (implicit op: breeze.linalg.operators.OpMulScalar.Impl2[breeze.linalg.DenseVector[Array[Int]],breeze.linalg.DenseVector[Int],That])That. Unspecified value parameter op.
此代码编译:
def mult(features : breeze.linalg.DenseVector[Array[Int]]) = {
val dv1 = new breeze.linalg.DenseVector(Array(-30, 20 , 20))
val dv2 = new breeze.linalg.DenseVector(Array(-30, 20 , 20))
dv1 :* dv2
}
如何将features
参数乘以dv
?我不确定编译器错误的含义,与我没有在方法中指定 DenseVector 的大小有关吗?