0

I'm creating a class to represent tridiagonal matrices. These are square matrices which have a set of non-zero values on the diagonal, and non-zero values on the upper and lower diagonals and then zeros everywhere else.

To store them, I'm using three 1D arrays: one for each diagonal.

Here's an example:

d_0   u_0    0     0
l_0   d_1   u_1    0
 0    l_1   d_2   u_2
 0     0    l_2   d_3

So there's one array for the a_i, one for the u_i and one for the l_i. The zeroes aren't stored.

I require an algorithm to perform LU decomposition. LU decomposition would usually yield the following two matrices:

 1     0     0    0
a_0    1     0    0
 0    a_1    1    0
 0     0    a_2   1 


b_0   c_0    0     0
 0    b_1   c_1    0
 0     0    b_2   c_2
 0     0     0    b_3 

However, the 1's are useless as with the zeroes, they just waste space so I require the algorithm return the following tridiagonal matrix to act as the LU decomposition:

b_0   c_0    0     0
a_0   b_1   c_1    0
0     a_1   b_2   c_2
0      0    a_2   b_3 

I've managed to obtain the following equations:

c_i = u_i    for all i

b_0=d_0

l_i = a_i * b_i    for all i

d_(i+1) = a_i * c_i + b(i+1)    for i>=1

But I'm not sure how to find a general formula for all of the a_i, b_i and c_i which is what I need.

Does anyone know of a nice, easy to program algorithm to do this for me. I'm not looking for anything efficient, just the easiest one to program really.

Thanks very much in advance.

Jarred Morris
  • 53
  • 1
  • 1
  • 4

1 Answers1

0

Is this a homework assignment?

Why re-invent the wheel? Use this link on how to do LU decomposition with C#. Sorry you have to translate to Java

http://msdn.microsoft.com/en-us/magazine/jj863137.aspx

static double[][] MatrixDecompose(double[][] matrix,
  out int[] perm, out int toggle) {
  ...
}
John Alexiou
  • 28,472
  • 11
  • 77
  • 133
  • The problem with that method is that it seems to assume I'm storing the data in my matrix as a 2D array when in fact I'm storing it in three 1D arrays. If I were to use it then I'd have to mess around with changing the structure of the matrix which kind of defeats the point of storing things as I currently do. I have a class for ordinary matrices (non-tridiagonal) where in fact I do use a method fairly similar to this one because there I use a 2D array. – Jarred Morris Apr 01 '13 at 19:47
  • So your problem is not LU decomposition specific, but storage related. An there is no way to convert an element `lu[i][j]` to your storage scheme? – John Alexiou Apr 01 '13 at 21:03