New in Wolfram Mathematica 6: Extended Array Operations  previous | next 
Use Concise Notation for Linear Algebra
Mathematica 6 further enhances Mathematica's ability to represent operations and algorithms on arrays in a concise and readable form.
In[1]:=

Click for copyable input
LUDecompose[A_] :=

  Module[{m, n, L, U}, {m, n} = Dimensions[A];

   L = IdentityMatrix[n]; 

   U = A;

   Do[

    L[[k ;; n, k]] = U[[k ;; n, k]]/U[[k, k]];

    U[[(k + 1) ;; n, k ;; n]] = 

     U[[(k + 1) ;; n, k ;; n]] - 

      L[[(k + 1) ;; n, {k}]].U[[{k}, k ;; n]], {k, 1, n - 1}];

   {L, U}

   ];