Kristina,

Thanks for the discussion. I = followed up on your problem and learned that Scala doesn't support multiple implicit conversions in a = single expression=C2=A0for complexity reasons. I'm afraid the solut= ion for now is to do (v1: BV[Double]) + (v1: BV[Double])

On Tue, Aug 25, 2015 at = 11:06 AM, Kristina Rogale Plazonic wrote:<= br>
:)))))))

On Tue, Aug 25, 201= 5 at 1:57 PM, Burak Yavuz wrote:
Hmm. I have a lot of code on the = local linear algebra operations using Spark's Matrix and Vector represe= ntations

I can make a Spark package with that cod= e if people are interested.

Best,
Burak<= /div>

On Tue, Aug 25, 2015 at 10:54 AM, Kristina Rogale Plazonic wrote:
However I do think it's easier than it seems to write the implici= ts;
it doesn't involve new classes or anything. Yes it's pretty much ju= st
what you wrote. There is a class "Vector" in Spark. This declarat= ion
can be in an object; you don't implement your own class. (Also you can<= br> use "toBreeze" to get Breeze vectors.)

The implicit conversion with the implicit def happens for the = first vector in the sum, but not the second vector (see below).=C2=A0
=

At this point I give up, because I spent way too much t= ime.=C2=A0 I am so disappointed.=C2=A0 So many times I heard "Spark ma= kes simple things easy and complicated things possible". Well, here is= the simplest thing you can imagine in linear algebra, but heck, it is not = easy or intuitive.=C2=A0 It was easier to run a DeepLearning algo (from ano= ther library) than add two vectors.=C2=A0

If anybo= dy has a workaround other than implementing your own add/substract/scalarMu= ltiply, PLEASE let me know.=C2=A0

Here is the code= and error from (freshly started) spark-shell:=C2=A0

scala> import breeze.linalg.{DenseVector =3D> BDV, SparseVect= or =3D> BSV, Vector =3D> BV}
import breeze.linalg.{DenseVec= tor=3D>BDV, SparseVector=3D>BSV, Vector=3D>BV}

scala> import org.apache.spark.mllib.linalg.Vectors
impo= rt org.apache.spark.mllib.linalg.Vectors

scala>= val v1 =3D Vectors.dense(1.0, 2.0, 3.0)
v1: org.apache.spark.mll= ib.linalg.Vector =3D [1.0,2.0,3.0]

scal= a> import org.apache.spark.mllib.linalg.{Vector =3D>SparkVector}
import org.apache.spark.mllib.linalg.{Vector=3D>SparkVector}
=

scala> object MyUtils {
=C2=A0 =C2=A0 =C2= =A0| =C2=A0 implicit def toBreeze(v:SparkVector) =3D BV(v.toArray)
=C2=A0 =C2=A0 =C2=A0| }
warning: there were 1 feature warning(s= ); re-run with -feature for details
defined module MyUtils
<= /div>

scala> import MyUtils._
import M= yUtils._

scala> v1:BV[Double]
res2: b= reeze.linalg.Vector[Double] =3D DenseVector(1.0, 2.0, 3.0)
=
scala> v1 + v1
<console>:30: error: = could not find implicit value for parameter op: breeze.linalg.operators.OpA= dd.Impl2[breeze.linalg.Vector[Double],org.apache.spark.mllib.linalg.Vector,= That]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 v1 + v1
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^

=C2=A0

--047d7bdc9e4ece021d051e26d48b--