1

I want to write an algorithm such that what I have attached, I am somehow elementary in writing algorithms with latex. I do not want the exact answer, only a tip or an example similar to what I have attached.

algorithm written in table

2

You can do any one of the following:

  1. Place the algorithms each in its own minipage environment:

    \begin{minipage}{.5\textwidth}
      \begin{algorithm}[H]% Left algorithm
        ...
      \end{algorithm}
    \end{minipage}%
    \begin{minipage}{.5\textwidth}
      \begin{algorithm}[H]% Right algorithm
        ...
      \end{algorithm}
    \end{minipage}%
    
  2. Place the algorithms inside the columns of a larger table.

I've chosen (2) above to produce this (with the help of booktabs:

enter image description here

Symbols and other notation may have to change. It's just to give you an idea of what could be done.


Spoiler alert:

\documentclass{article}

\usepackage[margin=1in]{geometry}% Just for this example

\usepackage[lined]{algorithm2e}
\usepackage{amsmath,tabularx,booktabs}

\DontPrintSemicolon

\newcommand{\vectnotation}[1]{\textbf{\textit{#1}}}
\DeclareMathOperator{\Vect}{vec}
\newcommand{\vect}[1]{\Vect(#1)}
\newcommand{\assign}{\leftarrow}
\newcommand{\To}{\textup{\textbf{to}}}

\begin{document}

\noindent
\begin{tabularx}{\textwidth}{XX}
  \toprule
  \multicolumn{2}{p{\dimexpr\textwidth-2\tabcolsep}}{\refstepcounter{algocf}\AlCapSty{\AlCapFnt\algorithmcfname\nobreakspace\thealgocf:}
    Efficient application of the wavelet dictionary by the Horner's rule.} \\
  \midrule
  \begin{algorithm}[H]
    Forward operator $(y = \vectnotation{D} \vect{\vectnotation{X}})$\;
    $\vectnotation{R} \assign \mathbf{1} \otimes \vectnotation{X}(N,:)$\;
    \For{$n \assign 2$ \To{} $N$}{
      $\vectnotation{P} \assign \mathbf{1} \otimes \vectnotation{X}(N-n+1,:)$\;
      $\vectnotation{R} \assign \vectnotation{R} \circ \vectnotation{Z} + \vectnotation{P}$\;
    }
    $\vectnotation{y} \assign \vectnotation{F}^{-1}(\hat{\vectnotation{w}} \circ \vectnotation{R}\mathbf{1})$\;
  \end{algorithm} &
  \begin{algorithm}[H]
    Adjunct operator $(\vect{\tilde{\vectnotation{X}}} = \vectnotation{D}^{T} \vectnotation{y})$\;
    $\mathbf{\rho} \assign \vectnotation{y}^{T} \vectnotation{W}\vectnotation{F}$\;
    $\vectnotation{L} \assign N \times M$ all-ones matrix\;
    \For{$n \assign 2$ \To{} $N$}{
      $\tilde{\vectnotation{X}}(n,:) \assign \mathbf{\rho} \vectnotation{L}$\;
      $\vectnotation{L} \assign \vectnotation{Z}^{\star} \circ \vectnotation{L}$\;
    }
  \end{algorithm} \\[-\normalbaselineskip]
  \bottomrule
\end{tabularx}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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