KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > JSci > maths > algebras > su3Dim3


1 package JSci.maths.algebras;
2
3 import JSci.maths.*;
4 import JSci.maths.matrices.AbstractComplexMatrix;
5 import JSci.maths.matrices.AbstractComplexSquareMatrix;
6 import JSci.maths.matrices.ComplexSquareMatrix;
7 import JSci.maths.vectors.AbstractDoubleVector;
8 import JSci.maths.vectors.DoubleVector;
9 import JSci.maths.fields.ComplexField;
10
11 /**
12 * The su3Dim3 class encapsulates su(3) algebras using
13 * the 3 dimensional (fundamental) representation.
14 * Elements are represented by vectors with a matrix basis.
15 * @version 1.2
16 * @author Mark Hale
17 */

18 public final class su3Dim3 extends LieAlgebra {
19         /**
20         * Useful complex constants.
21         */

22         private final static Complex T8_1=new Complex(0.5/Math.sqrt(3.0),0.0);
23         private final static Complex T8_2=new Complex(-1.0/Math.sqrt(3.0),0.0);
24
25         private final static Complex t1[][]={
26                 {Complex.ZERO,ComplexField.HALF,Complex.ZERO},
27                 {ComplexField.HALF,Complex.ZERO,Complex.ZERO},
28                 {Complex.ZERO,Complex.ZERO,Complex.ZERO}
29         };
30         private final static Complex t2[][]={
31                 {Complex.ZERO,ComplexField.MINUS_HALF_I,Complex.ZERO},
32                 {ComplexField.HALF_I,Complex.ZERO,Complex.ZERO},
33                 {Complex.ZERO,Complex.ZERO,Complex.ZERO}
34         };
35         private final static Complex t3[][]={
36                 {ComplexField.HALF,Complex.ZERO,Complex.ZERO},
37                 {Complex.ZERO,ComplexField.MINUS_HALF,Complex.ZERO},
38                 {Complex.ZERO,Complex.ZERO,Complex.ZERO}
39         };
40         private final static Complex t4[][]={
41                 {Complex.ZERO,Complex.ZERO,ComplexField.HALF},
42                 {Complex.ZERO,Complex.ZERO,Complex.ZERO},
43                 {ComplexField.HALF,Complex.ZERO,Complex.ZERO}
44         };
45         private final static Complex t5[][]={
46                 {Complex.ZERO,Complex.ZERO,ComplexField.MINUS_HALF_I},
47                 {Complex.ZERO,Complex.ZERO,Complex.ZERO},
48                 {ComplexField.HALF_I,Complex.ZERO,Complex.ZERO}
49         };
50         private final static Complex t6[][]={
51                 {Complex.ZERO,Complex.ZERO,Complex.ZERO},
52                 {Complex.ZERO,Complex.ZERO,ComplexField.HALF},
53                 {Complex.ZERO,ComplexField.HALF,Complex.ZERO}
54         };
55         private final static Complex t7[][]={
56                 {Complex.ZERO,Complex.ZERO,Complex.ZERO},
57                 {Complex.ZERO,Complex.ZERO,ComplexField.MINUS_HALF_I},
58                 {Complex.ZERO,ComplexField.HALF_I,Complex.ZERO}
59         };
60         private final static Complex t8[][]={
61                 {T8_1,Complex.ZERO,Complex.ZERO},
62                 {Complex.ZERO,T8_1,Complex.ZERO},
63                 {Complex.ZERO,Complex.ZERO,T8_2}
64         };
65         /**
66         * Basis.
67         */

68         private final static AbstractComplexSquareMatrix basisMatrices[]={
69                 new ComplexSquareMatrix(t1),
70                 new ComplexSquareMatrix(t2),
71                 new ComplexSquareMatrix(t3),
72                 new ComplexSquareMatrix(t4),
73                 new ComplexSquareMatrix(t5),
74                 new ComplexSquareMatrix(t6),
75                 new ComplexSquareMatrix(t7),
76                 new ComplexSquareMatrix(t8)
77         };
78
79         private final static su3Dim3 _instance = new su3Dim3();
80         /**
81         * Constructs an su(3) algebra.
82         */

83         private su3Dim3() {
84                 super("su(3) [3]");
85         }
86         /**
87         * Singleton.
88         */

89         public static final su3Dim3 getInstance() {
90                 return _instance;
91         }
92         /**
93         * Returns an element as a matrix (vector*basis).
94         */

95         public AbstractComplexSquareMatrix getElement(final AbstractDoubleVector v) {
96                 AbstractComplexMatrix m=basisMatrices[0].scalarMultiply(v.getComponent(0));
97                 m=m.add(basisMatrices[1].scalarMultiply(v.getComponent(1)));
98                 m=m.add(basisMatrices[2].scalarMultiply(v.getComponent(2)));
99                 m=m.add(basisMatrices[3].scalarMultiply(v.getComponent(3)));
100                 m=m.add(basisMatrices[4].scalarMultiply(v.getComponent(4)));
101                 m=m.add(basisMatrices[5].scalarMultiply(v.getComponent(5)));
102                 m=m.add(basisMatrices[6].scalarMultiply(v.getComponent(6)));
103                 m=m.add(basisMatrices[7].scalarMultiply(v.getComponent(7)));
104                 return (AbstractComplexSquareMatrix)m.scalarMultiply(Complex.I);
105         }
106         /**
107         * Returns the Lie bracket (commutator) of two elements.
108         */

109         public AbstractDoubleVector multiply(final AbstractDoubleVector a, final AbstractDoubleVector b) {
110                 double array[]=new double[8];
111                 array[0]=b.getComponent(1)*a.getComponent(2)-b.getComponent(2)*a.getComponent(1)+0.5*(
112                         b.getComponent(3)*a.getComponent(6)-b.getComponent(6)*a.getComponent(3)+
113                         b.getComponent(5)*a.getComponent(4)-b.getComponent(4)*a.getComponent(5));
114                 array[1]=b.getComponent(2)*a.getComponent(0)-b.getComponent(0)*a.getComponent(2)+0.5*(
115                         b.getComponent(3)*a.getComponent(5)-b.getComponent(5)*a.getComponent(3)+
116                         b.getComponent(4)*a.getComponent(6)-b.getComponent(6)*a.getComponent(4));
117                 array[2]=b.getComponent(0)*a.getComponent(1)-b.getComponent(1)*a.getComponent(0)+0.5*(
118                         b.getComponent(3)*a.getComponent(4)-b.getComponent(4)*a.getComponent(3)+
119                         b.getComponent(6)*a.getComponent(5)-b.getComponent(5)*a.getComponent(6));
120                 array[3]=Math.sqrt(0.75)*(b.getComponent(4)*a.getComponent(7)-b.getComponent(7)*a.getComponent(4))+0.5*(
121                         b.getComponent(6)*a.getComponent(0)-b.getComponent(0)*a.getComponent(6)+
122                         b.getComponent(5)*a.getComponent(1)-b.getComponent(1)*a.getComponent(5)+
123                         b.getComponent(4)*a.getComponent(2)-b.getComponent(2)*a.getComponent(4));
124                 array[4]=Math.sqrt(0.75)*(b.getComponent(7)*a.getComponent(3)-b.getComponent(3)*a.getComponent(7))+0.5*(
125                         b.getComponent(0)*a.getComponent(5)-b.getComponent(5)*a.getComponent(0)+
126                         b.getComponent(6)*a.getComponent(1)-b.getComponent(1)*a.getComponent(6)+
127                         b.getComponent(2)*a.getComponent(3)-b.getComponent(3)*a.getComponent(2));
128                 array[5]=Math.sqrt(0.75)*(b.getComponent(6)*a.getComponent(7)-b.getComponent(7)*a.getComponent(6))+0.5*(
129                         b.getComponent(4)*a.getComponent(0)-b.getComponent(0)*a.getComponent(4)+
130                         b.getComponent(1)*a.getComponent(3)-b.getComponent(3)*a.getComponent(1)+
131                         b.getComponent(2)*a.getComponent(6)-b.getComponent(6)*a.getComponent(2));
132                 array[6]=Math.sqrt(0.75)*(b.getComponent(7)*a.getComponent(5)-b.getComponent(5)*a.getComponent(7))+0.5*(
133                         b.getComponent(0)*a.getComponent(3)-b.getComponent(3)*a.getComponent(0)+
134                         b.getComponent(1)*a.getComponent(4)-b.getComponent(4)*a.getComponent(1)+
135                         b.getComponent(5)*a.getComponent(2)-b.getComponent(2)*a.getComponent(5));
136                 array[7]=Math.sqrt(0.75)*(b.getComponent(3)*a.getComponent(4)-b.getComponent(4)*a.getComponent(3)+
137                         b.getComponent(5)*a.getComponent(6)-b.getComponent(6)*a.getComponent(5));
138                 return new DoubleVector(array);
139         }
140         /**
141         * Returns the basis used to represent the Lie algebra.
142         */

143         public AbstractComplexSquareMatrix[] basis() {
144                 return basisMatrices;
145         }
146 }
147
148
Popular Tags