GenPauli

GenPauli is a function that produces generalized Pauli matrices (sometimes called Weyl matrices). More specifically, it produces a unitary matrix of the form $X^j Z^k$, where $X$ and $Z$ are the $d \times d$ "shift" and "clock" matrices defined by:
 * $$X =

\begin{bmatrix} 0          & 0 & 0      & \cdots &0 & 1\\ 1          & 0 & 0      & \cdots & 0 & 0\\ 0          & 1 & 0      & \cdots & 0 & 0\\ 0     & 0     & 1 & \cdots & 0 & 0 \\ \vdots     & \vdots     & \vdots & \ddots &\vdots &\vdots \\ 0          & 0     &0   & \cdots    & 1 & 0\\ \end{bmatrix} \quad \text{and} \quad Z = \begin{bmatrix} 1     & 0         & 0 & \cdots & 0\\ 0     & \omega    & 0 & \cdots & 0\\ 0     & 0         &\omega ^2 & \cdots & 0\\ \vdots & \vdots   & \vdots    & \ddots & \vdots\\ 0 & 0 & 0 & \cdots & \omega ^{d-1} \end{bmatrix}, $$ and $\omega = \exp(2\pi i/d)$ is a primitive root of unity.

Syntax

 * P = GenPauli(IND1,IND2,DIM)
 * P = GenPauli(IND1,IND2,DIM,SP)

Argument descriptions

 * IND1: The exponent of $X$, the shift matrix (this was called $j$ above). Should be an integer from 0 to DIM-1, inclusive.
 * IND2: The exponent of $Z$, the clock matrix (this was called $k$ above). Should be an integer from 0 to DIM-1</tt>, inclusive.
 * DIM</tt>: The size of the output matrix (this was called $d$ above).
 * SP</tt> (optional, default 0): A flag (either 1 or 0) indicating that the generalized Pauli matrix produced should or should not be sparse.