Documentation
¶
Overview ¶
Package liealgebra implements computational tools for Lie algebras and root systems using only the Go standard library.
The package is organised around a handful of small, self-contained numeric types and a large collection of genuinely distinct operations on them:
Dense real and complex matrices (Matrix, CMatrix) with the arithmetic needed for matrix Lie algebras: addition, multiplication, transpose, conjugate transpose, trace, Frobenius norm, LU based determinant, inverse and linear solve.
The Lie bracket (commutator) Bracket and anticommutator, the adjoint action AdjointAction, the Jacobi identity residual and test (JacobiResidual, SatisfiesJacobi), structure constants (StructureConstants), the Killing form (KillingForm, KillingFormValue) and the trace form, together with semisimplicity tests.
Concrete generators of the low dimensional Lie algebras: sl(2) with its standard E, F, H basis (SL2Generators), so(3) rotation generators (SO3Generators), su(2) via the Pauli matrices (SU2Generators, PauliMatrices), su(3) via the Gell-Mann matrices (GellMannMatrices), and arbitrary spin-j representations (SpinMatrices).
The exponential map for matrices (MatExp, CMatExp) implemented with scaling and squaring and a diagonal Padé approximant, plus integer powers and the leading Baker-Campbell-Hausdorff terms.
Root system combinatorics for the classical families A, B, C and D and the exceptional types: Cartan matrices (CartanMatrix), simple and positive roots (SimpleRoots, PositiveRoots), fundamental weights, Weyl group orders (WeylGroupOrder), Coxeter numbers, Dynkin diagram adjacency, Weyl reflections and the Weyl dimension and Casimir formulas.
All computation is deterministic. Operations that can fail (dimension mismatches, singular systems, unknown Dynkin types) return a sentinel error such as ErrDim, ErrSingular or ErrType; a few pure accessors panic on out-of-range indices.
Index ¶
- Variables
- func AdjointDimension(family string, rank int) (int, error)
- func AllRoots(family string, rank int) ([][]float64, error)
- func CTraceForm(a, b *CMatrix) (complex128, error)
- func CartanInteger(alpha, beta []float64) (float64, error)
- func CartanMatrixDeterminant(family string, rank int) (float64, error)
- func CasimirEigenvalue(family string, rank int, dynkin []int) (float64, error)
- func CasimirSU2(j float64) float64
- func CasimirTraceNormalization(basis []*Matrix) (float64, error)
- func Coroot(root []float64) ([]float64, error)
- func CoxeterNumber(family string, rank int) (int, error)
- func Det(m *Matrix) (float64, error)
- func DimensionSLn(n int) (int, error)
- func DimensionSOn(n int) (int, error)
- func DimensionSPn(n int) (int, error)
- func DimensionSU2(j float64) (int, error)
- func DimensionSUn(n int) (int, error)
- func DualCoxeterFromRoots(family string, rank int) (int, error)
- func DualCoxeterNumber(family string, rank int) (int, error)
- func FundamentalWeightsRootBasis(family string, rank int) ([][]float64, error)
- func HighestRootLabel(family string, rank int) ([]int, error)
- func IsAbelian(basis []*Matrix, tol float64) bool
- func IsClosedUnderBracket(basis []*Matrix, tol float64) bool
- func IsNilpotentMatrix(m *Matrix, tol float64) (bool, error)
- func IsSemisimple(basis []*Matrix, tol float64) (bool, error)
- func IsSimplyLaced(family string, rank int) (bool, error)
- func JacobiResidualConstants(c [][][]float64) float64
- func KillingFormRank(basis []*Matrix, tol float64) (int, error)
- func KillingFormValue(basis []*Matrix, x, y []float64) (float64, error)
- func LieAlgebraDimension(family string, rank int) (int, error)
- func LieAlgebraName(family string, rank int) (string, error)
- func NumPositiveRoots(family string, rank int) (int, error)
- func NumRoots(family string, rank int) (int, error)
- func PositiveRootLabels(family string, rank int) ([][]int, error)
- func PositiveRoots(family string, rank int) ([][]float64, error)
- func Rank(m *Matrix, tol float64) int
- func RootInnerProduct(b *Matrix, x, y []float64) (float64, error)
- func SO3ToVector(m *Matrix) ([]float64, error)
- func SatisfiesJacobi(a, b, c *Matrix, tol float64) bool
- func SimpleRoots(family string, rank int) ([][]float64, error)
- func Solve(a *Matrix, b []float64) ([]float64, error)
- func SolveLeastSquares(a *Matrix, b []float64) ([]float64, error)
- func SpectralRadiusBound(m *Matrix) float64
- func StructureConstants(basis []*Matrix) ([][][]float64, error)
- func TraceForm(a, b *Matrix) (float64, error)
- func VecAdd(a, b []float64) ([]float64, error)
- func VecDot(a, b []float64) (float64, error)
- func VecEqual(a, b []float64, tol float64) bool
- func VecNorm(a []float64) float64
- func VecNormSquared(a []float64) float64
- func VecScale(a []float64, s float64) []float64
- func VecSub(a, b []float64) ([]float64, error)
- func WeylDimension(family string, rank int, dynkin []int) (int, error)
- func WeylGroupOrder(family string, rank int) (*big.Int, error)
- func WeylOrbit(simple [][]float64, v []float64, tol float64) ([][]float64, error)
- func WeylReflection(root, v []float64) ([]float64, error)
- func WeylVectorRootBasis(family string, rank int) ([]float64, error)
- type CMatrix
- func CAnticommutator(a, b *CMatrix) (*CMatrix, error)
- func CBracket(a, b *CMatrix) (*CMatrix, error)
- func CMatExp(a *CMatrix) (*CMatrix, error)
- func CMatPow(a *CMatrix, p int) (*CMatrix, error)
- func DiagCMatrix(d []complex128) *CMatrix
- func GellMannMatrices() []*CMatrix
- func GellMannMatrix(i int) *CMatrix
- func IdentityCMatrix(n int) *CMatrix
- func NewCMatrix(rows, cols int) *CMatrix
- func NewCMatrixFromRows(rows [][]complex128) (*CMatrix, error)
- func PauliMatrices() (sx, sy, sz *CMatrix)
- func PauliX() *CMatrix
- func PauliY() *CMatrix
- func PauliZ() *CMatrix
- func RealToComplex(m *Matrix) *CMatrix
- func SU2Generators() (t1, t2, t3 *CMatrix)
- func SU2SpinMatrices() (sx, sy, sz *CMatrix)
- func SU3Generators() []*CMatrix
- func SpinJz(j float64) (*CMatrix, error)
- func SpinLowering(j float64) (*CMatrix, error)
- func SpinMatrices(j float64) (jx, jy, jz *CMatrix, err error)
- func SpinRaising(j float64) (*CMatrix, error)
- func (m *CMatrix) Add(b *CMatrix) (*CMatrix, error)
- func (m *CMatrix) AntiHermitianPart() (*CMatrix, error)
- func (m *CMatrix) ApproxEqual(b *CMatrix, tol float64) bool
- func (m *CMatrix) At(i, j int) complex128
- func (m *CMatrix) Clone() *CMatrix
- func (m *CMatrix) Conjugate() *CMatrix
- func (m *CMatrix) ConjugateTranspose() *CMatrix
- func (m *CMatrix) Dagger() *CMatrix
- func (m *CMatrix) Dims() (int, int)
- func (m *CMatrix) Equal(b *CMatrix) bool
- func (m *CMatrix) FrobeniusNorm() float64
- func (m *CMatrix) HermitianPart() (*CMatrix, error)
- func (m *CMatrix) Imag() *Matrix
- func (m *CMatrix) IsAntiHermitian(tol float64) bool
- func (m *CMatrix) IsHermitian(tol float64) bool
- func (m *CMatrix) IsSquare() bool
- func (m *CMatrix) IsTraceless(tol float64) bool
- func (m *CMatrix) IsUnitary(tol float64) bool
- func (m *CMatrix) Kronecker(b *CMatrix) *CMatrix
- func (m *CMatrix) MaxAbs() float64
- func (m *CMatrix) Mul(b *CMatrix) (*CMatrix, error)
- func (m *CMatrix) Neg() *CMatrix
- func (m *CMatrix) Real() *Matrix
- func (m *CMatrix) Scale(s complex128) *CMatrix
- func (m *CMatrix) Set(i, j int, v complex128)
- func (m *CMatrix) Sub(b *CMatrix) (*CMatrix, error)
- func (m *CMatrix) Trace() (complex128, error)
- func (m *CMatrix) Transpose() *CMatrix
- type Matrix
- func AdjointAction(x, y *Matrix) (*Matrix, error)
- func AdjointMatrix(basis []*Matrix, index int) (*Matrix, error)
- func Anticommutator(a, b *Matrix) (*Matrix, error)
- func BCHApprox(x, y *Matrix) (*Matrix, error)
- func Bracket(a, b *Matrix) (*Matrix, error)
- func CartanMatrix(family string, rank int) (*Matrix, error)
- func CartanMatrixA(n int) (*Matrix, error)
- func CartanMatrixB(n int) (*Matrix, error)
- func CartanMatrixC(n int) (*Matrix, error)
- func CartanMatrixD(n int) (*Matrix, error)
- func CartanMatrixFromRoots(simple [][]float64) (*Matrix, error)
- func DiagMatrix(d []float64) *Matrix
- func DynkinBondMatrix(family string, rank int) (*Matrix, error)
- func DynkinDiagramAdjacency(family string, rank int) (*Matrix, error)
- func ExpBracketSeries(x, y *Matrix, terms int) (*Matrix, error)
- func ExpMap(a *Matrix) (*Matrix, error)
- func HeisenbergGenerators() (x, y, z *Matrix)
- func IdentityMatrix(n int) *Matrix
- func Inverse(m *Matrix) (*Matrix, error)
- func InverseCartanMatrix(family string, rank int) (*Matrix, error)
- func JacobiResidual(a, b, c *Matrix) (*Matrix, error)
- func KillingForm(basis []*Matrix) (*Matrix, error)
- func MatExp(a *Matrix) (*Matrix, error)
- func MatPow(a *Matrix, p int) (*Matrix, error)
- func NestedBracket(xs ...*Matrix) (*Matrix, error)
- func NewMatrix(rows, cols int) *Matrix
- func NewMatrixFromRows(rows [][]float64) (*Matrix, error)
- func RootBilinearForm(family string, rank int) (*Matrix, error)
- func SL2CartanH() *Matrix
- func SL2Generators() (e, f, h *Matrix)
- func SL2LoweringF() *Matrix
- func SL2RaisingE() *Matrix
- func SO3FromVector(w []float64) (*Matrix, error)
- func SO3Generators() (lx, ly, lz *Matrix)
- func WeylReflectionMatrix(root []float64) (*Matrix, error)
- func ZeroMatrix(n int) *Matrix
- func (m *Matrix) Add(b *Matrix) (*Matrix, error)
- func (m *Matrix) AntiSymmetrize() (*Matrix, error)
- func (m *Matrix) ApproxEqual(b *Matrix, tol float64) bool
- func (m *Matrix) At(i, j int) float64
- func (m *Matrix) Clone() *Matrix
- func (m *Matrix) Col(j int) []float64
- func (m *Matrix) Dims() (int, int)
- func (m *Matrix) Equal(b *Matrix) bool
- func (m *Matrix) FrobeniusNorm() float64
- func (m *Matrix) IsAntisymmetric(tol float64) bool
- func (m *Matrix) IsDiagonal(tol float64) bool
- func (m *Matrix) IsSquare() bool
- func (m *Matrix) IsSymmetric(tol float64) bool
- func (m *Matrix) IsTraceless(tol float64) bool
- func (m *Matrix) Kronecker(b *Matrix) *Matrix
- func (m *Matrix) MatVec(x []float64) ([]float64, error)
- func (m *Matrix) MaxAbs() float64
- func (m *Matrix) Mul(b *Matrix) (*Matrix, error)
- func (m *Matrix) Neg() *Matrix
- func (m *Matrix) Row(i int) []float64
- func (m *Matrix) Scale(s float64) *Matrix
- func (m *Matrix) Set(i, j int, v float64)
- func (m *Matrix) Sub(b *Matrix) (*Matrix, error)
- func (m *Matrix) Symmetrize() (*Matrix, error)
- func (m *Matrix) Trace() (float64, error)
- func (m *Matrix) Transpose() *Matrix
- func (m *Matrix) Vec() []float64
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDim indicates a shape or dimension mismatch between operands. ErrDim = errors.New("liealgebra: dimension mismatch") // ErrNotSquare indicates that a square matrix was required. ErrNotSquare = errors.New("liealgebra: matrix is not square") // ErrSingular indicates a singular (non-invertible) linear system. ErrSingular = errors.New("liealgebra: singular matrix") // ErrRank indicates a rank-deficient or linearly dependent basis. ErrRank = errors.New("liealgebra: rank deficient basis") // ErrType indicates an unknown or unsupported Dynkin/Cartan type. ErrType = errors.New("liealgebra: unknown Dynkin type") // ErrRange indicates an out-of-range rank or index argument. ErrRange = errors.New("liealgebra: argument out of range") )
Sentinel errors returned throughout the package.
Functions ¶
func AdjointDimension ¶
AdjointDimension returns the dimension of the adjoint representation, which equals the dimension of the Lie algebra itself.
func AllRoots ¶
AllRoots returns all roots (positive together with their negatives) of a classical type as Euclidean coordinate vectors.
func CTraceForm ¶
func CTraceForm(a, b *CMatrix) (complex128, error)
CTraceForm returns the complex trace form tr(AB) of two complex matrices.
func CartanInteger ¶
CartanInteger returns the Cartan integer ⟨α,β∨⟩ = 2(α,β)/(β,β) of two Euclidean root vectors.
func CartanMatrixDeterminant ¶
CartanMatrixDeterminant returns the determinant of the Cartan matrix, an important invariant equal to the order of the center of the simply connected group (the index of the root lattice in the weight lattice).
func CasimirEigenvalue ¶
CasimirEigenvalue returns the eigenvalue of the quadratic Casimir operator on the irreducible representation with the given highest weight (Dynkin labels), computed as (λ, λ+2ρ) in the normalisation where the long roots have squared length 2. It returns ErrDim if the label count does not match the rank.
func CasimirSU2 ¶
CasimirSU2 returns the physics-convention quadratic Casimir eigenvalue j(j+1) of the spin-j irreducible representation of su(2).
func CasimirTraceNormalization ¶
CasimirTraceNormalization returns the constant c such that the Killing form equals c times the trace form on the defining representation, given a basis; it is computed as the ratio of the (0,0) entries of the two Gram matrices and returns ErrRange when the trace form entry is zero.
func CoxeterNumber ¶
CoxeterNumber returns the Coxeter number h of the given Dynkin type, equal to (number of roots)/rank and to one plus the height of the highest root.
func DimensionSLn ¶
DimensionSLn returns the dimension n^2-1 of the Lie algebra sl(n) = A_{n-1}.
func DimensionSOn ¶
DimensionSOn returns the dimension n(n-1)/2 of the Lie algebra so(n).
func DimensionSPn ¶
DimensionSPn returns the dimension n(2n+1) of the Lie algebra sp(2n) = C_n.
func DimensionSU2 ¶
DimensionSU2 returns the dimension 2j+1 of the spin-j representation of su(2). It returns ErrRange if 2j is not a nonnegative integer.
func DimensionSUn ¶
DimensionSUn returns the dimension n^2-1 of the Lie algebra su(n).
func DualCoxeterFromRoots ¶
DualCoxeterFromRoots returns the dual Coxeter number computed as 1 + (ρ, θ∨) where θ is the highest root; provided as an independent cross-check of DualCoxeterNumber for classical and exceptional types.
func DualCoxeterNumber ¶
DualCoxeterNumber returns the dual Coxeter number h∨ of the given Dynkin type.
func FundamentalWeightsRootBasis ¶
FundamentalWeightsRootBasis returns the fundamental weights expressed in the basis of simple roots; row i is ω_i. They are the rows of the inverse Cartan matrix.
func HighestRootLabel ¶
HighestRootLabel returns the coefficient vector (in the simple-root basis) of the highest root, the unique positive root of maximal height.
func IsAbelian ¶
IsAbelian reports whether every pair of basis elements commutes to within tolerance tol, i.e. whether the spanned Lie algebra is abelian.
func IsClosedUnderBracket ¶
IsClosedUnderBracket reports whether the bracket of every pair of basis elements lies in the span of the basis to within tolerance tol, i.e. whether the basis spans a Lie subalgebra.
func IsNilpotentMatrix ¶
IsNilpotentMatrix reports whether the square matrix m is nilpotent, i.e. some power m^k (k up to its dimension) vanishes to within tolerance tol.
func IsSemisimple ¶
IsSemisimple reports whether the Killing form of the given basis is nondegenerate (Cartan's criterion), tested by |det K| > tol.
func IsSimplyLaced ¶
IsSimplyLaced reports whether the Dynkin type is simply laced, i.e. all bonds are single (types A, D, E).
func JacobiResidualConstants ¶
JacobiResidualConstants returns the maximum absolute value of the Jacobi identity applied to structure constants: Σ_m ( c[m][i][j] c[n][m][k] + c[m][j][k] c[n][m][i] + c[m][k][i] c[n][m][j] ). It is zero for a genuine Lie algebra and provides a coordinate-space Jacobi check independent of the matrix realisation.
func KillingFormRank ¶
KillingFormRank returns the rank of the Killing form of a basis. It equals the dimension of the algebra for a semisimple Lie algebra and is smaller when the radical is nonzero.
func KillingFormValue ¶
KillingFormValue returns the Killing form value K(X,Y) = tr(ad_X ad_Y) for two elements X and Y given by their coordinate vectors in the supplied basis.
func LieAlgebraDimension ¶
LieAlgebraDimension returns the dimension of the semisimple Lie algebra of the given type, equal to rank + number of roots.
func LieAlgebraName ¶
LieAlgebraName returns a human-readable classical name for the given Dynkin type, such as "sl(4)" for A_3 or "so(7)" for B_3.
func NumPositiveRoots ¶
NumPositiveRoots returns the number of positive roots of the given type.
func PositiveRootLabels ¶
PositiveRootLabels returns every positive root of the given type expressed as an integer coefficient vector in the basis of simple roots. The algorithm is the standard height-by-height root-string construction driven by the Cartan matrix and works uniformly for classical and exceptional types.
func PositiveRoots ¶
PositiveRoots returns the positive roots of a classical type as Euclidean coordinate vectors. It returns ErrType for exceptional types.
func Rank ¶
Rank returns the numerical rank of a matrix using Gaussian elimination with the given tolerance for treating a pivot as zero.
func RootInnerProduct ¶
RootInnerProduct returns the inner product of two vectors expressed in the simple-root basis using the bilinear form B (see RootBilinearForm).
func SO3ToVector ¶
SO3ToVector maps a 3x3 antisymmetric matrix to its axial vector (w) such that the matrix acts as w×. It returns ErrDim if the matrix is not 3x3.
func SatisfiesJacobi ¶
SatisfiesJacobi reports whether the Jacobi identity holds for A, B, C to within tolerance tol (measured by the max absolute entry of the residual).
func SimpleRoots ¶
SimpleRoots returns the simple roots of a classical type (A, B, C or D) as Euclidean coordinate vectors. Type A_n lives in R^(n+1) with α_i = e_i-e_{i+1}; types B_n, C_n and D_n live in R^n. It returns ErrType for exceptional types (use PositiveRootLabels for those).
func Solve ¶
Solve solves the linear system A x = b for a square A. It returns ErrSingular if A is not invertible and ErrDim on a length mismatch.
func SolveLeastSquares ¶
SolveLeastSquares solves the (possibly overdetermined) system A x = b in the least-squares sense via the normal equations AᵀA x = Aᵀb. It requires A to have full column rank and returns ErrRank otherwise.
func SpectralRadiusBound ¶
SpectralRadiusBound returns an upper bound on the spectral radius of a real matrix via the maximum absolute row sum (an induced ∞-norm).
func StructureConstants ¶
StructureConstants computes the structure constants c[k][i][j] of a matrix Lie algebra with the given basis, defined by [e_i, e_j] = Σ_k c[k][i][j] e_k. The basis matrices must be square, of equal size and linearly independent; otherwise ErrRank or ErrDim is returned. The bracket of any two basis elements must lie in the span of the basis (a genuine subalgebra).
func TraceForm ¶
TraceForm returns the trace form tr(AB) of two square matrices. For many matrix Lie algebras this is proportional to the Killing form.
func VecDot ¶
VecDot returns the Euclidean dot product of two equal-length vectors, or ErrDim on a length mismatch.
func VecNormSquared ¶
VecNormSquared returns the squared Euclidean norm of a vector.
func WeylDimension ¶
WeylDimension returns the dimension of the irreducible representation of the given Dynkin type with highest weight specified by nonnegative Dynkin labels (a_1,...,a_rank), via the Weyl dimension formula
dim = Π_{α>0} (λ+ρ, α) / (ρ, α).
The result is rounded to the nearest integer. It returns ErrDim if the number of labels does not match the rank.
Example ¶
ExampleWeylDimension prints the dimension of the adjoint representation of su(3), whose highest weight has Dynkin labels (1,1).
dim, _ := WeylDimension("A", 2, []int{1, 1})
fmt.Println(dim)
Output: 8
func WeylGroupOrder ¶
WeylGroupOrder returns the order of the Weyl group of the given Dynkin type as an arbitrary-precision integer.
Example ¶
ExampleWeylGroupOrder prints the order of the Weyl group of E8.
w, _ := WeylGroupOrder("E", 8)
fmt.Println(w.String())
Output: 696729600
func WeylOrbit ¶
WeylOrbit returns the orbit of a Euclidean vector v under the Weyl group generated by reflections in the given simple roots. It repeatedly applies all simple reflections until the orbit stabilises (finite for a genuine root system) and returns the distinct vectors within tolerance tol.
func WeylReflection ¶
WeylReflection returns the reflection of the vector v across the hyperplane orthogonal to root, s_root(v) = v - 2(v,root)/(root,root) root, in Euclidean coordinates. It returns ErrDim on a length mismatch or a zero root.
Types ¶
type CMatrix ¶
type CMatrix struct {
Rows int
Cols int
Data []complex128
}
CMatrix is a dense complex matrix stored in row-major order. Complex matrices are needed for the unitary Lie algebras su(n), whose generators are naturally complex. The zero value is not usable; construct with NewCMatrix.
func CAnticommutator ¶
CAnticommutator returns {A,B} = AB + BA of two complex matrices.
func CMatExp ¶
CMatExp returns the matrix exponential exp(A) of a square complex matrix by scaling and squaring with a truncated Taylor series.
func DiagCMatrix ¶
func DiagCMatrix(d []complex128) *CMatrix
DiagCMatrix returns the square complex matrix with the given diagonal.
func GellMannMatrices ¶
func GellMannMatrices() []*CMatrix
GellMannMatrices returns all eight Gell-Mann matrices λ_1..λ_8.
func GellMannMatrix ¶
GellMannMatrix returns the i-th Gell-Mann matrix, i in 1..8. These are the eight Hermitian traceless generators of su(3). It panics if i is out of range.
func IdentityCMatrix ¶
IdentityCMatrix returns the n-by-n complex identity matrix.
func NewCMatrix ¶
NewCMatrix returns a rows-by-cols zero complex matrix.
func NewCMatrixFromRows ¶
func NewCMatrixFromRows(rows [][]complex128) (*CMatrix, error)
NewCMatrixFromRows builds a complex matrix from equal-length rows, returning ErrDim if the rows are ragged.
func PauliMatrices ¶
func PauliMatrices() (sx, sy, sz *CMatrix)
PauliMatrices returns the three Pauli matrices (σ_x, σ_y, σ_z). They are Hermitian, traceless, unitary and satisfy σ_iσ_j = δ_ij I + i ε_ijk σ_k.
func RealToComplex ¶
RealToComplex promotes a real matrix to a complex matrix.
func SU2Generators ¶
func SU2Generators() (t1, t2, t3 *CMatrix)
SU2Generators returns the anti-Hermitian generators of su(2) given by T_i = -i σ_i / 2, satisfying [T_i, T_j] = ε_ijk T_k. These are the generators for which the exponential map lands in SU(2).
func SU2SpinMatrices ¶
func SU2SpinMatrices() (sx, sy, sz *CMatrix)
SU2SpinMatrices returns the Hermitian spin-1/2 operators (S_x, S_y, S_z) = (σ_x, σ_y, σ_z)/2 satisfying [S_i,S_j] = i ε_ijk S_k.
func SU3Generators ¶
func SU3Generators() []*CMatrix
SU3Generators returns the anti-Hermitian su(3) generators T_a = -i λ_a / 2 for a in 1..8.
func SpinLowering ¶
SpinLowering returns the lowering operator J- for spin j.
func SpinMatrices ¶
SpinMatrices returns the (2j+1)-dimensional Hermitian angular-momentum operators (Jx, Jy, Jz) for spin/quantum number j (a nonnegative half-integer such as 0.5, 1, 1.5, ...). They satisfy [Ji,Jj] = i ε_ijk Jk. It returns ErrRange if 2j is not a nonnegative integer.
func SpinRaising ¶
SpinRaising returns the raising operator J+ for spin j.
func (*CMatrix) AntiHermitianPart ¶
AntiHermitianPart returns (m-mᴴ)/2, the anti-Hermitian part.
func (*CMatrix) ApproxEqual ¶
ApproxEqual reports shape equality with every entry agreeing to within tol in complex modulus.
func (*CMatrix) At ¶
func (m *CMatrix) At(i, j int) complex128
At returns element (i,j), panicking on an out-of-range index.
func (*CMatrix) ConjugateTranspose ¶
ConjugateTranspose returns the Hermitian conjugate (dagger) mᴴ.
func (*CMatrix) Dagger ¶
Dagger is an alias for CMatrix.ConjugateTranspose.
func (*CMatrix) FrobeniusNorm ¶
FrobeniusNorm returns the square root of the sum of squared moduli.
func (*CMatrix) HermitianPart ¶
HermitianPart returns (m+mᴴ)/2, the Hermitian part of a square complex matrix.
func (*CMatrix) IsAntiHermitian ¶
IsAntiHermitian reports whether m equals the negative of its conjugate transpose within tol (a skew-Hermitian matrix, as in su(n)).
func (*CMatrix) IsHermitian ¶
IsHermitian reports whether m equals its conjugate transpose within tol.
func (*CMatrix) IsTraceless ¶
IsTraceless reports whether the trace is zero within tol.
func (*CMatrix) Kronecker ¶
Kronecker returns the Kronecker (tensor) product m ⊗ b of complex matrices.
func (*CMatrix) Scale ¶
func (m *CMatrix) Scale(s complex128) *CMatrix
Scale returns the matrix times the complex scalar s.
func (*CMatrix) Set ¶
func (m *CMatrix) Set(i, j int, v complex128)
Set assigns v to element (i,j), panicking on an out-of-range index.
func (*CMatrix) Trace ¶
func (m *CMatrix) Trace() (complex128, error)
Trace returns the sum of diagonal entries, or ErrNotSquare.
type Matrix ¶
type Matrix struct {
Rows int
Cols int
Data []float64 // len == Rows*Cols, element (i,j) at Data[i*Cols+j]
}
Matrix is a dense real matrix stored in row-major order. The zero value is not usable; construct matrices with NewMatrix and the related helpers.
func AdjointAction ¶
AdjointAction returns ad_X(Y) = [X,Y], the action of X in the adjoint representation on the matrix Y.
func AdjointMatrix ¶
AdjointMatrix returns the matrix of ad_{e_index} in the given basis: the d-by-d matrix M with M[k][j] = c[k][index][j] where c are the structure constants. Column j is the coordinate vector of [e_index, e_j].
func Anticommutator ¶
Anticommutator returns {A,B} = AB + BA of two square real matrices.
func BCHApprox ¶
BCHApprox returns the second-order Baker-Campbell-Hausdorff approximation to log(exp(X)exp(Y)):
X + Y + ½[X,Y] + (1/12)([X,[X,Y]] + [Y,[Y,X]]).
It is exact through third order in X and Y and is the standard truncation for small elements of a matrix Lie algebra.
func Bracket ¶
Bracket returns the Lie bracket (commutator) [A,B] = AB - BA of two square real matrices. It returns ErrDim if the shapes are incompatible.
Example ¶
ExampleBracket demonstrates the sl(2) commutation relation [E,F]=H.
e, f, h := SL2Generators() br, _ := Bracket(e, f) fmt.Println(br.Equal(h))
Output: true
func CartanMatrix ¶
CartanMatrix returns the Cartan matrix of the Lie algebra of the given Dynkin type. The family is one of "A","B","C","D" (classical) or "E","F","G" (exceptional); rank must be admissible. Entry A[i][j] equals 2(α_i,α_j)/(α_j,α_j) in the Bourbaki convention.
func CartanMatrixA ¶
CartanMatrixA returns the Cartan matrix of type A_n (the Lie algebra sl(n+1)).
func CartanMatrixB ¶
CartanMatrixB returns the Cartan matrix of type B_n (the Lie algebra so(2n+1)).
func CartanMatrixC ¶
CartanMatrixC returns the Cartan matrix of type C_n (the Lie algebra sp(2n)).
func CartanMatrixD ¶
CartanMatrixD returns the Cartan matrix of type D_n (the Lie algebra so(2n)).
func CartanMatrixFromRoots ¶
CartanMatrixFromRoots builds the Cartan matrix A[i][j] = 2(α_i,α_j)/(α_j,α_j) from a list of simple roots given as Euclidean coordinate vectors. It returns ErrDim if any root is zero or the coordinate lengths disagree.
func DiagMatrix ¶
DiagMatrix returns the square matrix with the given diagonal entries.
func DynkinBondMatrix ¶
DynkinBondMatrix returns the matrix B[i][j] = A[i][j]*A[j][i], whose value (0,1,2,3) counts the number of bonds between nodes i and j in the Dynkin diagram.
func DynkinDiagramAdjacency ¶
DynkinDiagramAdjacency returns the 0/1 adjacency matrix of the Dynkin diagram: nodes i and j are adjacent when the Cartan entry A[i][j] is nonzero.
func ExpBracketSeries ¶
ExpBracketSeries returns the truncated series for Ad_{exp(X)}(Y) = exp(ad_X)(Y) = Σ_{k≥0} (1/k!) ad_X^k(Y), summed to the given number of terms (terms>=1). This is the finite version of the identity exp(X)Y exp(-X).
func ExpMap ¶
ExpMap is an alias for MatExp; for a Lie-algebra element X it returns the corresponding group element exp(X).
func HeisenbergGenerators ¶
func HeisenbergGenerators() (x, y, z *Matrix)
HeisenbergGenerators returns the three matrices (X, Y, Z) generating the 3-dimensional Heisenberg Lie algebra of strictly upper-triangular 3x3 real matrices, satisfying [X,Y]=Z and [X,Z]=[Y,Z]=0.
func IdentityMatrix ¶
IdentityMatrix returns the n-by-n identity matrix.
func Inverse ¶
Inverse returns the matrix inverse, or ErrSingular if the matrix is not invertible.
func InverseCartanMatrix ¶
InverseCartanMatrix returns the inverse of the Cartan matrix. Its rows give the fundamental weights expressed in the basis of simple roots.
func JacobiResidual ¶
JacobiResidual returns [[A,B],C] + [[B,C],A] + [[C,A],B], which is identically the zero matrix for any associative product and hence for matrix Lie algebras. It is a convenient numerical check of the Jacobi identity.
func KillingForm ¶
KillingForm returns the Killing form matrix K of a Lie algebra given by a basis, with entries K[i][j] = tr(ad_{e_i} ad_{e_j}). The result is symmetric.
func MatExp ¶
MatExp returns the matrix exponential exp(A) of a square real matrix, computed by scaling and squaring with a truncated Taylor series. It returns ErrNotSquare for non-square input.
func MatPow ¶
MatPow returns A raised to a nonnegative integer power using exponentiation by squaring; A^0 is the identity. It returns ErrNotSquare for non-square input and ErrRange for a negative power.
func NestedBracket ¶
NestedBracket returns the left-nested bracket [x0,[x1,[...,xk]...]] for a list of matrices. An empty list returns ErrDim; a single element returns it.
func NewMatrixFromRows ¶
NewMatrixFromRows builds a matrix from a slice of equal-length rows. It returns ErrDim if the rows are ragged.
func RootBilinearForm ¶
RootBilinearForm returns the symmetric matrix B with B[i][j] = (α_i,α_j), the inner products of the simple roots normalised so that the longest roots have squared length 2. It is derived from the Cartan matrix and underlies the Weyl dimension and Casimir formulas.
func SL2Generators ¶
func SL2Generators() (e, f, h *Matrix)
SL2Generators returns the standard basis (E, F, H) of the Lie algebra sl(2) of traceless 2x2 real matrices, satisfying [H,E]=2E, [H,F]=-2F and [E,F]=H.
E = [[0,1],[0,0]], F = [[0,0],[1,0]], H = [[1,0],[0,-1]].
func SL2LoweringF ¶
func SL2LoweringF() *Matrix
SL2LoweringF returns the lowering generator F of sl(2).
func SO3FromVector ¶
SO3FromVector returns the 3x3 antisymmetric matrix [w]_× representing the cross product w×(·). It returns ErrDim unless w has length 3.
func SO3Generators ¶
func SO3Generators() (lx, ly, lz *Matrix)
SO3Generators returns the three real antisymmetric generators (Lx, Ly, Lz) of the rotation algebra so(3), satisfying [Lx,Ly]=Lz and cyclic permutations. Each Li is (L_i)_{jk} = -ε_{ijk}.
func WeylReflectionMatrix ¶
WeylReflectionMatrix returns the orthogonal matrix of the reflection across the hyperplane orthogonal to the given root in Euclidean coordinates.
func (*Matrix) AntiSymmetrize ¶
AntiSymmetrize returns (m-mᵀ)/2, the antisymmetric part of a square matrix.
func (*Matrix) ApproxEqual ¶
ApproxEqual reports whether a and b have the same shape and every entry agrees to within absolute tolerance tol.
func (*Matrix) FrobeniusNorm ¶
FrobeniusNorm returns the square root of the sum of squared entries.
func (*Matrix) IsAntisymmetric ¶
IsAntisymmetric reports whether m equals the negative of its transpose within tolerance tol (a real antisymmetric/skew matrix).
func (*Matrix) IsDiagonal ¶
IsDiagonal reports whether all off-diagonal entries vanish within tol.
func (*Matrix) IsSymmetric ¶
IsSymmetric reports whether m equals its transpose within tolerance tol.
func (*Matrix) IsTraceless ¶
IsTraceless reports whether the trace is zero within tolerance tol.
func (*Matrix) Symmetrize ¶
Symmetrize returns (m+mᵀ)/2, the symmetric part of a square matrix.
func (*Matrix) Trace ¶
Trace returns the sum of the diagonal entries. It returns ErrNotSquare for a non-square matrix.