HILA
Loading...
Searching...
No Matches
Algebra< SU< N, T > > Class Template Reference

#include <sun_matrix.h>

Inheritance diagram for Algebra< SU< N, T > >:
Collaboration diagram for Algebra< SU< N, T > >:

Public Member Functions

SU< N, T > expand_scaled (T scf) const
 expand algebra to scaled matrix rep - antihermitian
 
Algebragaussian_random (T width=sqrt(2.0))
 
e (const int i, const int j) const
 Standard array indexing operation for matrices and vectors.
 
operator[] (const int i) const
 Indexing operation [] defined only for vectors.
 
RowVector< m, T > row (int r) const
 Return row of a matrix as a RowVector.
 
void set_row (int r, const RowVector< m, S > &v)
 Set row of Matrix with RowVector if types are assignable.
 
Vector< n, T > column (int c) const
 Returns column vector as value at index c.
 
void set_column (int c, const Vector< n, S > &v)
 get column of a matrix
 
DiagonalMatrix< n, T > diagonal ()
 Return diagonal of square matrix.
 
void set_diagonal (const Vector< n, S > &v)
 Set diagonal of square matrix to Vector which is passed to the method.
 
const Array< n, m, T > & asArray () const
 Cast Matrix to Array.
 
const DiagonalMatrix< n, T > & asDiagonalMatrix () const
 Cast Vector to DiagonalMatrix.
 
Algebra< SU< N, T > > operator- () const
 Unary - operator.
 
const auto & operator+ () const
 Unary + operator.
 
bool operator== (const Matrix< n2, m2, S > &rhs) const
 Boolean operator == to determine if two matrices are exactly the same.
 
bool operator!= (const Matrix< n, m, S > &rhs) const
 Boolean operator != to check if matrices are exactly different.
 
auto & operator+= (const Matrix_t< n, m, S, MT > &rhs) &
 Add assign operator with matrix or scalar.
 
auto & operator+= (const DiagonalMatrix< n, S > &rhs) &
 add and sub assign a DiagonalMatrix
 
auto & operator-= (const Matrix_t< n, m, S, MT > &rhs) &
 Subtract assign operator with matrix or scalar.
 
auto & operator*= (const Matrix_t< m, p, S, MT > &rhs) &
 Multiply assign scalar or matrix.
 
auto & operator*= (const DiagonalMatrix< m, S > &rhs) &
 mult and divide assign a diagonal - cols must match diagonal matrix rows
 
auto & operator/= (const S rhs) &
 Divide assign scalar.
 
const auto & fill (const S rhs)
 Matrix fill.
 
Rtype transpose () const
 Transpose of matrix.
 
const RowVector< n, T > & transpose () const
 Transpose of vector.
 
Algebra< SU< N, T > > conj () const
 Returns complex conjugate of Matrix.
 
Rtype dagger () const
 Hermitian conjugate of matrix.
 
Rtype adjoint () const
 Adjoint of matrix.
 
auto abs () const
 Returns absolute value of Matrix.
 
Matrix< n, m, hila::arithmetic_type< T > > real () const
 Returns real part of Matrix or Vector.
 
Matrix< n, m, hila::arithmetic_type< T > > imag () const
 Returns imaginary part of Matrix or Vector.
 
trace () const
 Computes Trace for Matrix.
 
hila::type_mul< T, S > mul_trace (const Matrix_t< p, q, S, MT > &rm) const
 Multiply with given matrix and compute trace of result.
 
hila::arithmetic_type< T > squarenorm () const
 Calculate square norm - sum of squared elements.
 
hila::arithmetic_type< T > norm () const
 Calculate vector norm - sqrt of squarenorm.
 
max () const
 Find max or min value - only for arithmetic types.
 
dot (const Matrix< p, q, S > &rhs) const
 Dot product.
 
Matrix< n, p, R > outer_product (const Matrix< p, q, S > &rhs) const
 Outer product.
 
Algebra< SU< N, T > > & random ()
 dot with matrix - matrix
 
Algebra< SU< N, T > > & gaussian_random (base_type width=1.0)
 Fills Matrix with gaussian random elements.
 
Algebra< SU< N, T > > permute_columns (const Vector< m, int > &permutation) const
 permute columns of Matrix
 
Algebra< SU< N, T > > permute_rows (const Vector< n, int > &permutation) const
 permute rows of Matrix
 
Algebra< SU< N, T > > permute (const Vector< N, int > &permutation) const
 Permute elements of vector.
 
Algebra< SU< N, T > > sort (Vector< N, int > &permutation, hila::sort order=hila::sort::ascending) const
 Sort method for Vector.
 
void mult_by_2x2_left (int p, int q, const Matrix_t< 2, 2, R, Mt > &M)
 Multiply \( n \times m \)-matrix from the left by \( n \times m \) matrix defined by \( 2 \times 2 \) sub matrix.
 
