Re: [scala-breeze] Vector dot product returns vector?

372 views
Skip to first unread message

David Hall

unread,
Nov 9, 2012, 10:45:11 AM11/9/12
to scala-...@googlegroups.com
On Fri, Nov 9, 2012 at 9:52 AM, MLnick <nick.pe...@gmail.com> wrote:
>
> Hi
>
> I'm doing a bit of playing around with breeze for use in a potential library. Trying the following:
>
> var r = DenseVector.rand(5); var g = DenseVector.rand(5)
> println(r, g)
> // (DenseVector(0.057312052796559154, 0.603576970954528, 0.4595477983002969, 0.4694604690636721, 0.19107834398076085),DenseVector(0.8629295915092834, 0.3899120624074236, 0.5890612242474883, 0.410202971158085, 0.5517934304629235))
>
> var v = r.t * g
> println(v)
> // DenseVector(0.8535098507053147)

use r dot g. making * return a scalar for x.t * y induces too much
overhead in terms of implementation.

-- David

>
> Shouldn't a vector dot product return a scalar? i.e. a Double in this case? Or am I missing something?
>
> It's a bit long-winded to have to chain together something like (r.t * g).valueAt(0) * someScalar - someOtherScalar etc etc...
>
> Just wondering if there is a way to do this, such that the formula syntax looks more natural (ie Matlab / numpy like)
>
> Thanks
> Nick
>
> --
> You received this message because you are subscribed to the Google Groups "Scala Breeze" group.
> To post to this group, send email to scala-...@googlegroups.com.
> To unsubscribe from this group, send email to scala-breeze...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msg/scala-breeze/-/p_nsLyQUBLwJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
Reply all
Reply to author
Forward
0 new messages