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

    https://github.com/apache/spark/pull/2451#discussion_r17800687
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala 
---
    @@ -37,11 +44,197 @@ trait Matrix extends Serializable {
       private[mllib] def toBreeze: BM[Double]
     
       /** Gets the (i, j)-th element. */
    -  private[mllib] def apply(i: Int, j: Int): Double = toBreeze(i, j)
    +  private[mllib] def apply(i: Int, j: Int): Double
    +
    +  /** Return the index for the (i, j)-th element in the backing array. */
    +  private[mllib] def index(i: Int, j: Int): Int
    +
    +  /** Update element at (i, j) */
    +  private[mllib] def update(i: Int, j: Int, v: Double): Unit
    +
    +  /** Get a deep copy of the matrix. */
    +  def copy: Matrix
     
    +  /** Convenience method for `Matrix`-`Matrix` multiplication.
    +    * Note: `SparseMatrix`-`SparseMatrix` multiplication is not supported 
*/
    +  def multiply(y: Matrix): DenseMatrix = {
    +    val C: DenseMatrix = DenseMatrix.zeros(numRows, y.numCols)
    +    BLAS.gemm(false, false, 1.0, this, y, 0.0, C)
    +    C
    +  }
    +
    +  /** Convenience method for `Matrix`-`DenseVector` multiplication. */
    +  def multiply(y: DenseVector): DenseVector = {
    +    val output = new DenseVector(new Array[Double](numRows))
    +    BLAS.gemv(1.0, this, y, 0.0, output)
    +    output
    +  }
    +
    +  /** Convenience method for `Matrix`^T^-`Matrix` multiplication.
    +    * Note: `SparseMatrix`-`SparseMatrix` multiplication is not supported 
*/
    +  def transposeMultiply(y: Matrix): DenseMatrix = {
    --- End diff --
    
    How hard would it be to have matrices store a transpose bit indicated if 
they are transposed (without the data being moved)?  I envision:
    * transpose() function which sets this bit (so transpose is a lazy 
operation)
    * eliminate transposeMultiply
    * perhaps include a transposePhysical or tranpose(physical: Boolean) method 
which forces data movement
    I'm also OK with adding that support later on.


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