grouprep

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package grouprep implements the ordinary representation theory of finite groups over the complex numbers, built entirely on the Go standard library.

A (matrix) representation of a finite group G is a homomorphism ρ: G → GL(d, ℂ) assigning to every group element an invertible d×d complex matrix such that ρ(gh) = ρ(g)ρ(h). This package provides the concrete data structures and algorithms of the classical theory: complex matrices (Matrix), finite groups given by their Cayley table (Group), matrix representations (Rep), characters (Character) and character tables (CharacterTable).

Groups

A Group is stored as an explicit multiplication (Cayley) table together with an inverse map and identity index. Standard families are provided: CyclicGroup, DihedralGroup, SymmetricGroup, AlternatingGroup, QuaternionGroup, KleinFourGroup, TrivialGroup and the DirectProduct of two groups. Structural queries include Group.ConjugacyClasses, Group.Center, Group.IsAbelian, Group.ElementOrder and subgroup closures via Group.GeneratedBy.

Representations

A Rep pins a group and a matrix for every element. Constructions include TrivialRep, RegularRep, CyclicRep, DihedralRep2D, NaturalRepSymmetric, SignRepSymmetric and QuaternionRep. Reps combine under Rep.DirectSum and Rep.TensorProduct and can be dualised with Rep.Dual. Every rep is validated as a genuine homomorphism.

Characters

The character of a rep is the trace class function χ(g) = tr ρ(g), obtained with Rep.Character. Characters live in the Hermitian inner product space of class functions with 〈χ, ψ〉 = (1/|G|) Σ χ(g)⁻ ψ(g), computed by InnerProduct. A character is irreducible exactly when its norm squared is one (IsIrreducible); an arbitrary character decomposes uniquely into irreducibles (DecomposeCharacter) — the numerical content of Maschke's theorem and complete reducibility. Restriction and induction between a group and a subgroup are provided by RestrictCharacter and InduceCharacter, and satisfy Frobenius reciprocity.

Character tables

A CharacterTable assembles a complete set of irreducible characters against the conjugacy classes of the group. Tables for the standard families are produced by CharacterTableCyclic, CharacterTableDihedral, CharacterTableSymmetric, CharacterTableQuaternion and CharacterTableKleinFour. Each table satisfies the row and column orthogonality relations (CharacterTable.RowOrthogonality, CharacterTable.ColumnOrthogonality) and the dimension identity Σ dᵢ² = |G| (CharacterTable.SumOfSquaresOfDims).

All results are deterministic. Any randomness used by helper routines takes a caller-supplied seed through math/rand. Floating-point comparisons take an explicit tolerance; a value near 1e-9 is appropriate for the small groups the package targets.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsC

func AbsC(z complex128) float64

AbsC returns the modulus |z| of the complex number z.

func ApproxEqualC

func ApproxEqualC(a, b complex128, tol float64) bool

ApproxEqualC reports whether a and b are within tol of each other in modulus, i.e. |a-b| <= tol.

func ApproxZeroC

func ApproxZeroC(z complex128, tol float64) bool

ApproxZeroC reports whether |z| <= tol.

func CharacterDimension

func CharacterDimension(chi Character) int

CharacterDimension returns the dimension of the representation affording chi, the rounded real part of chi on the identity.

func ClassValues

func ClassValues(g *Group, chi Character, tol float64) ([]complex128, error)

ClassValues reduces chi to one value per conjugacy class of g, taking the value on each class representative (the smallest element). It errors if chi is not a class function to within tol.

func Conj

func Conj(z complex128) complex128

Conj returns the complex conjugate of z.

func Cplx

func Cplx(re, im float64) complex128

Cplx builds a complex128 from its real and imaginary parts. It is a thin convenience wrapper around the built-in complex.

func DecomposeCharacter

func DecomposeCharacter(g *Group, chi Character, irrs []Character) []int

