GenPauli

 Other toolboxes required GenPauli Produces a generalized Pauli operator (sometimes called a Weyl operator) none GellMannGenGellMannPauli Special states, vectors, and operators

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, inclusive.
• DIM: The size of the output matrix (this was called $d$ above).
• SP (optional, default 0): A flag (either 1 or 0) indicating that the generalized Pauli matrix produced should or should not be sparse.

Examples

Gives the Pauli operators when DIM = 2

>> GenPauli(1,0,2) % Pauli X operator

ans =

0     1
1     0

>> GenPauli(0,1,2) % Pauli Z operator

ans =

1.0000 + 0.0000i   0.0000 + 0.0000i
0.0000 + 0.0000i  -1.0000 + 0.0000i

>> GenPauli(1,1,2) % Pauli Y operator (up to global phase)

ans =

0.0000 + 0.0000i  -1.0000 + 0.0000i
1.0000 + 0.0000i   0.0000 + 0.0000i

>> GenPauli(0,0,2) % identity operator

ans =

1     0
0     1

In Higher Dimensions

>> GenPauli(1,0,3) % generalized Pauli X

ans =

0     0     1
1     0     0
0     1     0

>> GenPauli(0,1,3) % generalized Pauli Z

ans =

1.0000 + 0.0000i   0.0000 + 0.0000i   0.0000 + 0.0000i
0.0000 + 0.0000i  -0.5000 + 0.8660i   0.0000 + 0.0000i
0.0000 + 0.0000i   0.0000 + 0.0000i  -0.5000 - 0.8660i

>> GenPauli(2,3,4,1) % sparse 4-dimensional generalized Pauli

ans =

(3,1)      1.0000 + 0.0000i
(4,2)     -0.0000 - 1.0000i
(1,3)     -1.0000 + 0.0000i
(2,4)      0.0000 + 1.0000i

Source code

Click on "expand" to the right to view the MATLAB source code for this function.

1. %%  GENPAULI    Produces a generalized Pauli operator
2. %   This function has three required arguments:
3. %     IND1 (a nonnegative integer from 0 to DIM-1 inclusive)
4. %     IND2 (a nonnegative integer from 0 to DIM-1 inclusive)
5. %     DIM (a positive integer indicating the dimension)
6. %
7. %   P = GenPauli(IND1,IND2,DIM) is a DIM-by-DIM unitary operator. More
8. %   specifically, it is the operator X^IND1*Z^IND2, where X and Z are the
9. %   "shift" and "clock" operators that naturally generalize the Pauli X and
10. %   Z operators. These matrices span the entire space of DIM-by-DIM
11. %   matrices as IND1 and IND2 range from 0 to DIM-1, inclusive.
12. %
13. %   This function has one optional argument:
14. %     SP (default 0)
15. %
16. %   P = GenPauli(IND1,IND2,DIM,SP) is as above, with sparsity of the output
17. %   determined by the value of SP. If SP = 0 then the output will be full,
18. %   if SP = 1 then the output will be sparse.
19. %
20. %   URL: http://www.qetlab.com/GenPauli
21. 
22. %   requires: opt_args.m
23. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
24. %   package: QETLAB
25. %   last updated: December 18, 2013
26. 
27. function p = GenPauli(ind1,ind2,dim,varargin)
28. 
29. % set optional argument defaults: sp=0
30. [sp] = opt_args({ 0 },varargin{:});
31. 
32. w = exp(2i*pi/dim); % primitive root of unity
33. X = circshift(speye(dim),1); % shift matrix
34. Z = spdiags((w.^(0:dim-1)).',0,dim,dim); % clock matrix
35. 
36. p = X^ind1*Z^ind2;
37. 
38. if(~sp)
39.     p = full(p);
40. end