13 #ifndef SU3MATRIXGENERATOR_H 14 #define SU3MATRIXGENERATOR_H 24 std::mt19937_64 m_generator;
27 std::uniform_real_distribution<double> m_uniform_distribution;
30 std::uniform_real_distribution<double> m_SU2_uniform_distribution;
32 double m_epsilonSquared;
33 double m_sqrtOneMinusEpsSquared;
34 double m_projectionFactor[2];
35 double m_columnLength = 0;
37 inline SU3 RSTMatrixMultiplicationInverse(
SU2 r,
SU2 s,
SU2 t);
103 for (
int i = 0; i < 3; i++)
105 for (
int j = 0; j < 3; j++)
107 H[6*i + 2*j] = m_uniform_distribution(m_generator);
108 H[6*i + 2*j + 1] = m_uniform_distribution(m_generator);
113 for (
int i = 0; i < 3; i++)
115 m_columnLength += H[6*i]*H[6*i] + H[6*i+1]*H[6*i+1];
117 m_columnLength = sqrt(m_columnLength);
118 for (
int i = 0; i < 3; i++)
120 H[6*i] /= m_columnLength;
121 H[6*i+1] /= m_columnLength;
124 m_projectionFactor[0] = 0;
125 m_projectionFactor[1] = 0;
126 for (
int i = 0; i < 3; i++)
128 m_projectionFactor[0] += H[6*i+2]*H[6*i] + H[6*i+3]*H[6*i+1];
129 m_projectionFactor[1] += H[6*i+3]*H[6*i] - H[6*i+2]*H[6*i+1];
131 for (
int i = 0; i < 3; i++)
133 H[6*i+2] -= H[6*i]*m_projectionFactor[0] - H[6*i+1]*m_projectionFactor[1];
134 H[6*i+3] -= H[6*i]*m_projectionFactor[1] + H[6*i+1]*m_projectionFactor[0];
138 for (
int i = 0; i < 3; i++)
140 m_columnLength += H[6*i+2]*H[6*i+2] + H[6*i+3]*H[6*i+3];
142 m_columnLength = sqrt(m_columnLength);
143 for (
int i = 0; i < 3; i++)
145 H[6*i+2] /= m_columnLength;
146 H[6*i+3] /= m_columnLength;
149 H[4] = H[8]*H[12] - H[9]*H[13] - H[14]*H[6] + H[15]*H[7];
150 H[5] = H[14]*H[7] + H[15]*H[6] - H[8]*H[13] - H[9]*H[12];
151 H[10] = H[14]*H[0] - H[15]*H[1] - H[2]*H[12] + H[3]*H[13];
152 H[11] = H[2]*H[13] + H[3]*H[12] - H[14]*H[1] - H[15]*H[0];
153 H[16] = H[2]*H[6] - H[3]*H[7] - H[8]*H[0] + H[9]*H[1];
154 H[17] = H[8]*H[1] + H[9]*H[0] - H[2]*H[7] - H[3]*H[6];
184 if (m_SU2_uniform_distribution(m_generator) < 0) {
185 return RSTMatrixMultiplicationInverse(r,s,t);
187 return RSTMatrixMultiplication(r,s,t);
200 for (
int i = 0; i < 4; i++) {
201 _r[i] = m_SU2_uniform_distribution(m_generator);
205 _x[0] = - m_sqrtOneMinusEpsSquared;
208 _x[0] = m_sqrtOneMinusEpsSquared;
210 for (
int i = 1; i < 4; i++) {
211 _rNorm += _r[i]*_r[i];
213 _rNorm = sqrt(_rNorm)/m_epsilon;
214 for (
int i = 1; i < 4; i++) {
215 _x[i] = _r[i]/_rNorm;
219 for (
int i = 0; i < 4; i++) {
220 _rNorm += _x[i]*_x[i];
222 _rNorm = sqrt(_rNorm);
223 for (
int i = 0; i < 4; i++) {
229 for (
int i = 0; i < 3; i++) {
230 for (
int j = 0; j < 4; j++) {
231 U[2*j] = U[2*j] - _x[i+1]*sigma[i].
mat[2*j+1];
232 U[2*j+1] = U[2*j+1] + _x[i+1]*sigma[i].
mat[2*j];
238 inline SU3 SU3MatrixGenerator::RSTMatrixMultiplication(
SU2 r,
SU2 s,
SU2 t)
249 rs[0] = r[0]*s[2] - r[1]*s[3];
250 rs[1] = r[1]*s[2] + r[0]*s[3];
252 rs[2] = r[4]*s[2] - r[5]*s[3];
253 rs[3] = r[5]*s[2] + r[4]*s[3];
255 X[0] = r[0]*s[0] - r[1]*s[1];
256 X[1] = r[1]*s[0] + r[0]*s[1];
257 X[2] = rs[0]*t[4] - r[3]*t[1] + r[2]*t[0] - rs[1]*t[5];
258 X[3] = rs[1]*t[4] + r[3]*t[0] + r[2]*t[1] + rs[0]*t[5];
259 X[4] = rs[0]*t[6] - r[3]*t[3] + r[2]*t[2] - rs[1]*t[7];
260 X[5] = rs[1]*t[6] + r[3]*t[2] + r[2]*t[3] + rs[0]*t[7];
261 X[6] = r[4]*s[0] - r[5]*s[1];
262 X[7] = r[5]*s[0] + r[4]*s[1];
263 X[8] = rs[2]*t[4] - r[7]*t[1] + r[6]*t[0] - rs[3]*t[5];
264 X[9] = rs[3]*t[4] + r[7]*t[0] + r[6]*t[1] + rs[2]*t[5];
265 X[10] = rs[2]*t[6] - r[7]*t[3] + r[6]*t[2] - rs[3]*t[7];
266 X[11] = rs[3]*t[6] + r[7]*t[2] + r[6]*t[3] + rs[2]*t[7];
269 X[14] = s[6]*t[4] - s[7]*t[5];
270 X[15] = s[7]*t[4] + s[6]*t[5];
271 X[16] = s[6]*t[6] - s[7]*t[7];
272 X[17] = s[7]*t[6] + s[6]*t[7];
277 inline SU3 SU3MatrixGenerator::RSTMatrixMultiplicationInverse(
SU2 r,
SU2 s,
SU2 t)
288 rs[0] = r[0]*s[2] - r[1]*s[3];
289 rs[1] = r[1]*s[2] + r[0]*s[3];
291 rs[2] = r[4]*s[2] - r[5]*s[3];
292 rs[3] = r[5]*s[2] + r[4]*s[3];
294 X[0] = r[0]*s[0] - r[1]*s[1];
295 X[1] = - r[1]*s[0] - r[0]*s[1];
296 X[2] = r[4]*s[0] - r[5]*s[1];
297 X[3] = - r[5]*s[0] - r[4]*s[1];
300 X[6] = rs[0]*t[4] - r[3]*t[1] + r[2]*t[0] - rs[1]*t[5];
301 X[7] = - rs[1]*t[4] - r[3]*t[0] - r[2]*t[1] - rs[0]*t[5];
302 X[8] = rs[2]*t[4] - r[7]*t[1] + r[6]*t[0] - rs[3]*t[5];;
303 X[9] = - rs[3]*t[4] - r[7]*t[0] - r[6]*t[1] - rs[2]*t[5];
304 X[10] = s[6]*t[4] - s[7]*t[5];
305 X[11] = - s[7]*t[4] - s[6]*t[5];
306 X[12] = rs[0]*t[6] - r[3]*t[3] + r[2]*t[2] - rs[1]*t[7];
307 X[13] = - rs[1]*t[6] - r[3]*t[2] - r[2]*t[3] - rs[0]*t[7];
308 X[14] = rs[2]*t[6] - r[7]*t[3] + r[6]*t[2] - rs[3]*t[7];
309 X[15] = - rs[3]*t[6] - r[7]*t[2] - r[6]*t[3] - rs[2]*t[7];
310 X[16] = s[6]*t[6] - s[7]*t[7];
311 X[17] = - s[7]*t[6] - s[6]*t[7];
316 #endif // SU3MATRIXGENERATOR_H SU3 testRSTMultiplicationInverse(SU2 r, SU2 s, SU2 t)
testRSTMultiplicationInverse wrapper for testing the RSTMatrixMultiplicationInverse method.
Definition: su3matrixgenerator.h:84
~SU3MatrixGenerator()
Definition: su3matrixgenerator.cpp:37
void zeros()
Definition: su3.cpp:8
class for holding matrices.
Definition: su3.h:18
Class for generating random SU3 matrices.
Definition: su3matrixgenerator.h:20
void zeros()
Definition: su2.h:176
SU3 generateRandom()
SU3MatrixGenerator::generateRandom generates a fully random SU3 matrix.
Definition: su3matrixgenerator.h:91
SU2 generateSU2()
SU3MatrixGenerator::generateSU2 generates a random SU2 matrix close to unity.
Definition: su3matrixgenerator.h:195
double mat[8]
Definition: su2.h:33
SU3MatrixGenerator()
Definition: su3matrixgenerator.cpp:16
Class for holding matrices.
Definition: su2.h:21
SU3 generateRST()
SU3MatrixGenerator::generateRST generates a SU3 matrix close to unity.
Definition: su3matrixgenerator.h:163
SU3 testRSTMultiplication(SU2 r, SU2 s, SU2 t)
testRSTMultiplication wrapper for testing the RSTMatrixMultiplication method.
Definition: su3matrixgenerator.h:73