I want to write an algorithm, and I have the code segment shown below, but it provides multiple errors, such as input and output commands are not recognized and I get missing \endcsname
error. Additionally, the line numbers are not inserted, any idea how to fix all the errors and also insert the line numbers?
\documentclass[a4paper]{paper}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{algorithm}
\usepackage{algpseudocode}
\begin{document}
\begin{algorithm}[H]
\Input{A vector \textbf{a}}
\Output{Bit reversed vector}
\Function{NTT}{$\textbf{a}$}
\State $m \gets 1$
\State $k \gets n / 2$
\While{$m < n$}
\For {$i = 0$ \To $m - 1$}
\State $jFirst \gets 2 \cdot i \cdot k$
\State $jLast \gets jFirst + k - 1$
\State $S \gets \psi_{rev}[m + i]$
\For {$j = jFirst$ \To $jLast$}
\State $l \gets j + k$
\State $t \gets \textbf{a}[j]$
\State $u \gets \textbf{a}[l] \cdot S$
\State $\textbf{a}[j] \gets t + u \mod q$
\State $\textbf{a}[l] \gets t - u \mod q$
\EndFor
\EndFor
\State $m \gets m \cdot 2$
\State $k \gets n / 2$
\EndWhile
\State \Return $\textbf{a}$
\EndFunction
\caption{Cooley-Tukey (CT) Forward NTT}
\label{CTAlgo}
\end{algorithm}
\end{document}
\documentclass[a4paper]{paper}
actually. I have no idea where it is defined. Just using it as I'm writing paper, and usingxelatex
.