我正在尝试使用while循环编写程序:
(更新:解决方案已建立!!!!!!!因为在下面必须提供对/错语句),if函数应该是明确的理由。
while ((it_count) < it_max && it_change > tol)
{
wj <- Kc%*%yj #LS regression for wj
vj <- wj/as.vector(t(wj)%*%wj) #normalization of wj
cj <- t(yj)%*%vj #LS regression for cj
old_yj <- yj
yj <- yj%*%cj
yj <- yj/as.vector(t(yj)%*%yj) #normalize new yj
diff_y <- yj - old_yj
it_change <- diff_y/as.vector(t(diff_y)%*%diff_y)
it_count <- inc(it_count)
}
if (a == j ) break
else
{warning(paste("failed to converge for component", a, "steps"))}