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

    https://github.com/apache/spark/pull/4459#discussion_r24436973
  
    --- Diff: mllib/src/main/scala/org/apache/spark/mllib/linalg/BLAS.scala ---
    @@ -235,12 +235,23 @@ private[spark] object BLAS extends Serializable with 
Logging {
        * @param x the vector x that contains the n elements.
        * @param A the symmetric matrix A. Size of n x n.
        */
    -  def syr(alpha: Double, x: DenseVector, A: DenseMatrix) {
    +
    +  // Wrapper around the dense and sparse methods.
    +  def syr(alpha: Double, x: Vector, A: DenseMatrix) {
         val mA = A.numRows
         val nA = A.numCols
    -    require(mA == nA, s"A is not a symmetric matrix. A: $mA x $nA")
    +    require(mA == nA, s"A is not a square matrix (and hence is not 
symmetric). A: $mA x $nA")
         require(mA == x.size, s"The size of x doesn't match the rank of A. A: 
$mA x $nA, x: ${x.size}")
     
    +    x match {
    +      case dv: DenseVector => syr(alpha, dv, A, mA, nA)
    +      case sv: SparseVector => syr(alpha, sv, A, nA)
    +      case _ =>
    +        throw new IllegalArgumentException(s"syr doesn't support vector 
type ${x.getClass}.")
    +    }
    +  }
    +
    +  private def syr(alpha: Double, x: DenseVector, A: DenseMatrix, mA: Int, 
nA: Int) {
    --- End diff --
    
    If `mA == nA`, I don't think we need `mA` and `nA` here. We don't support 
submatrix slicing at this time, so the API should be `syr(alpha, x, A)`. Scala 
should recognize overloaded methods correctly.


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