MathGroup Archive 2006

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

Search the Archive

Re: Why Does Repeated Dot Product Take So Long?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg67955] Re: [mg67938] Why Does Repeated Dot Product Take So Long?
  • From: Gregory Lypny <gregory.lypny at videotron.ca>
  • Date: Tue, 18 Jul 2006 05:50:45 -0400 (EDT)
  • References: <200607171051.GAA02347@smc.vnet.net> <44BB93B3.5050508@wolfram.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Thank you for having a look, Carl.  The matrices contain real  
numbers, all less than one, with about nine digits to the right of  
the decimal.  I'll give your approach a try.

Regards,

	Greg

On Mon, Jul 17, 2006, at 9:42 AM, Carl K. Woll wrote:

> Gregory Lypny wrote:
>> Hello Everyone,
>> x and y are both 2000 x 3 matrices.  I wanted to created a 2000 x  
>> 1  vector with each element equal to the dot product of the   
>> corresponding rows of x and y.  So I tried this:
>> Table[x[[i]].y[[i]], {i, 1, 2000}]
>> It took more than two and a half minutes on my iBook G4.  Is that   
>> normal?  I've done seemingly more demanding computations in Do  
>> loops  and Tables that are completed in a split second.  Am I  
>> doing  something wrong with this one?
>> Regards,
>> 	Gregory
>
> When I tried your code with matrices containing machine reals, the  
> timing was practically instantaneous. Perhaps you could tell us  
> what the matrix elements are.
>
> For this particular computation with very large numerical matrices,  
> a faster approach is to rely on the listable attribute of matrices:
>
> Total[Transpose[x y]]
>
> For large matrices such as 200000 x 3 the above method is  
> significantly faster.
>
> Carl Woll
> Wolfram Research


  • Prev by Date: Re: Why Does Repeated Dot Product Take So Long?
  • Next by Date: Re: Filtering same elements from two lists
  • Previous by thread: Re: Why Does Repeated Dot Product Take So Long?
  • Next by thread: Re: Why Does Repeated Dot Product Take So Long?