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

    https://github.com/apache/spark/pull/3319#discussion_r21925528
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/linalg/Matrices.scala 
---
    @@ -313,15 +593,145 @@ object Matrices {
        * @return Square `DenseMatrix` with size `values.length` x 
`values.length` and `values`
        *         on the diagonal
        */
    -  def diag(vector: Vector): Matrix = {
    -    val n = vector.size
    -    val matrix = Matrices.eye(n)
    -    val values = vector.toArray
    -    var i = 0
    -    while (i < n) {
    -      matrix.update(i, i, values(i))
    -      i += 1
    +  def diag(vector: Vector): Matrix = DenseMatrix.diag(vector)
    +
    +  /**
    +   * Horizontally concatenate a sequence of matrices. The returned matrix 
will be in the format
    +   * the matrices are supplied in. Supplying a mix of dense and sparse 
matrices will result in
    +   * a dense matrix.
    --- End diff --
    
    I like the MATLAB approach better. Usually a sparse matrix is very sparse, 
while a dense component is quite small, for example,
    
    ~~~
    A^T A  A^T
    A      I
    ~~~


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to