I'm trying to create a dense matrix in Spark and then transpose it using the following code:
val weightsMatrix = Matrices.dense(1, 3, Array.fill[Double](3)(0))
val weightsMatrix_t = weightsMatrix.transpose()
but it fails with the compilation error below.
not enough arguments for method apply: (i: Int, j: Int)Double in
trait Matrix.
[error] Unspecified value parameters i, j.
[error] val weightsMatrix_t = weightsMatrix.transpose()
[error] ^
[error] one error found
[error] (compile:compileIncremental) Compilation failed
I've checked in the documentation that the function transpose
does not take any parameters, but it seems a method named apply
is somehow involved.
The apply is referring to the () trialing your transpose. Transpose is a member variable of matrix so when you call tanspose it is returning a matrix and you are then calling an index on that matrix with no index values given. the solution is
val weightsMatrix_t = weightsMatrix.transpose
without the ()