flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tillrohrmann <...@git.apache.org>
Subject [GitHub] flink pull request: FLINK-1737: Kronecker product
Date Mon, 23 Nov 2015 15:28:24 GMT
Github user tillrohrmann commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1078#discussion_r45615952
  
    --- Diff: flink-staging/flink-ml/src/main/scala/org/apache/flink/ml/math/SparseVector.scala
---
    @@ -85,6 +86,39 @@ case class SparseVector(
         }
       }
     
    +  /** Returns the outer product (a.k.a. Kronecker product) of `this`
    +    * with `other`. The result is given in [[org.apache.flink.ml.math.SparseMatrix]]
    +    * representation.
    +    *
    +    * @param other a Vector
    +    * @return the [[org.apache.flink.ml.math.SparseMatrix]] which equals the outer product
of `this`
    +    *         with `other.`
    +    */
    +  override def outer(other: Vector): SparseMatrix = {
    +    val numRows = size
    +    val numCols = other.size
    +
    +    val entries = other match {
    +      case sv @ SparseVector(_, _, _) =>
    +       for {
    +          i <- indices
    +          j <- sv.indices
    +          value = data(indices.indexOf(i)) * sv.data(sv.indices.indexOf(j))
    --- End diff --
    
    `zipWithIndex` to avoid search in `indices` for `i` and `j`.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message