Routine Name: ForwardSub
Author: David Merkley
Language: Python
Description/Purpose: Computes solution to lower triangular matrix.
Input:
Required:
A - a matrix
b - vector
Optional:
diagIsOne - Whether to treat diagonal elements as 1
Output: Solution to Ax = b
Implementation/Code:
def forwardSub(A, b, diagonalOne=False):
n = len(b)
ans = [x for x in b]
for i in range(n):
for j in range(i):
ans[i] -= A[i][j] * ans[j]
if not diagonalOne:
ans[i] /= A[i][i]
return ans