DecomposeCharacter returns the multiplicities of chi against the given list of irreducible characters, so that chi = Σ mult[i]·irrs[i]. This is the numerical form of complete reducibility (Maschke's theorem). The multiplicity is the rounded inner product 〈irrs[i], chi〉.

func Imag

func Imag(z complex128) float64

Imag returns the imaginary part of z.

func InnerProduct

func InnerProduct(g *Group, a, b Character) complex128

InnerProduct returns the Hermitian inner product of two characters of g,

〈a, b〉 = (1/|G|) Σ_{x∈G} conj(a(x)) · b(x).

For irreducible characters this is 1 when the characters are equal and 0 otherwise (the first orthogonality relation). It panics if the lengths do not match |G|.

Example

ExampleInnerProduct demonstrates the first orthogonality relation on the irreducible characters of S3.

g := SymmetricGroup(3)
ct := CharacterTableSymmetric(3)
std := ct.Irreducible(2)
fmt.Printf("%.0f %.0f\n",
	real(InnerProduct(g, std, std)),
	real(InnerProduct(g, ct.Irreducible(0), std)))
Output:
1 0

func IsCharacter

func IsCharacter(g *Group, chi Character, irrs []Character, tol float64) bool

IsCharacter reports whether chi is a (non-virtual) character with respect to the given complete list of irreducibles: all multiplicities are non-negative integers to within tol, and the reconstruction matches chi.

func IsIntegerC

func IsIntegerC(z complex128, tol float64) bool

IsIntegerC reports whether z is a (real) integer to within tol.

func IsIrreducible

func IsIrreducible(g *Group, chi Character, tol float64) bool

IsIrreducible reports whether chi is an irreducible character, i.e. its norm squared is 1 to within tol.

func IsRealC

func IsRealC(z complex128, tol float64) bool

IsRealC reports whether z is real to within tol, i.e. |Imag(z)| <= tol.

func Multiplicity

func Multiplicity(g *Group, chi, irr Character) int

Multiplicity returns the multiplicity of the irreducible character irr in the character chi, the rounded value of 〈irr, chi〉.

func NormSquared

func NormSquared(g *Group, chi Character) float64

NormSquared returns the real number 〈chi, chi〉, the squared norm of chi in the character inner product. It equals the sum of the squares of the multiplicities of the irreducible constituents.

func PrimitiveRootOfUnity

func PrimitiveRootOfUnity(n int) complex128

PrimitiveRootOfUnity returns exp(2πi / n), the standard primitive n-th root of unity. It panics if n <= 0.

func Real

func Real(z complex128) float64

Real returns the real part of z.

func RootOfUnity

func RootOfUnity(n, k int) complex128

RootOfUnity returns the primitive-n-th root exp(2πi k / n), the k-th power of the standard primitive n-th root of unity. It panics if n <= 0.

func RoundC

func RoundC(z complex128, decimals int) complex128

RoundC rounds both the real and imaginary parts of z to the given number of decimal places. It is useful for presenting otherwise noisy floating-point results.

func RoundToInteger

func RoundToInteger(z complex128) complex128

RoundToInteger returns the nearest Gaussian integer to z. It is used to snap character inner products, which are known to be integers, to exact values.

Types

type Character

type Character []complex128

Character is a class function on a group, stored as one complex value per element index: chi[i] is the value on element i. The character of a representation is the class function i ↦ tr ρ(i), obtained from Rep.Character.

func AddCharacters

func AddCharacters(a, b Character) Character

AddCharacters returns the pointwise sum a+b, the character of the direct sum.

func CharacterFromRep

func CharacterFromRep(r *Rep) Character

CharacterFromRep returns the character of the representation r; it is a free function equivalent to r.Character().

func ConjugateCharacter

func ConjugateCharacter(chi Character) Character

ConjugateCharacter returns the complex conjugate of chi, the character of the dual representation.

func InduceCharacter

func InduceCharacter(gG *Group, gH *Group, emb []int, psi Character) (Character, error)

InduceCharacter induces a character psi of a subgroup H up to the group G, using the embedding emb (emb[h] the index in G of the H-element h). It applies the Frobenius formula

Ind(psi)(y) = (1/|H|) Σ_{x∈G} psi°(x⁻¹ y x),

where psi° extends psi by zero off H. It returns an error if emb is not a valid injection of a subgroup of G.

func RegularCharacter

func RegularCharacter(g *Group) Character

RegularCharacter returns the character of the regular representation of g: |G| on the identity and 0 elsewhere. It decomposes as Σ dᵢ·χᵢ over the irreducibles, each appearing with multiplicity equal to its degree.

func RestrictCharacter

func RestrictCharacter(chi Character, emb []int) Character

RestrictCharacter restricts a character of a group G to a subgroup H given by an embedding emb, where emb[h] is the index in G of the element h of H. The result is the class function on H with value chi(emb[h]).

func ScaleCharacter

func ScaleCharacter(z complex128, chi Character) Character

ScaleCharacter returns z·chi.

func SubCharacters

func SubCharacters(a, b Character) Character

SubCharacters returns the pointwise difference a-b (a virtual character).

func TensorCharacters

func TensorCharacters(a, b Character) Character

TensorCharacters returns the pointwise product a·b, the character of the tensor product representation.

func TrivialCharacter

func TrivialCharacter(g *Group) Character

TrivialCharacter returns the character of the trivial representation of g, identically 1.

func ZeroCharacter

func ZeroCharacter(g *Group) Character

ZeroCharacter returns the identically zero class function on g.

func (Character) ApproxEqual

func (chi Character) ApproxEqual(psi Character, tol float64) bool

ApproxEqual reports whether chi and psi agree entrywise to within tol.

func (Character) Clone

func (chi Character) Clone() Character

Clone returns an independent copy of chi.

func (Character) Degree

func (chi Character) Degree() float64

Degree returns the degree (dimension) of the character, its value on the identity element, as a real number.

func (Character) IsClassFunction

func (chi Character) IsClassFunction(g *Group, tol float64) bool

IsClassFunction reports whether chi is constant on the conjugacy classes of g to within tol. Every character is a class function; this checks a candidate.

func (Character) Value

func (chi Character) Value(i int) complex128

Value returns the value of chi on element i.

type CharacterTable

type CharacterTable struct {
	// contains filtered or unexported fields
}

CharacterTable holds a complete set of irreducible characters of a group, tabulated against its conjugacy classes. The number of irreducibles equals the number of conjugacy classes. Rows are irreducible characters and columns are classes.

func BuildCharacterTable

func BuildCharacterTable(g *Group, irrs []Character) *CharacterTable

BuildCharacterTable assembles a character table for g from a list of irreducible characters (each a full class function over all |G| elements). The characters are sorted by degree (ascending), then lexicographically, so the trivial character comes first. The rows are reduced to one value per conjugacy class.

func CharacterTableCyclic

func CharacterTableCyclic(n int) *CharacterTable

CharacterTableCyclic returns the character table of the cyclic group C_n. Its n irreducible characters send the generator to each n-th root of unity. It panics if n < 1.

func CharacterTableDihedral

func CharacterTableDihedral(n int) *CharacterTable

CharacterTableDihedral returns the character table of the dihedral group D_n. It is assembled from the one-dimensional characters and the two-dimensional characters χ_h(r^j) = 2cos(2πhj/n), χ_h(reflection) = 0. It panics if n < 1.

func CharacterTableKleinFour

func CharacterTableKleinFour() *CharacterTable

CharacterTableKleinFour returns the character table of the Klein four-group.

func CharacterTableQuaternion

func CharacterTableQuaternion() *CharacterTable

CharacterTableQuaternion returns the character table of the quaternion group Q8: four one-dimensional characters and one two-dimensional character with values (2, -2, 0, 0, 0) on the classes {1}, {-1}, {±i}, {±j}, {±k}.

func CharacterTableSymmetric

func CharacterTableSymmetric(n int) *CharacterTable

CharacterTableSymmetric returns the character table of the symmetric group S_n for 1 <= n <= 4. It panics for n outside this range (the general case is governed by the Murnaghan-Nakayama rule and is not implemented here).

func (*CharacterTable) ClassElementOrders

func (ct *CharacterTable) ClassElementOrders() []int

ClassElementOrders returns the order of a representative element of each conjugacy class, in column order.

func (*CharacterTable) ClassRepresentatives

func (ct *CharacterTable) ClassRepresentatives() []int

ClassRepresentatives returns the smallest element index of each conjugacy class, in column order.

func (*CharacterTable) ClassSizes

func (ct *CharacterTable) ClassSizes() []int

ClassSizes returns the number of elements in each conjugacy class, in column order.

func (*CharacterTable) ColumnOrthogonality

func (ct *CharacterTable) ColumnOrthogonality(tol float64) bool

ColumnOrthogonality reports whether the columns satisfy the second orthogonality relation: for classes c and d with representatives of centralizer order |G|/|class|,

Σᵢ conj(χᵢ(c))·χᵢ(d) = δ_{cd}·|G|/|class c|,

to within tol.

func (*CharacterTable) Decompose

func (ct *CharacterTable) Decompose(chi Character) []int

Decompose returns the multiplicities of an arbitrary character chi against the irreducibles of the table, so that chi = Σ mult[i]·χᵢ.

Example

ExampleDecomposeCharacter shows that the regular representation of S3 decomposes with each irreducible appearing with multiplicity equal to its degree: the trivial (1), the sign (1) and the two-dimensional standard representation (2).

g := SymmetricGroup(3)
ct := CharacterTableSymmetric(3)
reg := RegularCharacter(g)
fmt.Println(ct.Decompose(reg))
Output:
[1 1 2]

func (*CharacterTable) Dimensions

func (ct *CharacterTable) Dimensions() []int

Dimensions returns the degrees of the irreducible characters, in row order.

func (*CharacterTable) Group

func (ct *CharacterTable) Group() *Group

Group returns the group of the table.

func (*CharacterTable) Irreducible

func (ct *CharacterTable) Irreducible(i int) Character

Irreducible returns the i-th irreducible character as a full class function over the group.

func (*CharacterTable) Irreducibles

func (ct *CharacterTable) Irreducibles() []Character

Irreducibles returns all irreducible characters as full class functions.

func (*CharacterTable) IsComplete

func (ct *CharacterTable) IsComplete() bool

IsComplete reports whether the table has as many irreducibles as classes and satisfies Σ dᵢ² = |G|.

func (*CharacterTable) NumClasses

func (ct *CharacterTable) NumClasses() int

NumClasses returns the number of conjugacy classes (columns). It equals NumIrreducibles for a complete table.

func (*CharacterTable) NumIrreducibles

func (ct *CharacterTable) NumIrreducibles() int

NumIrreducibles returns the number of irreducible characters (rows).

func (*CharacterTable) RowOrthogonality

func (ct *CharacterTable) RowOrthogonality(tol float64) bool

RowOrthogonality reports whether the rows satisfy the first orthogonality relation: 〈χᵢ, χⱼ〉 = δᵢⱼ to within tol, using the weighted class sum (1/|G|) Σ_c |class c|·conj(χᵢ)·χⱼ.

func (*CharacterTable) String

func (ct *CharacterTable) String() string

String renders the character table as an aligned text grid: one row per irreducible, one column per class, values rounded to two decimals.

func (*CharacterTable) SumOfSquaresOfDims

func (ct *CharacterTable) SumOfSquaresOfDims() int

SumOfSquaresOfDims returns Σ dᵢ², which for a complete table equals the group order |G|.

func (*CharacterTable) Value

func (ct *CharacterTable) Value(i, c int) complex128

Value returns the value of irreducible i on conjugacy class c.

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group is a finite group given by an explicit Cayley (multiplication) table. Elements are the integers 0,...,n-1; element 0 is always the identity. The table satisfies table[i][j] = index of the product i·j. Construct groups with the family constructors (CyclicGroup, DihedralGroup, ...) rather than by hand.

func AlternatingGroup

func AlternatingGroup(n int) *Group

AlternatingGroup returns the alternating group A_n of even permutations of n points, of order n!/2 for n >= 2. It panics if n < 1.

func CyclicGroup

func CyclicGroup(n int) *Group

CyclicGroup returns the cyclic group Z/nZ of order n written additively: element i is i mod n and i·j = (i+j) mod n. It panics if n < 1.

func DihedralGroup

func DihedralGroup(n int) *Group

DihedralGroup returns the dihedral group D_n of order 2n, the symmetry group of a regular n-gon. Element a·n+b denotes s^a r^b with r a rotation of order n, s a reflection, and s r s = r⁻¹. It panics if n < 1.

func DirectProduct

func DirectProduct(g, h *Group) *Group

DirectProduct returns the external direct product g×h. Element a·|h|+b denotes the pair (a, b) with componentwise multiplication.

func KleinFourGroup

func KleinFourGroup() *Group

KleinFourGroup returns the Klein four-group V = C2×C2 of order 4.

func QuaternionGroup

func QuaternionGroup() *Group

QuaternionGroup returns the quaternion group Q8 = {±1, ±i, ±j, ±k} of order 8. Elements are indexed 0:1, 1:-1, 2:i, 3:-i, 4:j, 5:-j, 6:k, 7:-k.

func SymmetricGroup

func SymmetricGroup(n int) *Group

SymmetricGroup returns the symmetric group S_n of all permutations of n points, of order n!. It panics if n < 1. Practical use is limited to small n.

func TrivialGroup

func TrivialGroup() *Group

TrivialGroup returns the group with one element.

func (*Group) CayleyTable

func (g *Group) CayleyTable() [][]int

CayleyTable returns a copy of the multiplication table of g.

func (*Group) Center

func (g *Group) Center() []int

Center returns the sorted indices of the elements commuting with every element of g.

func (*Group) Centralizer

func (g *Group) Centralizer(x int) []int

Centralizer returns the sorted indices of the elements commuting with x.

func (*Group) ClassOf

func (g *Group) ClassOf(x int) []int

ClassOf returns the conjugacy class containing element x.

func (*Group) Commutator

func (g *Group) Commutator(i, j int) int

Commutator returns the group commutator i j i⁻¹ j⁻¹.

func (*Group) ConjugacyClasses

func (g *Group) ConjugacyClasses() [][]int

ConjugacyClasses returns the conjugacy classes of g, each a sorted slice of element indices. The classes are ordered by their smallest element, so the identity class {0} comes first.

func (*Group) Conjugate

func (g *Group) Conjugate(a, x int) int

Conjugate returns the conjugate g x g⁻¹ (with a the conjugator and x the element), i.e. a·x·a⁻¹.

func (*Group) ElementName

func (g *Group) ElementName(i int) string

ElementName returns a human-readable label for element i.

func (*Group) ElementOrder

func (g *Group) ElementOrder(i int) int

ElementOrder returns the order of element i, the least positive k with i^k = identity.

func (*Group) Elements

func (g *Group) Elements() []int

Elements returns the slice {0,1,...,Order()-1}.

func (*Group) Exponent

func (g *Group) Exponent() int

Exponent returns the exponent of g, the least common multiple of all element orders.

func (*Group) GeneratedBy

func (g *Group) GeneratedBy(gens []int) []int

GeneratedBy returns the sorted set of elements of the subgroup generated by gens (the closure under multiplication and inverses).

func (*Group) Identity

func (g *Group) Identity() int

Identity returns the index of the identity element, which is always 0.

func (*Group) Inverse

func (g *Group) Inverse(i int) int

Inverse returns the inverse of element i.

func (*Group) IsAbelian

func (g *Group) IsAbelian() bool

IsAbelian reports whether g is commutative.

func (*Group) IsSubgroup

func (g *Group) IsSubgroup(elems []int) bool

IsSubgroup reports whether the given set of element indices is closed under the group operation and inverses (and hence forms a subgroup).

func (*Group) IsValid

func (g *Group) IsValid() error

IsValid re-checks that g really is a group. It returns nil for the groups the constructors produce.

func (*Group) Mul

func (g *Group) Mul(i, j int) int

Mul returns the product i·j.

func (*Group) Name

func (g *Group) Name() string

Name returns the display name of g.

func (*Group) NumConjugacyClasses

func (g *Group) NumConjugacyClasses() int

NumConjugacyClasses returns the number of conjugacy classes of g, which equals the number of complex irreducible representations.

func (*Group) Order

func (g *Group) Order() int

Order returns the number of elements of g.

func (*Group) Pow

func (g *Group) Pow(i, k int) int

Pow returns element i raised to the integer power k (negative k uses the inverse).

type Matrix

type Matrix [][]complex128

Matrix is a dense complex matrix stored row-major: m[i][j] is the entry in row i and column j. The zero value is not usable; construct matrices with NewMatrix, MatrixFromRows and friends.

func Commutator

func Commutator(a, b Matrix) Matrix

Commutator returns the matrix commutator ab-ba. It panics if the products are undefined.

func DiagMatrix

func DiagMatrix(diag []complex128) Matrix

DiagMatrix returns the square diagonal matrix whose diagonal entries are the elements of diag.

func IdentityMatrix

func IdentityMatrix(n int) Matrix

IdentityMatrix returns the n×n identity matrix. It panics if n is negative.

func MatAdd

func MatAdd(a, b Matrix) (Matrix, error)

MatAdd returns a+b, erroring on a shape mismatch.

func MatDirectSum

func MatDirectSum(a, b Matrix) Matrix

MatDirectSum returns the block-diagonal direct sum a⊕b.

func MatKronecker

func MatKronecker(a, b Matrix) Matrix

MatKronecker returns the Kronecker product a⊗b.

func MatMul

func MatMul(a, b Matrix) (Matrix, error)

MatMul returns the product a·b. It returns an error on a dimension mismatch; it is the free-function form of Matrix.Mul.

func MatSub

func MatSub(a, b Matrix) (Matrix, error)

MatSub returns a-b, erroring on a shape mismatch.

func MatrixFromReal

func MatrixFromReal(rows [][]float64) Matrix

MatrixFromReal builds a complex matrix whose entries are the given real numbers (with zero imaginary part). It panics if the input is ragged.

func MatrixFromRows

func MatrixFromRows(rows [][]complex128) Matrix

MatrixFromRows builds a matrix from an explicit slice of rows. The input is deep-copied. It panics if the rows are ragged.

func NewMatrix

func NewMatrix(r, c int) Matrix

NewMatrix returns an r×c matrix with every entry equal to zero. It panics if r or c is negative.

func PermutationMatrix

func PermutationMatrix(p []int) Matrix

PermutationMatrix returns the n×n permutation matrix P of the permutation p (in one-line notation, p[i] the image of i), defined by P[p[i]][i] = 1. Thus P acts on a standard basis vector e_i by sending it to e_{p[i]}. It panics if p is not a permutation of {0,...,n-1}.

func ReflectionMatrix

func ReflectionMatrix(theta float64) Matrix

ReflectionMatrix returns the 2×2 real matrix reflecting the plane across the line through the origin at angle theta to the x-axis.

func RotationMatrix

func RotationMatrix(theta float64) Matrix

RotationMatrix returns the 2×2 real rotation matrix through angle theta (counter-clockwise).

func ScalarMatrix

func ScalarMatrix(n int, z complex128) Matrix

ScalarMatrix returns the n×n diagonal matrix with z on the diagonal, i.e. z times the identity.

func ZeroMatrix

func ZeroMatrix(r, c int) Matrix

ZeroMatrix is an alias for NewMatrix returning the r×c zero matrix.

func (Matrix) Add

func (m Matrix) Add(n Matrix) (Matrix, error)

Add returns m+n. It returns an error if the shapes differ.

func (Matrix) ApproxEqual

func (m Matrix) ApproxEqual(n Matrix, tol float64) bool

ApproxEqual reports whether m and n have the same shape and entries agreeing to within tol in modulus.

func (Matrix) At

func (m Matrix) At(i, j int) complex128

At returns the entry m[i][j].

func (Matrix) Clone

func (m Matrix) Clone() Matrix

Clone returns an independent deep copy of m.

func (Matrix) Col

func (m Matrix) Col(j int) []complex128

Col returns a copy of column j.

func (Matrix) Cols

func (m Matrix) Cols() int

Cols returns the number of columns of m (zero for an empty matrix).

func (Matrix) Conjugate

func (m Matrix) Conjugate() Matrix

Conjugate returns the entrywise complex conjugate of m.

func (Matrix) ConjugateTranspose

func (m Matrix) ConjugateTranspose() Matrix

ConjugateTranspose returns the conjugate transpose (Hermitian adjoint) m†.

func (Matrix) Det

func (m Matrix) Det() complex128

Det returns the determinant of the square matrix m, computed by Gaussian elimination with partial pivoting. It panics if m is not square.

func (Matrix) DirectSum

func (m Matrix) DirectSum(n Matrix) Matrix

DirectSum returns the block-diagonal matrix diag(m, n), the direct sum m⊕n.

func (Matrix) Equal

func (m Matrix) Equal(n Matrix) bool

Equal reports whether m and n have the same shape and identical entries.

func (Matrix) FrobeniusNorm

func (m Matrix) FrobeniusNorm() float64

FrobeniusNorm returns the Frobenius norm of m, the square root of the sum of the squared moduli of all entries.

func (Matrix) Inverse

func (m Matrix) Inverse() (Matrix, error)

Inverse returns the inverse of the square matrix m via Gauss-Jordan elimination. It returns an error if m is not square or is singular.

func (Matrix) IsDiagonal

func (m Matrix) IsDiagonal(tol float64) bool

IsDiagonal reports whether all off-diagonal entries of the square matrix m vanish to within tol.

func (Matrix) IsHermitian

func (m Matrix) IsHermitian(tol float64) bool

IsHermitian reports whether m equals its conjugate transpose to within tol.

func (Matrix) IsIdentity

func (m Matrix) IsIdentity(tol float64) bool

IsIdentity reports whether m is the identity matrix to within tol.

func (Matrix) IsSquare

func (m Matrix) IsSquare() bool

IsSquare reports whether m has equal row and column counts.

func (Matrix) IsUnitary

func (m Matrix) IsUnitary(tol float64) bool

IsUnitary reports whether m is unitary, i.e. m†m is the identity to within tol.

func (Matrix) IsZero

func (m Matrix) IsZero(tol float64) bool

IsZero reports whether every entry of m is zero to within tol.

func (Matrix) Kronecker

func (m Matrix) Kronecker(n Matrix) Matrix

Kronecker returns the Kronecker (tensor) product m⊗n, an (r_m·r_n)×(c_m·c_n) matrix. It underlies the tensor product of representations.

func (Matrix) MaxAbsDiff

func (m Matrix) MaxAbsDiff(n Matrix) float64

MaxAbsDiff returns the largest modulus |m[i][j]-n[i][j]| over all entries. It panics if the shapes differ.

func (Matrix) Mul

func (m Matrix) Mul(n Matrix) (Matrix, error)

Mul returns the matrix product m·n. It returns an error if the inner dimensions do not match.

func (Matrix) MulVec

func (m Matrix) MulVec(v []complex128) ([]complex128, error)

MulVec returns the matrix-vector product m·v. It returns an error if the dimensions are incompatible.

func (Matrix) Pow

func (m Matrix) Pow(k int) (Matrix, error)

Pow returns m raised to the non-negative integer power k. Pow(m, 0) is the identity. It returns an error if m is not square.

func (Matrix) Rank

func (m Matrix) Rank(tol float64) int

Rank returns the numerical rank of m, the number of pivots found by Gaussian elimination with entries below tol treated as zero.

func (Matrix) Round

func (m Matrix) Round(decimals int) Matrix

Round returns a copy of m with every entry rounded to the given number of decimal places.

func (Matrix) Row

func (m Matrix) Row(i int) []complex128

Row returns a copy of row i.

func (Matrix) Rows

func (m Matrix) Rows() int

Rows returns the number of rows of m.

func (Matrix) Scale

func (m Matrix) Scale(z complex128) Matrix

Scale returns z·m, the matrix with every entry multiplied by z.

func (Matrix) Set

func (m Matrix) Set(i, j int, z complex128)

Set assigns z to entry m[i][j].

func (Matrix) String

func (m Matrix) String() string

String renders m with entries rounded to three decimals, one row per line.

func (Matrix) Sub

func (m Matrix) Sub(n Matrix) (Matrix, error)

Sub returns m-n. It returns an error if the shapes differ.

func (Matrix) Submatrix

func (m Matrix) Submatrix(rows, cols []int) Matrix

Submatrix returns the matrix formed by selecting the given rows and columns in the given order.

func (Matrix) Trace

func (m Matrix) Trace() complex128

Trace returns the sum of the diagonal entries of the square matrix m. It panics if m is not square.

func (Matrix) Transpose

func (m Matrix) Transpose() Matrix

Transpose returns the transpose of m.

type Perm

type Perm []int

Perm is a permutation of {0,...,n-1} in one-line notation: p[i] is the image of i. A valid Perm of length n contains each value in [0,n) exactly once.

func AllPermutations

func AllPermutations(n int) []Perm

AllPermutations returns every permutation of {0,...,n-1} in lexicographic order. It panics if n is negative.

func IdentityPerm

func IdentityPerm(n int) Perm

IdentityPerm returns the identity permutation of degree n.

func (Perm) Apply

func (p Perm) Apply(i int) int

Apply returns the image p[i] of point i.

func (Perm) Compose

func (p Perm) Compose(q Perm) Perm

Compose returns the composition p∘q, applying q first: (p∘q)[i] = p[q[i]]. It panics if the degrees differ.

func (Perm) CycleDecomposition

func (p Perm) CycleDecomposition() [][]int

CycleDecomposition returns the disjoint cycles of p as a slice of slices, including fixed points as length-one cycles. Each cycle begins with its smallest element and the cycles are ordered by that element.

func (Perm) CycleType

func (p Perm) CycleType() []int

CycleType returns the multiset of cycle lengths of p in non-increasing order, a partition of the degree. It is the conjugacy-class invariant for symmetric groups.

func (Perm) Degree

func (p Perm) Degree() int

Degree returns the size n of the set {0,...,n-1} that p permutes.

func (Perm) Equal

func (p Perm) Equal(q Perm) bool

Equal reports whether p and q are the same permutation.

func (Perm) Inverse

func (p Perm) Inverse() Perm

Inverse returns the inverse permutation of p.

func (Perm) IsValid

func (p Perm) IsValid() bool

IsValid reports whether p is a genuine permutation of {0,...,len(p)-1}.

func (Perm) Order

func (p Perm) Order() int

Order returns the multiplicative order of p, the least positive k with p^k = identity. It equals the least common multiple of the cycle lengths.

func (Perm) PermMatrix

func (p Perm) PermMatrix() Matrix

PermMatrix returns the permutation matrix of p; see PermutationMatrix.

func (Perm) Sign

func (p Perm) Sign() int

Sign returns the sign of p: +1 if p is an even permutation and -1 if odd, computed from the parity of the number of transpositions.

type Rep

type Rep struct {
	// contains filtered or unexported fields
}

Rep is a finite-dimensional complex matrix representation of a Group: a map assigning to every element i an invertible dim×dim matrix mats[i] such that mats[i·j] = mats[i]·mats[j]. Build reps with the constructors below or with NewRep, which validates the homomorphism property.

func CyclicRep

func CyclicRep(n, k int) *Rep

CyclicRep returns the one-dimensional representation of the cyclic group C_n sending the generator r to the k-th root of unity ω^k = exp(2πik/n). For k ranging over 0..n-1 these are all the irreducible representations of C_n. It panics if n < 1.

func DihedralRep2D

func DihedralRep2D(n, h int) *Rep

DihedralRep2D returns the two-dimensional representation of the dihedral group D_n in which the rotation r acts by rotation through 2πh/n and the reflection s acts by a reflection. For 1 <= h < n/2 these are irreducible; its character is 2cos(2πhj/n) on r^j and 0 on every reflection. It panics if n < 1.

func DirectSumReps

func DirectSumReps(reps ...*Rep) *Rep

DirectSumReps returns the direct sum of several representations of the same group, in order. It panics if fewer than one rep is given.

func NaturalRepSymmetric

func NaturalRepSymmetric(n int) *Rep

NaturalRepSymmetric returns the natural n-dimensional permutation representation of the symmetric group S_n, in which each permutation acts by its permutation matrix. It is reducible for n >= 2, decomposing as the trivial representation plus the (n-1)-dimensional standard representation. It panics if n < 1.

func NewRep

func NewRep(g *Group, mats []Matrix, tol float64) (*Rep, error)

NewRep builds a representation of g from an explicit matrix per element and verifies that it is a genuine homomorphism to within tol. The slice mats must have length g.Order() and every matrix must be square of the same size. It returns an error otherwise.

func QuaternionRep

func QuaternionRep() *Rep

QuaternionRep returns the two-dimensional irreducible representation of the quaternion group Q8 by Pauli-like matrices, with i, j, k acting as the standard unit-quaternion matrices. Its character is (2, -2, 0, 0, 0) on the classes {1}, {-1}, {±i}, {±j}, {±k}.

func RegularRep

func RegularRep(g *Group) *Rep

RegularRep returns the left regular representation of g, of dimension |G|: element x acts on the basis {e_y} by e_y ↦ e_{x·y}. Its character is |G| at the identity and 0 elsewhere.

func SignRepSymmetric

func SignRepSymmetric(n int) *Rep

SignRepSymmetric returns the one-dimensional sign representation of S_n, sending each permutation to its sign (+1 or -1). It panics if n < 1.

func TrivialRep

func TrivialRep(g *Group) *Rep

TrivialRep returns the one-dimensional representation sending every element to [1].

func (*Rep) Character

func (r *Rep) Character() Character

Character returns the character of r, the class function χ(i) = tr mats[i].

func (*Rep) Dim

func (r *Rep) Dim() int

Dim returns the dimension (degree) of the representation.

func (*Rep) DirectSum

func (r *Rep) DirectSum(s *Rep) *Rep

DirectSum returns the direct sum r⊕s, the block-diagonal representation of dimension Dim(r)+Dim(s). It panics if the two reps are of different groups.

func (*Rep) Dual

func (r *Rep) Dual() *Rep

Dual returns the dual (contragredient) representation, sending g to the inverse transpose of mats[g]. Its character is the complex conjugate of the original character.

func (*Rep) Group

func (r *Rep) Group() *Group

Group returns the group being represented.

func (*Rep) IsHomomorphism

func (r *Rep) IsHomomorphism(tol float64) bool

IsHomomorphism reports whether mats[i·j] = mats[i]·mats[j] for all i, j to within tol.

func (*Rep) IsUnitary

func (r *Rep) IsUnitary(tol float64) bool

IsUnitary reports whether every representing matrix is unitary to within tol. Every representation of a finite group is equivalent to a unitary one (Weyl's unitarian trick); the standard constructions here are unitary.

func (*Rep) Matrix

func (r *Rep) Matrix(i int) Matrix

Matrix returns the representing matrix of element i.

func (*Rep) RepString

func (r *Rep) RepString() string

RepString renders a short multi-line description of r for debugging.

func (*Rep) TensorProduct

func (r *Rep) TensorProduct(s *Rep) *Rep

TensorProduct returns the tensor (Kronecker) product r⊗s, of dimension Dim(r)·Dim(s). Its character is the pointwise product of the two characters. It panics if the reps are of different groups.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL