Speed of repeated matrix calculation

• To: mathgroup at smc.vnet.net
• Subject: [mg49717] Speed of repeated matrix calculation
• From: Gregory Lypny <gregory.lypny at videotron.ca>
• Date: Thu, 29 Jul 2004 07:43:39 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Hello everyone,

Just curious to know whether I'm doing this repeated matrix calculation
efficiently by using the Table command.

I've got matrices x and y, which are both 7000x3, and a matrix V which
is 3x3.

If I create a 7000x1 vector, q, whose elements are equal to each of the
row quadratic forms x.V.x, I can do it by creating a table.

q = Table[{x[[i, All]].V.x[[i, All]]}, {i, 1, 7000}];

The calculation is done in a split second on a G4 iBook.

However, if I use Table to create a 7000x1 vector, d, of the dot
products of the rows of x and y, the calculation takes more than two
minutes!

d = Table[{x[[i, All]].y[[i, All]]}, {i, 1, 7000}];

Why the big difference in time?  Is there a better way?

Greg

```

• Prev by Date: Re: about principal components analysis (PCA)
• Next by Date: output #1
• Previous by thread: Re: Wolfram Technology Conference 2004: Call for Submissions
• Next by thread: Re: Speed of repeated matrix calculation