例如123445678912所有值都减去1234代码该怎么写,谢谢!...
1 回答
汪汪一只猫
TA贡献1898条经验 获得超8个赞
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.numRows
val numCols = dm.numCols
val oldArray = dm.toArray
val 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)
- 1 回答
- 0 关注
- 910 浏览
添加回答
举报
0/150
提交
取消