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.