void mult_by_2x2_right (int p, int q, const Matrix_t< 2, 2, R, Mt > &M)
 Multiply \( n \times m \)-matrix from the right by \( n \times m \) matrix defined by \( 2 \times 2 \) sub matrix.
 
det_lu () const
 following calculate the determinant of a square matrix det() is the generic interface, using laplace for small matrices and LU for large
 
det_laplace () const
 Determinant of matrix, using Laplace method.
 
det () const
 determinant function - if matrix size is < 5, use Laplace, otherwise LU
 
int eigen_hermitean (DiagonalMatrix< n, Et > &eigenvalues, Matrix_t< n, n, Mt, MT > &eigenvectors, enum hila::sort sorted=hila::sort::unsorted) const
 Calculate eigenvalues and -vectors of an hermitean (or symmetric) matrix.
 
eigen_result< Algebra< SU< N, T > > > eigen_hermitean (enum hila::sort sorted=hila::sort::unsorted) const
 eigenvalues and -vectors of hermitean/symmetric matrix, alternative interface
 
int svd (Matrix_t< n, n, Mt, MT > &_U, DiagonalMatrix< n, Et > &_D, Matrix_t< n, n, Mt, MT > &_V, enum hila::sort sorted=hila::sort::unsorted) const
 Singular value decomposition: divide matrix A = U S V*, where U,V unitary and S diagonal matrix of real singular values. Unpivoted Jacobi rotations.
 
svd_result< Algebra< SU< N, T > > > svd (enum hila::sort sorted=hila::sort::unsorted) const
 svd and svd_pivot - alternative interface
 
int svd_pivot (Matrix_t< n, n, Mt, MT > &_U, DiagonalMatrix< n, Et > &_D, Matrix_t< n, n, Mt, MT > &_V, enum hila::sort sorted=hila::sort::unsorted) const
 Singular value decomposition: divide matrix A = U S V*, where U,V unitary and S diagonal matrix of real singular values. Fully pivoted Jacobi rotations.
 
std::string str (int prec=8, char separator=' ') const
 

Static Public Member Functions

static void generator_list (Alg_gen< N, T >(&gen_list)[N_a])
 expand algebra to matrix rep - antihermitean
 
static constexpr bool is_vector ()
 Returns true if Matrix is a vector.
 
static constexpr bool is_square ()
 Returns true if matrix is a square matrix.
 
static constexpr int rows ()
 Define constant methods rows(), columns() - may be useful in template code.
 
static constexpr int columns ()
 Returns column length.
 
static constexpr int size ()
 Returns size of Vector or square Matrix.
 

Public Attributes

c [n *m]
 The data as a one dimensional array.
 

Detailed Description

template<int N, typename T>
class Algebra< SU< N, T > >

Specialize Algebra type to SU(N) Derive from (real) Vector of N*N-1 elements

Definition at line 369 of file sun_matrix.h.

Member Function Documentation

◆ abs()

auto Matrix_t< n, m, T, Algebra< SU< N, T > > >::abs ( ) const
inlineinherited

Returns absolute value of Matrix.

For Matrix<n,m,Complex<T>> case type is changed to Matrix<n,m,T> as expected since absolute value of a complex number is real

Template Parameters
M
Returns
Mtype

Definition at line 1031 of file matrix.h.

◆ adjoint()

Rtype Matrix_t< n, m, T, Algebra< SU< N, T > > >::adjoint ( ) const
inlineinherited

Adjoint of matrix.

Alias to dagger

Template Parameters
std::conditional<n,Mtype,Matrix<m,n,T>>::type
Returns
Rtype

Definition at line 1019 of file matrix.h.

◆ asArray()

const Array< n, m, T > & Matrix_t< n, m, T, Algebra< SU< N, T > > >::asArray ( ) const
inlineinherited

Cast Matrix to Array.

used for array operations

Returns
Array<n, m, T>&

Definition at line 443 of file matrix.h.

◆ asDiagonalMatrix()

const DiagonalMatrix< n, T > & Matrix_t< n, m, T, Algebra< SU< N, T > > >::asDiagonalMatrix ( ) const
inlineinherited

Cast Vector to DiagonalMatrix.

Returns
DiagonalMatrix<n,T>

Definition at line 458 of file matrix.h.

◆ column()

Vector< n, T > Matrix_t< n, m, T, Algebra< SU< N, T > > >::column ( int  c) const
inlineinherited

Returns column vector as value at index c.

Parameters
cindex of column vector to be returned
Returns
const Vector<n, T>

Definition at line 368 of file matrix.h.

◆ columns()

static constexpr int Matrix_t< n, m, T, Algebra< SU< N, T > > >::columns ( )
inlinestaticconstexprinherited

Returns column length.

