Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Dot Product of Vectors

  • To: mathgroup at smc.vnet.net
  • Subject: [mg89080] Re: [mg89044] Dot Product of Vectors
  • From: "Adriano Pascoletti" <adriano.pascoletti at gmail.com>
  • Date: Sun, 25 May 2008 03:22:12 -0400 (EDT)
  • References: <200805240755.DAA20910@smc.vnet.net>

Gregory,this is a solution based on the listability of Times:

Total[X*Y, {2}]  gives a list of length n.


Use List /@ Total[X*Y, {2}]  to get an n x 1 array.


Adriano Pascoletti



On Sat, May 24, 2008 at 9:55 AM, Gregory Lypny <gregory.lypny at videotron.ca>
wrote:

> Hello everyone,
>
> I've got two n x k matrices called X and Y.  I'd like to compute an n
> x 1 vector whose elements are the dot products of corresponding rows
> of X and Y, that is,
>
>        {{X[[1]].Y[[1]]}, {X[[2]].Y[[2]]}, {X[[3]].Y[[3]]}, ...
> {X[[n]].Y[[n]]}.
>
> I found that this can be done using MapThread as
>
>        MapThread[Dot, { X, Y}],
>
> which is straightforward.  I'm curious, given that there a zillion
> ways to do any given calculation in Mathematica, if anyone knows of
> another way that is as compact.
>
> Regards,
>
>        Gregory
>
>
>
>



  • Prev by Date: Re: message: can' find notebook, but it does...
  • Next by Date: Re: How export the 0<x<10^-6 numbers to a text file correctly
  • Previous by thread: Re: Dot Product of Vectors
  • Next by thread: Re: Dot Product of Vectors