Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2451#discussion_r17802108
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala 
---
    @@ -57,13 +250,709 @@ trait Matrix extends Serializable {
      * @param numCols number of columns
      * @param values matrix entries in column major
      */
    -class DenseMatrix(val numRows: Int, val numCols: Int, val values: 
Array[Double]) extends Matrix {
    +class DenseMatrix(val numRows: Int, val numCols: Int, val values: 
Array[Double]) extends Matrix with Serializable {
     
    -  require(values.length == numRows * numCols)
    +  require(values.length == numRows * numCols, "The number of values 
supplied doesn't match the " +
    +    s"size of the matrix! values.length: ${values.length}, numRows * 
numCols: ${numRows * numCols}")
     
       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(i: Int, j: Int): Double = values(index(i, j))
    +
    +  private[mllib] def index(i: Int, j: Int): Int = i + numRows * j
    +
    +  private[mllib] def update(i: Int, j: Int, v: Double): Unit = {
    +    values(index(i, j)) = v
    +  }
    +
    +  override def copy = new DenseMatrix(numRows, numCols, values.clone())
    +
    +  private[mllib] def elementWiseOperateOnColumnsInPlace(
    +      f: (Double, Double) => Double,
    +      y: Matrix): DenseMatrix = {
    +    val y_vals = y.toArray
    +    val len = y_vals.length
    +    require(y_vals.length == numRows)
    --- End diff --
    
    Please add warning messages (here and in other require statements).


---
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

Reply via email to