Returns
constexpr int

Definition at line 234 of file matrix.h.

◆ conj()

Algebra< SU< N, T > > Matrix_t< n, m, T, Algebra< SU< N, T > > >::conj ( ) const
inlineinherited

Returns complex conjugate of Matrix.

Returns
const Mtype

Definition at line 986 of file matrix.h.

◆ dagger()

Rtype Matrix_t< n, m, T, Algebra< SU< N, T > > >::dagger ( ) const
inlineinherited

Hermitian conjugate of matrix.

for square matrix return type is same, for non square it is Matrix<m,n,MyType>

Template Parameters
std::conditional<n,Mtype,Matrix<m,n,T>>::type
Returns
const Rtype

Definition at line 1002 of file matrix.h.

◆ det_laplace()

T Matrix_t< n, m, T, Algebra< SU< N, T > > >::det_laplace
inherited

Determinant of matrix, using Laplace method.

Defined only for square matrices

For perfomance overloads exist for \( 1 \times 1 \), \( 2 \times 2 \) and \( 3 \times 3 \) matrices.

Parameters
matmatrix to compute determinant for
Returns
T result determinant

Definition at line 1530 of file matrix_linalg.h.

◆ det_lu()

T Matrix_t< n, m, T, Algebra< SU< N, T > > >::det_lu
inherited

following calculate the determinant of a square matrix det() is the generic interface, using laplace for small matrices and LU for large

Matrix determinant with LU decomposition.

Algorithm: numerical Recipes, 2nd ed. p. 47 ff Works for Real and Complex matrices Defined only for square matrices

Returns
Complex<radix> Determinant

Definition at line 1528 of file matrix_linalg.h.

◆ diagonal()

DiagonalMatrix< n, T > Matrix_t< n, m, T, Algebra< SU< N, T > > >::diagonal ( )
inlineinherited

Return diagonal of square matrix.

If called for non square matrix the program will throw an error.

Returns
Vector<n, T> returned vector.

Definition at line 406 of file matrix.h.

◆ dot()

R Matrix_t< n, m, T, Algebra< SU< N, T > > >::dot ( const Matrix< p, q, S > &  rhs) const
inlineinherited

Dot product.

Only works between two Vector objects

.
.
.
V.dot(W); // valid operation
R dot(const Matrix< p, q, S > &rhs) const
Dot product.
Definition matrix.h:1220
Matrix class which defines matrix operations.
Definition matrix.h:1620
.
.
.
V.dot(W); // not valid operation
Template Parameters
pRow length for rhs
qColumn length for rhs
SType for rhs
RGives resulting type of lhs and rhs multiplication
Parameters
rhsVector to compute dot product with
Returns
R Value of dot product

Definition at line 1220 of file matrix.h.

◆ e()

T Matrix_t< n, m, T, Algebra< SU< N, T > > >::e ( const int  i,
const int  j 
) const
inlineinherited

Standard array indexing operation for matrices and vectors.

Accessing singular elements is insufficient, but matrix elements are often quite small.

Exammple for matrix:

MyType a = M.e(i,j); \\ i <= n, j <= m
Complex definition.
Definition cmplx.h:56
T e(const int i, const int j) const
Standard array indexing operation for matrices and vectors.
Definition matrix.h:286

Example for vector:

MyType a = V.e(i) \\ i <= n
Parameters
irow index
jcolumn index
Returns
T matrix element type

Definition at line 286 of file matrix.h.

◆ eigen_hermitean() [1/2]

int Matrix_t< n, m, T, Algebra< SU< N, T > > >::eigen_hermitean ( DiagonalMatrix< n, Et > &  E,
Matrix_t< n, n, Mt, MT > &  U,
enum hila::sort  sorted = hila::sort::unsorted 
) const
inherited

Calculate eigenvalues and -vectors of an hermitean (or symmetric) matrix.

Calculate eigenvalues and vectors of an hermitean or real symmetric matrix.

Returns the number of Jacobi iterations, or -1 if did not converge. Arguments will contain eigenvalues and eigenvectors in columns of the "eigenvectors" matrix. Computation is done in double precision despite the input matrix types.

Parameters
eigenvaluevecVector of computed eigenvalue
eigenvectorsEigenvectors as columns of \( n \times n \) Matrix

Algorithm uses fully pivoted Jacobi rotations.

Two interfaces:

H.eigen_hermitean(E, U, [optional: sort]); E: output is DiagnoalMatrix containing real eigenvalues U: nxn unitary matrix, columns are normalized eigenvectors

auto res = H.eigen_hermitean([optional: sort]); This saves the trouble of defining E and U (see below)

Thus, H = U E U^* and H U = U E

Both interfaces allow optional sorting according to eigenvalues: hila::sort::unsorted [default] hila::sort::ascending / descending

Example:

