汪汪一只猫
import org.apache.spark.mllib.linalg.{Matrix, Matrices}val dm: Matrix = Matrices.dense(3, 4, Array(1, 4, 8, 2, 5, 9, 3, 6, 1, 4, 7, 2))println(dm)val numRows = dm.numRowsval numCols = dm.numColsval oldArray = dm.toArrayval newArray = new Array[Double](numRows * numCols)for (i <- 0 until numRows) {for (j <- 0 until numCols) {newArray(j * numRows + i) = oldArray(j * numRows + i) - oldArray(j * numRows)}}val newDm: Matrix = Matrices.dense(3, 4, newArray)println(newDm)