0
下面的示例尝试乘以Double
类型的标量数与SparseVector[(Int, Double)]
:如何将SparseVector与Breeze中的标量相乘?
val a = SparseVector(10)(3 -> 1.0, 6 -> 2.0, 9 -> 3.0)
val b = 5.0 * a
代码编译失败,因为
Error: could not find implicit value for parameter op: breeze.linalg.operators.OpMulMatrix.Impl2[Double,breeze.linalg.SparseVector[(Int, Double)],That] val b = 5.0 * a
看来这种类型乘法的隐含的实现是失踪。
然而,如果我们做同样的事情在DenseVector[Double]
,一切都很好:
val a = DenseVector(1.0, 2.0, 3.0)
val b = 5.0 * a
我错过了一个包,我应该为进口稀疏的情况下?