Skip to content

Instantly share code, notes, and snippets.

@stormxuwz
Last active August 29, 2015 13:56
Show Gist options
  • Save stormxuwz/9225226 to your computer and use it in GitHub Desktop.
Save stormxuwz/9225226 to your computer and use it in GitHub Desktop.
\usepackage[subsection]{algorithm} % algorithm float, number according to subsection
\usepackage{algpseudocode} % pseudo-code format
\begin{algorithm}[htbp]
\caption{Parallel CUDA algorithm for connect component labelling \#1}
\label{alg:imageLabellingGPU1}
\algblockdefx[kernel]{Kernel}{EndKernel}[2][default value]{{\bf kernel} {\footnotesize \uppercase{#1}(#2)}}{\bf end kernel}
\begin{algorithmic}
%\State Global variable: isChanged=true;
\Function{gpu\_labelling\_1}{}
\While{$isChanged=true$}
\State run kernel ROW on rows
\State run kernel COLUMN on columns
\EndWhile
\EndFunction
\end{algorithmic}
\hrule
\begin{algorithmic}
\Kernel[row]{$\bf x$} \Comment labells each pixel connected in a row with the smallest of their indices
\For{$k=1$ to $n$}
\For{$j=k$ to $n$}
\State $tmp=\sum{i=1}{k}L_{i,j}\times L_{i,k}$
\If{$j==k$}
\State $L_{k,j}=\sqrt{A_{k,j}-tmp}$
\Else
\State $L_{k,j}=(A_{k,j}-tmp)/L_{k,k}$
\EndIf
\EndFor
\EndFor
\EndKernel
\end{algorithmic}
\end{algorithm}
@stormxuwz
Copy link
Author

pseudo code in latex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment