From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Order of operations in a vectorized function
Date: Tue, 3 Aug 2010 19:58:04 +0000 (UTC)
Organization: Technion
Lines: 19
Message-ID: <i39scc$h7k$>
References: <i39kf9$bt5$> <i39pvi$7g8$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1280865484 17652 (3 Aug 2010 19:58:04 GMT)
NNTP-Posting-Date: Tue, 3 Aug 2010 19:58:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2119481
Xref: comp.soft-sys.matlab:658723

"Roger Stafford" <> wrote in message <i39pvi$7g8$>...
> - - - - - - - - - - -
>   In the "vectorized" form you have written, it doesn't look like Gauss-Seidel iteration to me.  For each element of grid, matlab will use the old values in grid for all its computations.  It accomplishes this by temporarily storing two copies of the grid matrix in separate buffers, the old values and the new values.  The computation on the right takes from the old value matrix and puts the results into the new value matrix.  Imagine that you wrote "temp_grid" on the left side and after the computation was finished for all elements you then wrote grid = temp_grid to copy the new results back into grid.  That would be equivalent to the vectorized action.
>   Note that this is general different from the results you would get if you put it in nested for-loops like this:
>  for i1 = 1:n
>   for i2 = 1:n
>    grid(i1,i2) = the above expression in grid(i1,i2) ;
>   end
>  end
>   A lot of beginners in matlab make the mistake of not distinguishing between these two different ways of proceeding.
> Roger Stafford

Roger, thank you. 
So, it seems there's no way of avoiding using loops in this case? "Vectorization" is only good when all the data are on the same 'time' level in the iteration, and if I specifically want to use the updated values, I need to loop? 
In general though, using .* and so on is substantially faster then using a loop for the same calculation?