//Original Vector and Weight Vector init
org.apache.spark.ml.linalg.Vector rowVec=Vectors.dense(2.0, 5.0, 10.0);
org.apache.spark.ml.linalg.Vector wtVec=Vectors.dense(1.0, 2.0, 0.5);
//Converting to Breeze
breeze.linalg.Vector brzRowVector= rowVec.asBreeze();
breeze.linalg.Vector brzWeightVector= wtVec.asBreeze();
//Multiply the Original Vector with Weight Vector
org.apache.spark.ml.linalg.Vector updRowVector = (org.apache.spark.ml.linalg.Vector)
brzRowVector.$colon$times(brzWeightVector, new UFunc.UImpl2() {
@Override
public Object apply(Object v, Object o) {
return null;
}
});
//updRowVectorhould return {2.0, 10.0, 5.0}
--
You received this message because you are subscribed to the Google Groups "Scala Breeze" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-breeze+unsubscribe@googlegroups.com.
To post to this group, send email to scala-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-breeze/76c8cb8f-53c1-4eb2-a311-35e6b7f434a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Breeze really isn't designed to be used from Java. You can do it, but it's not going to be any better than just writing a loop yourself most of the time.
On Mon, Jun 5, 2017 at 8:27 AM, UNM <umesh...@gmail.com> wrote:
Hi Team,My requirement is to multiply two vectors element wise. Here's the code I've written but I am not able to make it work because I don't know what to do with "UFunc.UImpl2" and I am also not sure whether I am using the right function or not. Can any one help please.Thanks in advance,UNM//Original Vector and Weight Vector init
org.apache.spark.ml.linalg.Vector rowVec=Vectors.dense(2.0, 5.0, 10.0);
org.apache.spark.ml.linalg.Vector wtVec=Vectors.dense(1.0, 2.0, 0.5);
//Converting to Breeze
breeze.linalg.Vector brzRowVector= rowVec.asBreeze();
breeze.linalg.Vector brzWeightVector= wtVec.asBreeze();
//Multiply the Original Vector with Weight Vector
org.apache.spark.ml.linalg.Vector updRowVector = (org.apache.spark.ml.linalg.Vector)
brzRowVector.$colon$times(brzWeightVector, new UFunc.UImpl2() {
@Override
public Object apply(Object v, Object o) {
return null;
}
});//updRowVectorhould return {2.0, 10.0, 5.0}
--
You received this message because you are subscribed to the Google Groups "Scala Breeze" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-breeze...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-breeze+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-breeze/d45599e1-da1a-406d-a8f4-3cbd22c7a00a%40googlegroups.com.