GellMann

 Other toolboxes required GellMann Produces a Gell-Mann operator none GenGellMannGenPauliPauli Special states, vectors, and operators

GellMann is a function that produces the 3-by-3 Gell-Mann matrices, as defined here:

 $$g_0 = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}$$ $$g_1 = \begin{bmatrix} 0 & 1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix}$$ $$g_2 = \begin{bmatrix} 0 & -i & 0 \\ i & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix}$$ $$g_3 = \begin{bmatrix} 1 & 0 & 0 \\ 0 & -1 & 0 \\ 0 & 0 & 0 \end{bmatrix}$$ $$g_4 = \begin{bmatrix} 0 & 0 & 1 \\ 0 & 0 & 0 \\ 1 & 0 & 0 \end{bmatrix}$$ $$g_5 = \begin{bmatrix} 0 & 0 & -i \\ 0 & 0 & 0 \\ i & 0 & 0 \end{bmatrix}$$ $$g_6 = \begin{bmatrix} 0 & 0 & 0 \\ 0 & 0 & 1 \\ 0 & 1 & 0 \end{bmatrix}$$ $$g_7 = \begin{bmatrix} 0 & 0 & 0 \\ 0 & 0 & -i \\ 0 & i & 0 \end{bmatrix}$$ $$g_8 = \frac{1}{\sqrt{3}} \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & -2 \end{bmatrix}$$

Syntax

• G = GellMann(IND)
• G = GellMann(IND,SP)

Argument descriptions

• IND: An index indicating which Gell-Mann operator you would like to be generated. Should be an integer between 0 and 8, inclusive.
• SP (optional, default 0): A flag (either 1 or 0) indicating that the Gell-Mann operator produced should or should not be sparse.

Examples

>> GellMann(1)

ans =

0     1     0
1     0     0
0     0     0

>> GellMann(3,1) % the matrix produced here will be sparse

ans =

(1,1)        1
(2,2)       -1

Source code

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

1. %%  GELLMANN    Produces a Gell-Mann operator
2. %   This function has one required argument:
3. %     IND (an integer between 0 and 8, inclusive)
4. %
5. %   G = GellMann(IND) is the 3-by-3 Gell-Mann matrix indicated by the value
6. %   of IND. IND = 0 gives the identity matrix, while values of 1 through 8
7. %   each indicate one of the other 8 Gell-Mann matrices.
8. %
9. %   This function has one optional argument:
10. %     SP (default 0)
11. %
12. %   G = GellMann(IND,SP) is as above, with sparsity of the output
13. %   determined by the value of SP. If SP = 0 then the output will be full,
14. %   if SP = 1 then the output will be sparse.
15. %
16. %   URL: http://www.qetlab.com/GellMann
17. 
18. %   requires: opt_args.m
19. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
20. %   package: QETLAB
21. %   last updated: December 18, 2013
22. 
23. function g = GellMann(ind,varargin)
24. 
25. % set optional argument defaults: sp=0
26. [sp] = opt_args({ 0 },varargin{:});
27. 
28. if(ind == 1)
29.     g = [0 1 0;1 0 0;0 0 0];
30. elseif(ind == 2)
31.     g = [0 -1i 0;1i 0 0;0 0 0];
32. elseif(ind == 3)
33.     g = [1 0 0;0 -1 0;0 0 0];
34. elseif(ind == 4)
35.     g = [0 0 1;0 0 0;1 0 0];
36. elseif(ind == 5)
37.     g = [0 0 -1i;0 0 0;1i 0 0];
38. elseif(ind == 6)
39.     g = [0 0 0;0 0 1;0 1 0];
40. elseif(ind == 7)
41.     g = [0 0 0;0 0 -1i;0 1i 0];
42. elseif(ind == 8)
43.     g = [1 0 0;0 1 0;0 0 -2]/sqrt(3);
44. else
45.     g = eye(3);
46. end
47. 
48. if(sp)
49.     g = sparse(g);
50. end