【发布时间】:2020-07-31 07:08:23
【问题描述】:
我正在尝试运行这个简单的程序:
object Test {
def foo(args: (Double, Double, Double)*) = {
val x = DenseMatrix(args.toList :_*)
val r = DenseVector(5.0, 5.0, 0.0)
println(sum(x(*, ::) - r)) // works
val func = new DiffFunction[DenseVector[Double]] {
def calculate(r: DenseVector[Double]) = {
sum(x(*, ::) - r) // Doesn't work
}
}
}
def main(args: Array[String]) {
foo((0.0, 0.0, 0.0), (5.0, 5.0, 0.0), (10.0, 0.0, 0.0))
}
}
但我收到以下错误:
Missing arguments for method *(B)(OpMulMatrix.Impl2[TT, B, That])
Missing arguments for method *(B)(OpMulMatrix.Impl2[TT, B, That])
Cannot resolve symbol *
似乎我不能使用运算符 * 来引用 DiffFunction 中矩阵的每一行。
为什么在 DiffFunction 外部使用运算符 * 访问矩阵行并从中减去向量有效,但在 DiffFunction 内部却不行?
【问题讨论】:
标签: scala scala-breeze