I want to write an algorithm in a table for my paper. I tried to write it, but I want to write ''While'' instead of ''for'' in this algorithm. How can I do it? And I want to put the table everywhere in the text.
\begin{algorithm}
\caption{
OMP Algorithm
}
\label{alg1}
\begin{latin}
\begin{algorithmic}[1]
\REQUIRE Decomposition of signal $x$
\STATE\textbf{Input:} signal $x \in \mathcal{R}^{m}$, Dictionary $\mathcal{G} \in \mathcal{R}^{m \times n}$,$\hat{x}=\emptyset$
\STATE \textbf{Output:} Decomposed signal $\hat{x}_{est}$ after $k$ iteration, Residual $R^{(k)}$
\STATE \textbf{Initialization} $R^{(0)}=x$
\STATE \textbf{for i=1:k do}
\STATE $l=\displaystyle{arg\max_{l=1,\dots ,l} |\langle g_l,R^{(i)} \rangle|}$ \qquad finding the atom in dictionary $\mathcal{G}$ with maximum correlation with residual.
\STATE $R^{(i+1)}=R{(i)}-a_l g_l^{(i)}$
\STATE $\hat{x}=\hat{x}+\langle R^{(i)},g_{l}^{(i)} \rangle g_{l}^{(i)}$
\STATE \textbf{end}
\end{algorithmic}
\end{latin}
\end{algorithm}