M = ... // make unitary
int rotations = M.eigen_hermitean(eigenvalues,eigenvectors,hila::sort::ascending);
Define type DiagonalMatrix<n,T>
int eigen_hermitean(DiagonalMatrix< n, Et > &eigenvalues, Matrix_t< n, n, Mt, MT > &eigenvectors, enum hila::sort sorted=hila::sort::unsorted) const
Calculate eigenvalues and -vectors of an hermitean (or symmetric) matrix.
Note
The matrix has to be hermitean/symmetric
Parameters
Ediagonal matrix of real eigenvalues
UUnitary nxn matrix of eigenvectors
sortedsorting of eigenvalues (default:unsorted)
Returns
int number of jacobi rotations

Definition at line 1546 of file matrix_linalg.h.

◆ eigen_hermitean() [2/2]

eigen_result< Algebra< SU< N, T > > > Matrix_t< n, m, T, Algebra< SU< N, T > > >::eigen_hermitean ( enum hila::sort  sorted = hila::sort::unsorted) const
inherited

eigenvalues and -vectors of hermitean/symmetric matrix, alternative interface

result = eigen_hermitean(hila::sort [optional]) returns struct eigen_result<Mtype>, with fields eigenvalues: DiagonalMatrix of eigenvalues eigenvectors: nxn unitary matrix of eigenvectors

Example:

M[ALL] = .. // make symmetric
onsites(ALL) {
auto R = M[X].svd();
// Use EV decomposition to evaluate function: sin(M) = U sin(eigenvals) U^T
sn[X] = R.eigenvectors * sin(R.eigenvalues) * R.eigenvectors.dagger();
}
Array< n, m, T > sin(Array< n, m, T > a)
Sine.
Definition array.h:1079
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
Definition field.h:61
constexpr Parity ALL
bit pattern: 011

This interface saves the trouble of defining the eigenvalue and -vector variables.

Definition at line 1550 of file matrix_linalg.h.

◆ fill()

const auto & Matrix_t< n, m, T, Algebra< SU< N, T > > >::fill ( const S  rhs)
inlineinherited

Matrix fill.

Fills the matrix with element if it is assignable to matrix type T

Works as follows:

M.fill(2) \\ Matrix is filled with 2
const auto & fill(const S rhs)
Matrix fill.
Definition matrix.h:937
Template Parameters
SElement type to be assigned
Parameters
rhsElement to fill matrix with
Returns
const Mtype&

Definition at line 937 of file matrix.h.

◆ gaussian_random() [1/2]

Algebra< SU< N, T > > & Matrix_t< n, m, T, Algebra< SU< N, T > > >::gaussian_random ( base_type  width = 1.0)
inlineinherited

Fills Matrix with gaussian random elements.

Works only for real valued elements such as float or double

Parameters
width
Returns
Mtype&

Definition at line 1314 of file matrix.h.

◆ gaussian_random() [2/2]

template<int N, typename T >
Algebra & Algebra< SU< N, T > >::gaussian_random ( width = sqrt(2.0))
inline

Produce gaussian random distributed algebra element. Set default normalisation so that the algebra matrix ah = i h = i xi_i \lambda_i is from distribution exp(-Tr h^2 ) = exp(- xi_i^2 / 2 ) I.E. the coefficients of the generators have < xi_i^2 > = 1

Now the off-diag elements have <|od|^2> = 1/2 = <od.re^2> + <od.im^2> = 1/4 + 1/4 1/4 (<xi_a^2> + <xi_b^2>)

With this convention the inherited method from Vector is fine and the code below is not needed

Definition at line 558 of file sun_matrix.h.

◆ imag()

Matrix< n, m, hila::arithmetic_type< T > > Matrix_t< n, m, T, Algebra< SU< N, T > > >::imag ( ) const
inlineinherited

Returns imaginary part of Matrix or Vector.

Returns
Matrix<n, m, hila::arithmetic_type<T>>

Definition at line 1064 of file matrix.h.

◆ is_square()

static constexpr bool Matrix_t< n, m, T, Algebra< SU< N, T > > >::is_square ( )
inlinestaticconstexprinherited

Returns true if matrix is a square matrix.

Returns
true
false

Definition at line 142 of file matrix.h.

◆ is_vector()

static constexpr bool Matrix_t< n, m, T, Algebra< SU< N, T > > >::is_vector ( )
inlinestaticconstexprinherited

Returns true if Matrix is a vector.

Returns
true
false

Definition at line 132 of file matrix.h.

◆ mul_trace()

hila::type_mul< T, S > Matrix_t< n, m, T, Algebra< SU< N, T > > >::mul_trace ( const Matrix_t< p, q, S, MT > &  rm) const
inlineinherited

Multiply with given matrix and compute trace of result.

Slightly cheaper operation than

