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

    https://github.com/apache/spark/pull/4274#discussion_r23832163
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/mllib/linalg/distributed/BlockMatrix.scala
 ---
    @@ -237,4 +239,88 @@ class BlockMatrix(
         val localMat = toLocalMatrix()
         new BDM[Double](localMat.numRows, localMat.numCols, localMat.toArray)
       }
    +
    +  /** Adds two block matrices together. The matrices must have the same 
size and matching
    +    * `rowsPerBlock` and `colsPerBlock` values. */
    +  def add(other: BlockMatrix): BlockMatrix = {
    +    require(numRows() == other.numRows(), "Both matrices must have the 
same number of rows. " +
    +      s"A.numRows: ${numRows()}, B.numRows: ${other.numRows()}")
    +    require(numCols() == other.numCols(), "Both matrices must have the 
same number of columns. " +
    +      s"A.numCols: ${numCols()}, B.numCols: ${other.numCols()}")
    +    if (checkPartitioning(other, OperationNames.add)) {
    --- End diff --
    
    Can we embed the `checkPartitioning` logic here? It is a one-line code 
comparing block sizes. If they don't match, we can throw exception directly. 
That makes the code simpler to read.


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