1
\begin{algorithm}
\caption{Sinkhorn's algorithm}
\begin{algorithmic}
\WHILE{ $\| B(u_{k}, v_{k})1 - \mu \| + \| B(u_{k}, v_{k})^{T} 1 - \nu \| \ge \epsilon'$ }
    \IF {$k \text{ mod } 2 = 0$}
        \STATE $u_{k+1} = u_{k} + ln \left( \frac{\mu}{B(u_{k},v_{k})\mathrm{1}} \right)$
        \STATE $v_{k+1} = v_{k}$
    \ELSE
        \STATE $v_{k+1} = v_{k} + ln \left( \frac{\nu}{B(u_{k},v_{k})^{T} \mathrm{1}} \right) $
        \STATE $u_{k+1} = u_{k}$
    \ENDIF
        \STATE $k = k+1$
\end{algorithmic}
\end{algorithm}

This code doesn't work do you know why ?

Thanks and regards.

1 Answer 1

1

\ENDWHILE should be used to indicate the end of the loop.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{algorithm}
\usepackage{algorithmic}
\usepackage{amsmath}

\begin{document}
\begin{algorithm}
   \caption{Sinkhorn's algorithm}
   \begin{algorithmic}
   \WHILE{ $\| B(u_{k}, v_{k})1 - \mu \| + \| B(u_{k}, v_{k})^{T} 1 - \nu \| \ge \epsilon'$ }
       \IF {$k \text{ mod } 2 = 0$}
           \STATE $u_{k+1} = u_{k} + ln \left( \frac{\mu}{B(u_{k},v_{k})\mathrm{1}} \right)$
           \STATE $v_{k+1} = v_{k}$
       \ELSE
           \STATE $v_{k+1} = v_{k} + ln \left( \frac{\nu}{B(u_{k},v_{k})^{T} \mathrm{1}} \right) $
           \STATE $u_{k+1} = u_{k}$
       \ENDIF
           \STATE $k = k+1$
   \ENDWHILE
   \end{algorithmic}
   \end{algorithm}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.