MathGroup Archive 2008

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

Search the Archive

Dot Product of Vectors

  • To: mathgroup at
  • Subject: [mg89044] Dot Product of Vectors
  • From: Gregory Lypny <gregory.lypny at>
  • Date: Sat, 24 May 2008 03:55:41 -0400 (EDT)

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]]}, ...  

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.



  • Prev by Date: Export graphics to ascii file
  • Next by Date: NIntegrate in NDSolve?
  • Previous by thread: Re: Export graphics to ascii file
  • Next by thread: Re: Dot Product of Vectors