The Smith normal form decomposition implementation in Julia. Note: Works only over integer domain.
pkg> add https://github.com/wildart/SmithNormalForm.jl.git#v0.2.0
For Julia 1.1+, add BoffinStuff registry in the package manager, and proceed with the installation:
pkg> registry add https://github.com/wildart/BoffinStuff.git
pkg> add SmithNormalForm
julia> using SmithNormalForm, LinearAlgebra
julia> X = rand(1:100, 3, 5)
3×5 Array{Int64,2}:
14 82 85 39 56
70 51 4 68 23
58 27 87 1 52
julia> F = smith(X)
Smith normal form:
[1, -1, 1]
julia> F.S
3×3 Array{Int64,2}:
1 0 0
640 1 0
807 29427 1
julia> F.T
5×5 Array{Int64,2}:
14 82 85 39 56
8890 52429 54396 24892 35817
261594790 1542762036 1600642584 732465412 1053941719
87198265 514254012 533547528 244155142 351313913
0 -109493940 -113601877 0 -536735
julia> diagm(F)
3×5 Array{Int64,2}:
1 0 0 0 0
0 -1 0 0 0
0 0 1 0 0
julia> F.SNF
3-element Array{Int64,1}:
1
-1
1
julia> F.S*diagm(F)*F.T
3×5 Array{Int64,2}:
14 82 85 39 56
70 51 4 68 23
58 27 87 1 52
05/24/2017
6 days ago
24 commits