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

    https://github.com/apache/flink/pull/2052#discussion_r65170092
  
    --- Diff: 
flink-libraries/flink-ml/src/main/scala/org/apache/flink/ml/math/SparseVector.scala
 ---
    @@ -175,10 +176,21 @@ case class SparseVector(
     
         java.util.Arrays.binarySearch(indices, 0, indices.length, index)
       }
    +
    +  def + (other: Vector): Vector = (this.asBreeze + 
other.asBreeze).fromBreeze
    +
    +  def - (other: Vector): Vector = (this.asBreeze - 
other.asBreeze).fromBreeze
    +
    +  def * (scalar: Double): Vector = (scalar * this.asBreeze).fromBreeze
    +
    --- End diff --
    
    Remark:  when I put `+` and `-` in the `Vector` Trait to avoid duplication 
of code, it works fine, but not when I add the `*` method to the `Vector` 
Trait.  I get errors even when using `+` when I add the `*` method in `Vector`, 
namely:
    
    ```
    Error:(86, 68) could not find implicit value for evidence parameter of type 
org.apache.flink.ml.math.BreezeVectorConverter[T]
      def + (other: Vector): Vector = (this.asBreeze + 
other.asBreeze).fromBreeze
                                                   ^
    ```
    
    This error does not appear if I have `+` and `-` in Vector.scala and keep 
`*` duplicated in both DenseVector.scala and SparseVector.scala.  Found it 
weird then to have `+` and `-` in Vector.scala and `*` separate.  This is why I 
decided to duplicate the code in DenseVector and SparseVector.  Happy to hear 
if anyone knows of a way to avoid this.


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

Reply via email to