I am trying to write a program using a while loop:
(UPDATE: solution founded!! since there must be a true/false statement provided in the below part), The if function should be clear justification.
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"))}