36template <
int N,
typename T>
67 for (
int r = 0; r < N; r++) {
72 for (
int c = 0;
c < N;
c++)
75 for (
int c = 0;
c < N;
c++)
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);
143 if constexpr (N == 2) {
147 this->
e(0, 0) = Complex<T>(v[0], v[3]);
148 this->
e(1, 1) = Complex<T>(v[0], -v[3]);
149 this->
e(0, 1) = Complex<T>(v[2], v[1]);
150 this->
e(1, 0) = Complex<T>(-v[2], v[1]);
157 for (
int h = 1; h <= nhits; h++) {
158 for (
int r = 0; r < N - 1; r++)
159 for (
int q = r + 1; q < N; q++) {
212 T sum = this->
e(0, 0).im;
213 for (
int i = 1; i < N; i++) {
214 a.e(i - 1) = (sum - i * this->
e(i, i).im) / sqrt(0.5 * i * (i + 1));
215 sum += this->
e(i, i).im;
220 for (
int i = 0; i < N - 1; i++) {
221 for (
int j = i + 1; j < N; j++) {
222 auto od = this->
e(i, j) - this->
e(j, i).conj();
237template <
int N,
typename T>
241 using base_type = hila::arithmetic_type<T>;
242 using argument_type = T;
246 static constexpr int n_offdiag = N * (N - 1);
247 static constexpr int n_diag = N - 1;
248 static constexpr int N_a = N * N - 1;
282 for (
int i = 1; i < N; i++) {
283 T r = this->e(i - 1) * sqrt(0.5 / (i * (i + 1)));
285 for (
int j = 0; j < i; j++)
291 for (
int i = 0; i < N; i++)
296 for (
int i = 0; i < N - 1; i++)
297 for (
int j = i + 1; j < N; j++) {
298 Complex<T> v(this->c[k] * inv2, this->c[k + 1] * inv2);
300 m.
e(j, i) = -v.
conj();
334template <
int N,
typename T>
SU< N, T > expand() const
expand algebra to matrix rep - antihermitean
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.
Mtype & gaussian_random(double width=1.0)
Fills Matrix with gaussian random elements from gaussian distribution.
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
Complex< T > c[n *m]
The data as a one dimensional array.
Complex< T > e(const int i, const int j) const
Standard array indexing operation for matrices.
const Array< n, m, Complex< T > > & asArray() const
Cast Matrix to Array.
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.
Definition of Matrix types.
Invert diagonal + const. matrix using Sherman-Morrison formula.