(M*N).trace()
T trace() const
Computes Trace for Matrix.
Definition matrix.h:1079
Template Parameters
p
q
S
MT
Parameters
rm
Returns
hila::type_mul<T, S>

Definition at line 1100 of file matrix.h.

◆ mult_by_2x2_left()

void Matrix_t< n, m, T, Algebra< SU< N, T > > >::mult_by_2x2_left ( int  p,
int  q,
const Matrix_t< 2, 2, R, Mt > &  M 
)
inlineinherited

Multiply \( n \times m \)-matrix from the left by \( n \times m \) matrix defined by \( 2 \times 2 \) sub matrix.

The multiplication is defined as follows, let \(M\) as the \( 2 \times 2 \) input matrix and \(B\) be (this) matrix, being the matrix stored in the object this method is called for. Let \(A = I\) be a \( n \times m \) unit matrix. We then set the values of A to be:

\begin{align} A_{p,p} = M_{0,0}, \hspace{5px} A_{p,q} = M_{0,1}, \hspace{5px} A_{q,p} = M_{1,0}, \hspace{5px} A_{q,q} = M_{1,1}. \end{align}

Then the resulting matrix will be:

\begin{align} B = A \cdot B \end{align}

Template Parameters
RElement type of M
MtMatrix type of M
Parameters
pFirst row and column
qSecond row and column
M\( 2 \times 2\) Matrix to multiply with

Definition at line 1473 of file matrix.h.

◆ mult_by_2x2_right()

void Matrix_t< n, m, T, Algebra< SU< N, T > > >::mult_by_2x2_right ( int  p,
int  q,
const Matrix_t< 2, 2, R, Mt > &  M 
)
inlineinherited

Multiply \( n \times m \)-matrix from the right by \( n \times m \) matrix defined by \( 2 \times 2 \) sub matrix.

See Matrix::mult_by_2x2_left, only difference being that the multiplication is from the right.

Template Parameters
RElement type of M
MtMatrix type of M
Parameters
pFirst row and column
qSecond row and column
M\( 2 \times 2\) Matrix to multiply with

Definition at line 1502 of file matrix.h.

◆ norm()

hila::arithmetic_type< T > Matrix_t< n, m, T, Algebra< SU< N, T > > >::norm ( ) const
inlineinherited

Calculate vector norm - sqrt of squarenorm.

Template Parameters
S
Returns
hila::arithmetic_type<T>

Definition at line 1133 of file matrix.h.

◆ operator!=()

bool Matrix_t< n, m, T, Algebra< SU< N, T > > >::operator!= ( const Matrix< n, m, S > &  rhs) const
inlineinherited

Boolean operator != to check if matrices are exactly different.

if matrices are exactly the same then this will return false

Template Parameters
SType for MAtrix which is being compared to
Parameters
rhsright hand side Matrix which we are comparing
Returns
true
false

Definition at line 544 of file matrix.h.

◆ operator*=()

auto & Matrix_t< n, m, T, Algebra< SU< N, T > > >::operator*= ( const Matrix_t< m, p, S, MT > &  rhs) &
inlineinherited

Multiply assign scalar or matrix.

Multiplication works as defined for matrix multiplication and scalar matrix multiplication.

Matrix multiply assign only defined for square matrices, since the matrix dimensions would change otherwise.

Multiply assign operator can be used in the following ways

Multiply assign matrix:

.
. Fill matrices M and N
.
M *= N; \\ M = M*N

Multiply assign scalar:

.
. Fill whole matrix with 1
.
M *= 2 ; \\ M is filled with 2
Parameters
rhsMatrix to multiply with
Returns
template <int p, typename S, typename MT, std::enable_if_t<hila::is_assignable<T &, hila::type_mul<T, S>>::value, int> = 0>&

Definition at line 796 of file matrix.h.

◆ operator+()

const auto & Matrix_t< n, m, T, Algebra< SU< N, T > > >::operator+ ( ) const
inlineinherited

Unary + operator.

Equivalent to identity operator meaning that matrix stays as is.

Returns
const Mtype&

Definition at line 507 of file matrix.h.

◆ operator+=() [1/2]

auto & Matrix_t< n, m, T, Algebra< SU< N, T > > >::operator+= ( const DiagonalMatrix< n, S > &  rhs) &
inlineinherited

add and sub assign a DiagonalMatrix

This is possible only for square matrices

Definition at line 877 of file matrix.h.

◆ operator+=() [2/2]

auto & Matrix_t< n, m, T, Algebra< SU< N, T > > >::operator+= ( const Matrix_t< n, m, S, MT > &  rhs) &
inlineinherited

Add assign operator with matrix or scalar.

Add assign operator can be used in the following ways

Add assign matrix:

M = 1;
N = 1;
M += N; \\M = 2*I
constexpr Imaginary_t< double > I(1.0)
Imaginary unit I - global variable.

