Github user mengxr commented on a diff in the pull request: https://github.com/apache/spark/pull/2294#discussion_r17255307 --- Diff: mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala --- @@ -63,7 +88,162 @@ class DenseMatrix(val numRows: Int, val numCols: Int, val values: Array[Double]) override def toArray: Array[Double] = values - private[mllib] override def toBreeze: BM[Double] = new BDM[Double](numRows, numCols, values) + private [mllib] def toBreeze: BM[Double] = new BDM[Double](numRows, numCols, values) + + private [mllib] def apply(i: Int): Double = values(i) + + private [mllib] def apply(r: Int, c: Int): Double = values(index(r, c)) + + private [mllib] def index(r: Int, c: Int): Int = r + numRows * c + + private [mllib] def update(r: Int, c: Int, v: Double){ + values(index(r, c)) = v + } + + def copy = new DenseMatrix(numRows, numCols, values.clone()) +} + +/** + * Factory methods for [[org.apache.spark.mllib.linalg.DenseMatrix]]. + * + * These methods can be used to generate common matrix types such as the Identity matrix, any + * diagonal matrix, zero matrix, and random matrices. + */ +object DenseMatrix { --- End diff -- We can move those functions to `Matrices`.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org