首页 > 代码库 > Latex 建立带有竖线和编号的算法环境

Latex 建立带有竖线和编号的算法环境

Latex 建立带有竖线和编号的算法环境

技术分享

Latex源码:

\documentclass{article}\usepackage{amssymb}\usepackage{amsmath}\usepackage[linesnumbered, ruled]{algorithm2e}\SetKwRepeat{Do}{do}{while}%\begin{document}\begin{algorithm}[!ht]  \caption{Algorithm for problem \eqref{WWW} }  \SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output} \Input  { data matrix ${\bf X}$, label matrix ${\bf Y}$ and ${\bf W}_0$, $k=0$}  \Output  {${\bf W}^*$}\Repeat{ADMM stopping criterion is satisfied}{ Updating ${\bf W}^k$:\begin{equation*}({\bf X}{\bf X}^{\mathrm T}+\mu{\bf I}){\bf W}={\bf B}^{k-1}\end{equation*}where ${\bf B}^{k-1} ={\bf X}{\bf Y}+\alpha{\bf A}^{k-1}-{\bf \Sigma}^{k-1}+\mu{\bf U}^{k-1}$\;Updating ${\bf U}^k$:\begin{equation*}  {\bf u}^k_i=  \begin{cases}  \frac{\mu\|{\bf n}^{k-1}_i\|_2-\alpha}{\mu\|{\bf n}^{k-1}_i\|_{2}}{\bf n}^{k-1}_i,& ~\mbox{if} ~\alpha<\mu\|{\bf n}^{k-1}_i\|_2 \  \quad 0 & ~\mbox{otherwise}\  \end{cases}  \end{equation*}  Updating ${\bf \Sigma}^{k}$:\begin{equation*}\begin{split}  {\bf \Sigma}^k:=&{\bf \Sigma}^{k-1}+\mu({\bf W}^{k-1}-{\bf U}^{k-1})  \end{split}\end{equation*}\$k=k+1$\;}\end{algorithm}\end{document}

  

Latex 建立带有竖线和编号的算法环境