Add assign scalar:

Adds scalar \( a \) to square matrix as \( M + a\cdot\mathbb{1} \)

M += 1 ; \\ M = 2*I
Template Parameters
SElement type of rhs
MTMatrix type of rhs
Parameters
rhsMatrix to add
Returns
Mtype&

Definition at line 690 of file matrix.h.

◆ operator-()

Algebra< SU< N, T > > Matrix_t< n, m, T, Algebra< SU< N, T > > >::operator- ( ) const
inlineinherited

Unary - operator.

casting from one Matrix (number) type to another: do not do this automatically. but require an explicit cast operator. This makes it easier to write code. or should it be automatic? keep/remove explicit? TODO: CHECK AVX CONVERSIONS

Returns matrix with the signs of all the elements in the Matrix flipped.

Returns
Mtype

Definition at line 493 of file matrix.h.

◆ operator-=()

auto & Matrix_t< n, m, T, Algebra< SU< N, T > > >::operator-= ( const Matrix_t< n, m, S, MT > &  rhs) &
inlineinherited

Subtract assign operator with matrix or scalar.

Subtract assign operator can be used in the following ways

Subtract assign matrix:

M = 3;
N = 1;
M -= N; \\M = 2*I

Subtract assign scalar:

Subtract scalar \( a \) to square matrix as \( M - a\cdot\mathbb{1} \)

M -= 1 ; \\ M = 2*I
Parameters
rhsMatrix to subtract with
Returns
template <typename S, typename MT, std::enable_if_t<hila::is_assignable<T &, S>::value, int> = 0>&

Definition at line 726 of file matrix.h.

◆ operator/=()

auto & Matrix_t< n, m, T, Algebra< SU< N, T > > >::operator/= ( const S  rhs) &
inlineinherited

Divide assign scalar.

Divide works as defined for scalar matrix division.

Division assign operator can be used in the following ways

Divide assign scalar:

.
. Fill whole matrix with 2
.
M /= 2 ; \\ M is filled with 1
Parameters
rhsMatrix to divide with
Returns
template <int p, typename S, typename MT, std::enable_if_t<hila::is_assignable<T &, hila::type_mul<T, S>>::value, int> = 0>&

Definition at line 863 of file matrix.h.

◆ operator==()

bool Matrix_t< n, m, T, Algebra< SU< N, T > > >::operator== ( const Matrix< n2, m2, S > &  rhs) const
inlineinherited

Boolean operator == to determine if two matrices are exactly the same.

Tolerance for equivalence is zero, meaning that the matrices must be exactly the same.

Template Parameters
SType for Matrix which is being compared to
Parameters
rhsright hand side Matrix which we are comparing
Returns
true
false

Definition at line 522 of file matrix.h.

◆ operator[]()

T Matrix_t< n, m, T, Algebra< SU< N, T > > >::operator[] ( const int  i) const
inlineinherited

Indexing operation [] defined only for vectors.

Example:

MyType a = V[i] \\ i <= n
Template Parameters
qrow size n
pcolumn size m
Parameters
irow or vector index depending on which is being indexed
Returns
T

Definition at line 327 of file matrix.h.

◆ outer_product()

Matrix< n, p, R > Matrix_t< n, m, T, Algebra< SU< N, T > > >::outer_product ( const Matrix< p, q, S > &  rhs) const
inlineinherited

Outer product.

Only works between two Vector objects

.
.
.
V.outer_product(W); \\ Valid operation
Matrix< n, p, R > outer_product(const Matrix< p, q, S > &rhs) const
Outer product.
Definition matrix.h:1263
.
.
.
V.outer_product(W); // not valid operation
Template Parameters
pRow length for rhs
qColumn length for rhs
SElement type for rhs
RType between lhs and rhs multiplication
Parameters
rhsVector to compute outer product with
Returns
Matrix<n, p, R>

Definition at line 1263 of file matrix.h.

◆ permute()

Algebra< SU< N, T > > Matrix_t< n, m, T, Algebra< SU< N, T > > >::permute ( const Vector< N, int > &  permutation) const
inlineinherited

Permute elements of vector.

Reordering is done based off of permutation vector

Parameters
permutationVector of integers to permute rows
Returns
Mtype

Definition at line 1377 of file matrix.h.

◆ permute_columns()

Algebra< SU< N, T > > Matrix_t< n, m, T, Algebra< SU< N, T > > >::permute_columns ( const Vector< m, int > &  permutation) const
inlineinherited

permute columns of Matrix

Reordering is done based off of permutation vector

Parameters
permutationVector of integers to permute columns
Returns
Mtype

Definition at line 1347 of file matrix.h.

◆ permute_rows()

Algebra< SU< N, T > > Matrix_t< n, m, T, Algebra< SU< N, T > > >::permute_rows ( const Vector< n, int > &  permutation) const
inlineinherited

