In [16]: def trigonalise(A, Y):
...: n = A.shape[0] ...: for i in range(n-1): ...: for k in range(i+1,n): ...: c = A[k,i]/A[i,i] ...: transvection(A,Y,k,i,c) ...:
In [17]: A = matrix([ [1, 2, 2], [1, 3, -2], [3, 5, 8] ])
In [18]: Y=matrix([ [2], [-1], [8] ])
In [19]: trigonalise(A,Y)
In [20]: A Out[20]:
matrix([ [ 1, 2, 2],
[ 0, 1, -4], [ 0, 0, -2] ])