【发布时间】:2011-12-12 14:04:25
【问题描述】:
我正在尝试在 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;
【问题讨论】:
-
W的类型是什么?你试过这个吗:for i in W.dims()[0]?变量w在哪里取值?