我正在尝试在 sage 中编写 Graham-Schmidt 过程,但无法弄清楚如何循环遍历数组的行。
def graham_schmidt(W):
a=0
U=W
for i in W.dims()[0]:# this is the not working part
print w
a=a+1
for j in xrange(0,-2):
a=a+1
U[i]=U[i]-(transpose(U[j])*w)/(transpose(U[j])*U[j])*U[j]
return a;