37template <
int N,
typename T>
49 SU &operator=(
const SU &su) && =
delete;
67 for (
int r = 0; r < N; r++) {
72 for (
int i = 0; i < N; i++)
75 for (
int i = 0; i < N; i++)
82 for (
int j = r + 1; j < N; j++) {
85 for (
int i = 0; i < N; i++) {
86 d +=
::conj(this->
e(r, i)) * this->
e(j, i);
89 for (
int i = 0; i < N; i++) {
90 this->
e(j, i) -= d * this->
e(r, i);
107 for (
int i = 0; i < N * N; i++) {
142 if constexpr (N == 2) {
146 this->
e(0, 0) = Complex<T>(v[0], v[3]);
147 this->
e(1, 1) = Complex<T>(v[0], -v[3]);
148 this->
e(0, 1) = Complex<T>(v[2], v[1]);
149 this->
e(1, 0) = Complex<T>(-v[2], v[1]);
156 for (
int h = 1; h <= nhits; h++) {
157 for (
int r = 0; r < N - 1; r++)
158 for (
int q = r + 1; q < N; q++) {
216 T sum = this->
e(0, 0).im;
217 for (
int i = 1; i < N; i++) {
218 a.e(i - 1) = (sum - i * this->
e(i, i).im) /
sqrt(0.5 * i * (i + 1));
219 sum += this->
e(i, i).im;
224 for (
int i = 0; i < N - 1; i++) {
225 for (
int j = i + 1; j < N; j++) {
226 auto od = this->
e(i, j) - this->
e(j, i).conj();
241 T sum = this->
e(0, 0).im;
242 for (
int i = 1; i < N; i++) {
243 a.e(i - 1) = scf * (sum - i * this->
e(i, i).im) /
sqrt(0.5 * i * (i + 1));
244 sum += this->
e(i, i).im;
249 for (
int i = 0; i < N - 1; i++) {
250 for (
int j = i + 1; j < N; j++) {
251 auto od = this->
e(i, j) - this->
e(j, i).conj();
252 a.e(k) = scf * od.re;
253 a.e(k + 1) = scf * od.im;
269 T sum = this->
e(0, 0).im;
270 for (
int i = 1; i < N; i++) {
271 a.e(i - 1) = (sum - i * this->
e(i, i).im) /
sqrt(0.5 * i * (i + 1));
272 sum += this->
e(i, i).im;
273 onenorm +=
abs(a.e(i - 1));
278 for (
int i = 0; i < N - 1; i++) {
279 for (
int j = i + 1; j < N; j++) {
280 auto od = this->
e(i, j) - this->
e(j, i).conj();
283 onenorm +=
abs(a.e(k)) +
abs(a.e(k + 1));
296template <
int N,
typename T>
300 using base_type = hila::arithmetic_type<T>;
301 using argument_type = T;
305 static constexpr int n_offdiag = N * (N - 1);
306 static constexpr int n_diag = N - 1;
307 static constexpr int N_a = N * N - 1;
339 for (
int i = 1; i < N; i++) {
340 T r = this->c[i - 1] *
sqrt(0.5 / (i * (i + 1)));
342 for (
int j = 0; j < i; j++)
348 for (
int i = 0; i < N; i++)
353 for (
int i = 0; i < N - 1; i++)
354 for (
int j = i + 1; j < N; j++) {
355 Complex<T> v(this->c[k] * inv2, this->c[k + 1] * inv2);
357 m.
e(j, i) = -v.
conj();
371 for (
int i = 1; i < N; i++) {
372 T r = this->c[i - 1] *
sqrt(0.5 / (i * (i + 1)));
374 for (
int j = 0; j < i; j++)
380 for (
int i = 0; i < N; i++)
385 for (
int i = 0; i < N - 1; i++)
386 for (
int j = i + 1; j < N; j++) {
387 Complex<T> v(this->c[k] * inv2, this->c[k + 1] * inv2);
389 m.
e(j, i) = -v.
conj();
429 T dot(
const Algebra &rhs)
const {
431 for (
int i = 0; i < N_a; ++i) {
432 r += this->e(i) * rhs.e(i);
438template <
int N,
typename T>
460template <
int N,
typename T>
470template <
int N,
typename T>
478template <
int N,
typename T>
488 for (it = 0; it < maxit; ++it) {
491 for (i = 0; i < Algebra<SU<N, T>>::N_a; ++i) {
492 res.e(i) += tres.e(i);
495 if (trn < fprec * (rn + 1.0)) {
498 tmat = res.expand_scaled(-1.0);
499 chexp(tmat, tmat2, pl);
500 mult(a, tmat2, tmat);
Array< n, m, T > exp(Array< n, m, T > a)
Exponential.
Array< n, m, T > cos(Array< n, m, T > a)
Cosine.
Array< n, m, T > sqrt(Array< n, m, T > a)
Square root.
Array< n, m, T > sin(Array< n, m, T > a)
Sine.
SU< N, T > expand_scaled(T scf) const
expand algebra to scaled matrix rep - antihermitian
SU< N, T > expand() const
expand algebra to matrix rep - antihermitean
Algebra & gaussian_random(T width=sqrt(2.0))
Complex< T > conj() const
Compute conjugate of Complex number.
T arg() const
Compute argument of Complex number.
The main matrix type template Matrix_t. This is a base class type for "useful" types which are deriv...
void mult_by_2x2_left(int p, int q, const Matrix_t< 2, 2, R, Mt > &M)
Multiply -matrix from the left by matrix defined by sub matrix.
hila::arithmetic_type< T > norm() const
Calculate vector norm - sqrt of squarenorm.
Matrix_t()=default
Define default constructors to ensure std::is_trivial.
SU< N, T > conj() const
Returns complex conjugate of Matrix.
Complex< T > det() const
determinant function - if matrix size is < 5, use Laplace, otherwise LU
auto abs() const
Returns absolute value of Matrix.
Complex< T > c[n *m]
The data as a one dimensional array.
Mtype & gaussian_random(base_type width=1.0)
Fills Matrix with gaussian random elements.
Complex< T > e(const int i, const int j) const
Standard array indexing operation for matrices and vectors.
hila::arithmetic_type< Complex< T > > squarenorm() const
Calculate square norm - sum of squared elements.
Matrix class which defines matrix operations.
const SU & random(int nhits=16)
Generate random SU(N) matrix.
const SU & reunitarize()
Reunitarize SU(N) matrix.
const SU & fix_det()
Fix determinant.
Algebra< SU< N, T > > project_to_algebra() const
const SU & make_unitary()
Makes the matrix unitary by orthogonalizing the rows.
T abs(const Complex< T > &a)
Return absolute value of Complex number.
Definition of Matrix types.
Matrix_t< n, m, T, MT > chsexp(const Matrix_t< n, m, T, MT > &mat)
Calculate exp of a square matrix.
void chexp(const Matrix_t< n, m, T, MT > &mat, Matrix_t< n, m, T, MT > &omat, Matrix_t< n, m, T, MT >(&pl)[n+1])
Calculate exp of a square matrix.
void mult(const Mt &a, const Mt &b, Mt &res)
compute product of two square matrices and write result to existing matrix
Implement hila::swap for gauge fields.
logger_class log
Now declare the logger.