I am using TDMA in Python using NumPy. The tridiagonal matrix is stored in three arrays:
a = array([...]) b = array([...]) c = array([...])
I would like to efficiently calculate alpha coefficients. The algorithm is as follows:
However, this is inefficient due to the Python for loop. I want me to want something like this approach:
In this latter case, the result is incorrect, because NumPy stores the right side of the last expression in a temporary array and then assigns links to its elements on alpha[1:] . Therefore, a[1:] * alpha[:-1] is just an array of zeros.
Can I tell NumPy to use the alpha values calculated in the previous steps inside my inner loop?
Thanks.
source share