@@ -31,3 +31,65 @@ function nlevelstate(::Type{T}, b::NLevelBasis, n::Integer) where T
3131 basisstate (T, b, n)
3232end
3333nlevelstate (b:: NLevelBasis , n:: Integer ) = nlevelstate (ComplexF64, b, n)
34+
35+ """
36+ paulix([T=ComplexF64,] b::NLevelBasis, pow=1)
37+
38+ Generalized Pauli ``X`` operator for the given `N` level system. This is also
39+ called the shift matrix, and generalizes the qubit pauli matrices to qudits,
40+ while preserving the operators being unitary. A different generalization is
41+ given by the angular momentum operators which preserves the operators being
42+ Hermitian and is implemented for the `SpinBasis` (see [`sigmax`](@ref)).
43+
44+ Powers of `paulix` together with [`pauliz`](@ref) form a complete, orthornormal
45+ (under Hilbert–Schmidt norm) operator basis.
46+
47+ Returns `X^pow`.
48+ """
49+ function paulix (:: Type{T} , b:: NLevelBasis , pow= 1 ) where T
50+ N = length (b)
51+ SparseOperator (b, spdiagm (pow => fill (one (T), N- pow),
52+ pow- N => fill (one (T), pow)))
53+ end
54+ paulix (b:: NLevelBasis , pow= 1 ) = paulix (ComplexF64, b, pow)
55+
56+ """
57+ pauliz([T=ComplexF64,] b::NLevelBasis, pow=1)
58+
59+ Generalized Pauli ``Z`` operator for the given `N` level system. This is also
60+ called the clock matrix, and generalizes the qubit pauli matrices to qudits,
61+ while preserving the operators being unitary. A different generalization is
62+ given by the angular momentum operators which preserves the operators being
63+ Hermitian and is implemented for the `SpinBasis` (see [`sigmaz`](@ref)).
64+
65+ Powers of `pauliz` together with [`paulix`](@ref) form a complete, orthornormal
66+ (under Hilbert–Schmidt norm) operator basis.
67+
68+ Returns `Z^pow`.
69+ """
70+ function pauliz (:: Type{T} , b:: NLevelBasis , pow= 1 ) where T
71+ N = length (b)
72+ ω = exp (2 π* 1im * pow/ N)
73+ SparseOperator (b, spdiagm (0 => T[ω^ n for n= 1 : N]))
74+ end
75+ pauliz (b:: NLevelBasis , pow= 1 ) = pauliz (ComplexF64, b, pow)
76+
77+ """
78+ pauliy([T=ComplexF64,] b::NLevelBasis)
79+
80+ Generalized Pauli ``Y`` operator for the given `N` level system.
81+
82+ Returns `Y^pow = ω^pow X^pow Z^pow` where `ω = ω = exp(2π*1im*pow/N)` and
83+ `N = length(b)` when odd or `N = 2*length(b)` when even. This is due to the
84+ order of the generalized Pauli group in even versus odd dimensions.
85+
86+ See [`paulix`](@ref) and [`pauliz`](@ref) for more details.
87+ """
88+ function pauliy (:: Type{T} , b:: NLevelBasis , pow= 1 ) where T
89+ N = length (b)
90+ N = N% 2 == 0 ? 2 N : N
91+ ω = exp (2 π* 1im * pow/ N)
92+ exp (2 π* 1im * pow/ N)* paulix (T,b,pow)* pauliz (T,b,pow)
93+ end
94+
95+ pauliy (b:: NLevelBasis , pow= 1 ) = pauliy (ComplexF64,b)
0 commit comments