% 伪代码 start
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{amsmath}
\renewcommand{\algorithmicrequire}{\textbf{Input:}} % Use Input in the format of Algorithm
\renewcommand{\algorithmicensure}{\textbf{Output:}} % Use Output in the format of Algorithm
% 伪代码 end

位置

latex 伪代码_伪代码

 

 

\begin{algorithm}[h]  
\caption{Conjugate Gradient Algorithm with Dynamic Step-Size Control}
\label{alg::conjugateGradient}
\begin{algorithmic}[1]
\Require
$f(x)$: objective funtion;
$x_0$: initial solution;
$s$: step size;
\Ensure
optimal $x^{*}$
\State initial $g_0=0$ and $d_0=0$;
\Repeat
\State compute gradient directions $g_k=\bigtriangledown f(x_k)$;
\State compute Polak-Ribiere parameter $\beta_k=\frac{g_k^{T}(g_k-g_{k-1})}{\parallel g_{k-1} \parallel^{2}}$;
\State compute the conjugate directions $d_k=-g_k+\beta_k d_{k-1}$;
\State compute the step size $\alpha_k=s/\parallel d_k \parallel_{2}$;
\Until{($f(x_k)>f(x_{k-1})$)}
\end{algorithmic}
\end{algorithm}

latex 伪代码_csdn博客_02

 ​