permute rows of Matrix

Reordering is done based off of permutation vector

Parameters
permutationVector of integers to permute rows
Returns
Mtype

Definition at line 1361 of file matrix.h.

◆ random()

Algebra< SU< N, T > > & Matrix_t< n, m, T, Algebra< SU< N, T > > >::random ( )
inlineinherited

dot with matrix - matrix

Generate random elements

Fills Matrix with random elements

Works only for real valued elements such as float or double

Returns
Mtype&

Definition at line 1296 of file matrix.h.

◆ real()

Matrix< n, m, hila::arithmetic_type< T > > Matrix_t< n, m, T, Algebra< SU< N, T > > >::real ( ) const
inlineinherited

Returns real part of Matrix or Vector.

Returns
Matrix<n, m, hila::arithmetic_type<T>>

Definition at line 1051 of file matrix.h.

◆ row()

RowVector< m, T > Matrix_t< n, m, T, Algebra< SU< N, T > > >::row ( int  r) const
inlineinherited

Return row of a matrix as a RowVector.

Parameters
rindex of row to be referenced
Returns
const RowVector<m, T>&

Definition at line 342 of file matrix.h.

◆ rows()

static constexpr int Matrix_t< n, m, T, Algebra< SU< N, T > > >::rows ( )
inlinestaticconstexprinherited

Define constant methods rows(), columns() - may be useful in template code.

Returns row length

Returns
constexpr int

Definition at line 226 of file matrix.h.

◆ set_column()

void Matrix_t< n, m, T, Algebra< SU< N, T > > >::set_column ( int  c,
const Vector< n, S > &  v 
)
inlineinherited

get column of a matrix

Set column of Matrix with Vector if types are assignable

Template Parameters
SVector type
Parameters
cIndex of column to be set
vVector to be set

Definition at line 395 of file matrix.h.

◆ set_diagonal()

void Matrix_t< n, m, T, Algebra< SU< N, T > > >::set_diagonal ( const Vector< n, S > &  v)
inlineinherited

Set diagonal of square matrix to Vector which is passed to the method.

If called for non square matrix the program will throw an error.

Example:

SquareMatrix<n,MyType> S = 0; \\ Zero matrix
Vector<n,MyType> V = 1; \\ Vector assigned to 1 at all elements
S.set_diagonal(V); \\ Results in Identity matrix of size n
void set_diagonal(const Vector< n, S > &v)
Set diagonal of square matrix to Vector which is passed to the method.
Definition matrix.h:430
static constexpr int size()
Returns size of Vector or square Matrix.
Definition matrix.h:248
Template Parameters
Stype vector to assign values to
Parameters
vVector to assign to diagonal

Definition at line 430 of file matrix.h.

◆ set_row()

void Matrix_t< n, m, T, Algebra< SU< N, T > > >::set_row ( int  r,
const RowVector< m, S > &  v 
)
inlineinherited

Set row of Matrix with RowVector if types are assignable.

Template Parameters
SRowVector type
Parameters
rIndex of row to be set
vRowVector to be set

Definition at line 357 of file matrix.h.

◆ size()

static constexpr int Matrix_t< n, m, T, Algebra< SU< N, T > > >::size ( )
inlinestaticconstexprinherited

Returns size of Vector or square Matrix.

Template Parameters
qrow size n
pcolumn size m
Returns
constexpr int

Definition at line 248 of file matrix.h.

◆ sort()

Algebra< SU< N, T > > Matrix_t< n, m, T, Algebra< SU< N, T > > >::sort ( Vector< N, int > &  permutation,
hila::sort  order = hila::sort::ascending 
) const
inlineinherited

Sort method for Vector.

Two interfaces: first returns permutation vector, which can be used to permute other vectors/matrices second does only sort

Direct sort:

V.random();
V.sort(); // V is sorted
Mtype & random()
dot with matrix - matrix
Definition matrix.h:1296
Mtype sort(Vector< N, int > &permutation, hila::sort order=hila::sort::ascending) const
Sort method for Vector.
Definition matrix.h:1416

Permutation vector:

V.random();
V.sort(perm);
V.permute(perm); // V is sorted
Mtype permute(const Vector< N, int > &permutation) const
Permute elements of vector.
Definition matrix.h:1377

Definition at line 1416 of file matrix.h.

◆ squarenorm()

hila::arithmetic_type< T > Matrix_t< n, m, T, Algebra< SU< N, T > > >::squarenorm ( ) const
inlineinherited

Calculate square norm - sum of squared elements.

Returns
hila::arithmetic_type<T>

Definition at line 1117 of file matrix.h.

◆ str()

std::string Matrix_t< n, m, T, Algebra< SU< N, T > > >::str ( int  prec = 8,
char  separator = ' ' 
) const
inlineinherited

