MathGroup Archive 2008

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

Search the Archive

Fast evaluation of modified dot product


I have (below) a vector x and matrix y and would like to compute z
efficiently:

{n, m, b} = {10000, 100, 10};  (* n >> m > b *)
x = RandomReal[{-1.,1.}, n - b +1]
y = RandomChoice[{-1,1}, {n, m}];

w = Partition[y, b, 1];
z = Dot[x, w];

I have to compute z for many different x with w fixed. For large n, w
becomes prohibitively big.

Doing the below is much slower but doesn't require large memory
allocation:

z2 = Fold[(#1 + x[[#2]] y[[#2;;#2+b-1]]) &, 0., Range[Length[x]] ];

I was wondering if there is a good way to compute z that doesn't
require a lot of memory.

Thanks,
Art.


  • Prev by Date: Mathematica hangs...
  • Next by Date: Re: Unwanted lined in PDF-exported Graphics3D
  • Previous by thread: Re: Mathematica hangs...
  • Next by thread: Re: Fast evaluation of modified dot product