Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm really trying to wrap my head around vectorization but I can't seem to understand it. I don't know if I don't understand how to vectorize, or if I don't understand the array notation that's being used. An example of a loop I'm working on with school is below:

for (M=0; M< number_of_iterations/2; M++){
   for (i=2; i<n-1; i++)  
      for (j=1; j<n-1; j++)  
          y[i][j]= (x[i-1][j]+x[i][j-1]+x[i+1][j]+x[i][j+1]+x[i-2][j])/5.;

I'm not sure I quite understand the whole thing on dependencies - Is there a way to vectorize this using array notation as is, or do I need to adjust it somehow to account for dependencies throughout?

share|cite|improve this question
Do two iterations of the innermost loop interfere in any way? – Raphael Feb 14 '13 at 6:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.