未定义控制序列。\输入

未定义控制序列。\输入

代码:

\documentclass{article}
\usepackage{algorithm}
\usepackage{algorithmic} 

\begin{document}

\begin{algorithm}[t]
    \caption{Dolphinn: Preprocessing (data structure)}
    \label{DolphinnPrep}
    \begin{algorithmic}
    \INPUT{Metric $(\MM, d_{\MM})$, radius $r>0$, approximation factor $c>1$, LSH family $F=F(c,r)$, data set $P \subset \MM$, parameter $d'$.}
    \STATE Initialize empty hashtable $T$.
    \FOR{$i = 1$ to $d'$}
        \STATE Sample $h_i \in F$ u.a.r.
        \FOR{each $x \in h_i(P)$}
            \STATE{Flip a fair coin and assign the result to $f_i(x)$.}
        \ENDFOR
    \ENDFOR
    \STATE{For all $p \in P$, $f(p)=(f_1(h_1(p)), \ldots, f_{d'}(h_{d'}(p)))$.}
    \STATE{For all $p \in P$, add $p$ to the bucket of $T$ with key $f(p)$.}
\end{algorithmic}
\end{algorithm}

\end{document}

错误:

./sample.tex:11: Undefined control sequence.
<recently read> \INPUT 

l.11     \INPUT
               {Metric $(\MM, d_{\MM})$, radius $r>0$, approximation factor ...

? 

如何解决这个问题?

答案1

你可能想要\INPUTS

\documentclass{article}
\usepackage{algorithm}
\usepackage{algorithmic}

\newcommand{\MM}{MM}% ???

\begin{document}

\begin{algorithm}[t]
\caption{Dolphinn: Preprocessing (data structure)}
\label{DolphinnPrep}

\begin{algorithmic}
\INPUTS
  \STATE Metric $(\MM, d_{\MM})$, radius $r>0$, approximation factor $c>1$,
         LSH family $F=F(c,r)$, data set $P \subset \MM$, parameter $d'$.
\ENDINPUTS
\STATE Initialize empty hashtable $T$.
\FOR{$i = 1$ to $d'$}
  \STATE Sample $h_i \in F$ u.a.r.
  \FOR{each $x \in h_i(P)$}
    \STATE Flip a fair coin and assign the result to $f_i(x)$.
  \ENDFOR
\ENDFOR
\STATE For all $p \in P$, $f(p)=(f_1(h_1(p)), \ldots, f_{d'}(h_{d'}(p)))$.
\STATE For all $p \in P$, add $p$ to the bucket of $T$ with key $f(p)$.
\end{algorithmic}

\end{algorithm}

\end{document}

在此处输入图片描述

相关内容