LaTeX 写算法伪码
2015-11-26 14:33
330 查看
本系列文章由 @YhL_Leo 出品,转载请注明出处。
文章链接: /article/3664579.html
LaTeX写算法伪码,需要包含包:
有些用例里还会加上:
可以遇到具体情形,再添加~
以常用的Levenberg-Marquardt(L-M)优化方法为例,给出一种方法:
编译结果为:
文章链接: /article/3664579.html
LaTeX写算法伪码,需要包含包:
[code]\usepackage{algorithm} \usepackage{algpseudocode}
有些用例里还会加上:
[code]\usepackage{caption} \usepackage{algorithmicx}
可以遇到具体情形,再添加~
以常用的Levenberg-Marquardt(L-M)优化方法为例,给出一种方法:
[code]\documentclass{article} \usepackage{algorithm} \usepackage{algpseudocode} %\usepackage{caption} %\usepackage{algorithmicx} \begin{document} \begin{algorithm} \caption{\textbf{Levenberg-Marquardt Method}} \label{Alg:scanMatching} \begin{algorithmic}[1] \Require $k:= 0$ ; $\nu:=2$; $\mathbf{x}:=\mathbf{x}_0 $; $\mathbf{A}:= \mathbf{J}(\mathbf{x})^T\mathbf{J}(\mathbf{x})$; $\mathbf{g}:=\mathbf{J}(\mathbf{x})^T\mathbf{f}(\mathbf{x})$ \Ensure $found := (\| \mathbf{g}\|_\infty \leq \varepsilon_1)$; $\mu := \tau\cdot max\{ a_{ii} \}$ \State \textbf{while} (\textbf{not} $found $) $\textbf{and}$ $k \leq k_{max}$ $\textbf{do}$ \State \ \ \ \ $k := k+1$; Solve $(\mathbf{A}+\mu\mathbf{I})\mathbf{h}_{lm}) = -\mathbf{g}$ \State \ \ \ \ $\textbf{if} \ \ \|\mathbf{h}_{lm} \| \leq \varepsilon_2 (\|\mathbf{x} + \varepsilon_2)$ \State \ \ \ \ \ \ \ \ $found:= \textbf{true}$ \State \ \ \ \ $\textbf{else}$ \State \ \ \ \ \ \ \ \ $\mathbf{x}_{new} := \mathbf{x} + \mathbf{h}_{lm}$ \State \ \ \ \ \ \ \ \ $\varrho:= (F(\mathbf{x}) - F(\mathbf{x}_{new}))/(L(\mathbf{0}) - L(\mathbf{h}_{lm}))$ \State \ \ \ \ \ \ \ \ $\textbf{if} \ \ \varrho > 0$ \State \ \ \ \ \ \ \ \ \ \ \ \ $\mathbf{x}:= \mathbf{x}_{new}$ \State \ \ \ \ \ \ \ \ \ \ \ \ $\mathbf{A} := \mathbf{J}(\mathbf{x})^T\mathbf{J}(\mathbf{x}); \ \ \mathbf{g}:=\mathbf{J}(\mathbf{x})^T\mathbf{f}(\mathbf{x})$ \State \ \ \ \ \ \ \ \ \ \ \ \ $found := (\|\mathbf{g}\|_{\infty} \leq \varepsilon_1)$ \State \ \ \ \ \ \ \ \ \ \ \ \ $\mu := \mu \cdot max\{ \frac{1}{3}, 1-(2\varrho-1)^3\}; \ \ \nu:=2$ \State \ \ \ \ \ \ \ \ $\textbf{else}$ \State \ \ \ \ \ \ \ \ \ \ \ \ $\mu := \mu \cdot \nu; \ \ \nu := 2\nu$ \State \ \ \ \ \ \ \ \ $\textbf{end if}$ \State \ \ \ \ $\textbf{end if}$ \State \textbf{end while} \end{algorithmic} \end{algorithm} \end{document}
编译结果为:
相关文章推荐
- 将Java Project打包成jar,并生成exe
- Spark GraphX 2
- 使用图形化界面管理 Exchange Server 2016
- Windows平台安装最新OpenCV-2.4.9,利用Eclipse、MinGW构建C++调用OpenCV开发环境
- Beego模板 循环和判断几个例子
- 程序员技术练级攻略
- 【笔记】CSS3 transition属性
- leetcocd_Bulls and Cows
- 【leetcode】【74】Search a 2D Matrix
- 关于BaseAdapter的两个优化方案
- imfilter()用法
- Spark GraphX
- bootstrap 超大屏幕(Jumbotron)
- Delphi Help
- Android4.0的Alertdialog对话框,设置点击其他位置不消失
- Django实现自定义的manage名利
- 使用svn diff的-r参数的来比较任意两个版本的差异
- MongoDB数据库和集合的状态信息
- Spark SQL - DataFrame
- Spark Streaming - DStream