Wednesday, January 19, 2011

LU Decomposition Part 2

This method uses a single array to represent an nxn matrix instead of a matrix. This should make the code more robust since C naturally reads arrays across columns. For example:
Code 1: 
for j 1 to 10
   for i 1 to 10
      a[i][j] += 2;
   end
end

Code 2: 
for j 1 to 10
   for i 1 to 10
      a[j][i] += 2;
   end
end

Code 1 wont be as fast as code 2 but in fortran the opposite is true. 
Here's a link to my code

1 comment:

  1. Wow Paht I think you do more coding than I do!

    Heres a decent explanation of why that code will run faster. Compiler optimizations are a fun read if you're ever bored!

    http://en.wikipedia.org/wiki/Loop_interchange

    ReplyDelete