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

    https://github.com/apache/spark/pull/3319#discussion_r21881450
  
    --- 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 --
    
    MATLAB does it the other way around. If one matrix is sparse, then the 
final matrix turns out to be sparse as well.
    That's why I added the note. Should I make it consistent with MATLAB?


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