Convert to string for printing

Definition at line 1587 of file matrix.h.

◆ svd() [1/2]

svd_result< Algebra< SU< N, T > > > Matrix_t< n, m, T, Algebra< SU< N, T > > >::svd ( enum hila::sort  sorted = hila::sort::unsorted) const
inherited

svd and svd_pivot - alternative interface

svd(hila::sort [optional]) returns struct svd_result<Mtype>, with fields U: nxn unitary matrix singularvalues: DiagonalMatrix of singular values (real, > 0) V: nxn unitary matrix

auto res = M.svd(); now res.U : nxn unitary res.singularvalues : DiagonalMatrix of singular values res.V : nxn unitary

result satifies M = res.U res.singularvalues res.V.dagger()

Definition at line 1571 of file matrix_linalg.h.

◆ svd() [2/2]

int Matrix_t< n, m, T, Algebra< SU< N, T > > >::svd ( Matrix_t< n, n, Mt, MT > &  _U,
DiagonalMatrix< n, Et > &  _S,
Matrix_t< n, n, Mt, MT > &  _V,
enum hila::sort  sorted = hila::sort::unsorted 
) const
inherited

Singular value decomposition: divide matrix A = U S V*, where U,V unitary and S diagonal matrix of real singular values. Unpivoted Jacobi rotations.

Unpivoted rotation is generally faster than pivoted (esp. on gpu), but a bit less accurate

Use: M.svd(U, S, V, [sorted]);

Result satisfies M = U S V.dagger()

The algorithm works by one-sided Jacobi rotations.

  • U = V = 1
  • Loop
    • for i=0..(n-2); j=(i+1)..(n-1)
      • calculate B_ii, B_ij, B_jj, (B_ij = (A^* A)_ij)
      • If B_ij > 0
        • diagonalize J^* [ B_ii B_ij ] J = diag(D_ii, D_jj) [ B_ji B_jj ]
        • A <- A J , Columns i and j change
        • V <- V J
    • endfor
    • if nothing changed, break Loop
  • Endloop Now A = U S, A^* A = S* S = S^2
  • S_ii = A_ii / |A_i| (norm of column i)
  • U = A / S

Definition at line 1567 of file matrix_linalg.h.

◆ svd_pivot()

int Matrix_t< n, m, T, Algebra< SU< N, T > > >::svd_pivot ( Matrix_t< n, n, Mt, MT > &  _U,
DiagonalMatrix< n, Et > &  _S,
Matrix_t< n, n, Mt, MT > &  _V,
enum hila::sort  sorted = hila::sort::unsorted 
) const
inherited

Singular value decomposition: divide matrix A = U S V*, where U,V unitary and S diagonal matrix of real singular values. Fully pivoted Jacobi rotations.

Use: M.svd_pivot(U, S, V, [sorted]);

The algorithm works by one-sided Jacobi rotations.

  • U = V = 1
  • Compute Gram matrix B = A^* A. B is Hermitean, with B_ii >= 0.
  • Loop:
    • Find largest B_ij, j > i - full pivoting if |B_ij|^2 <= tol * B_ii B_jj we're done
    • find J to diagonalize J^* [ B_ii B_ij ] J = diag(D_ii, D_jj) [ B_ji B_jj ]
    • A <- A J , Columns i and j change
    • V <- V J
    • Recompute B_ik and B_jk, k /= i,j (B_ii = D_ii, B_jj = D_jj, B_ij = 0) (n^2)
  • Endloop Now A = U S, A^* A = S* S = S^2
  • S_ii = A_ii / |A_i| (norm of column i)
  • U = A / S
Parameters
U

Definition at line 1576 of file matrix_linalg.h.

◆ trace()

T Matrix_t< n, m, T, Algebra< SU< N, T > > >::trace ( ) const
inlineinherited

Computes Trace for Matrix.

Not define for non square matrices. Static assert will stop code from compiling if executed for non square matrices.

Returns
T

Definition at line 1079 of file matrix.h.

◆ transpose() [1/2]

Rtype Matrix_t< n, m, T, Algebra< SU< N, T > > >::transpose ( ) const
inlineinherited

Transpose of matrix.

Return type for square matrix is same input, for non square return type is Matrix<n,m,MyType>

Template Parameters
mm
std::conditional<n,Mtype,Matrix<m,n,T>>::type
Returns
const Rtype

Definition at line 954 of file matrix.h.

◆ transpose() [2/2]

const RowVector< n, T > & Matrix_t< n, m, T, Algebra< SU< N, T > > >::transpose ( ) const
inlineinherited

Transpose of vector.

Returns reference

Template Parameters
mm
Returns
const RowVector<n, T>&

Definition at line 971 of file matrix.h.


The documentation for this class was generated from the following file: