我在R中实现Power迭代时遇到了一些麻烦。 以下是我得到的,但它现在已经不能正常工作,虽然我刚刚在几分钟前执行它并且它工作正常。 任何帮助将不胜感激。
A = matrix(c(0,0.5,0,0,0,0.5,0,0,1,0,0,0,0.4,0,0,0.6,0,0,0,0,0.8,0,0.2,0,0,0,0,1.0,0,0,0,0,0.3,0,0.7,0),
nrow = 6,
ncol = 6,
byrow = TRUE)
B = matrix(c(0,0,1,0,0,0),
nrow = 1,
ncol = 6)
eps = 1
steps = 1
power_test <- function(A,B,eps,stop=100)
{
repeat
{
B_new = (B %*% A)
print (steps)
if (norm(abs(B_new) - (B)) <= eps) break
print (B_new)
B = B_new
steps = steps + 1
if (steps == stop) break
}
}