我是Julia的新手。 我想编写一个程序,能够使用群作用。
例如:取 $\mathbb{R}^{4}$ 中的向量 $(a,b,c,d)$,考虑 $S_{4}$ 中元素在其上的作用,例如循环 $(1,2,3,4)$。我想要一个计算程序:
$$(1,2,3,4)(a,b,c,d) = (d,a,b,c)$$
如果能够适用于任何置换,那将非常好。你有任何想法需要下载哪些包吗?以及如何编写代码?
感谢您的帮助。
我是Julia的新手。 我想编写一个程序,能够使用群作用。
例如:取 $\mathbb{R}^{4}$ 中的向量 $(a,b,c,d)$,考虑 $S_{4}$ 中元素在其上的作用,例如循环 $(1,2,3,4)$。我想要一个计算程序:
$$(1,2,3,4)(a,b,c,d) = (d,a,b,c)$$
如果能够适用于任何置换,那将非常好。你有任何想法需要下载哪些包吗?以及如何编写代码?
感谢您的帮助。
你可能会喜欢Permutations包,https://github.com/scheinerman/Permutations.jl。
julia> using Permutations
julia> p = Permutation([2,3,4,1]) # an element of S_4
(1,2,3,4) # printed in cycle notation
julia> p(1) # apply it to one element
2
julia> two_row(p) # alternative way to print this
2×4 Matrix{Int64}:
1 2 3 4
2 3 4 1
julia> inv(p)
(1,4,3,2)
julia> input = [:a, :b, :c, :d]; # an array of any 4 things
julia> [input[p(i)] for i in eachindex(input)] # permute those?
4-element Vector{Symbol}:
:b
:c
:d
:a
julia> ans == input[p.(eachindex(input))] # another way to write the same
true
julia> input[inv(p).(eachindex(input))] # with inv(p)
4-element Vector{Symbol}:
:d
:a
:b
:c
julia> Permutation([2,3,1,4,6,5])
(1,2,3)(4)(5,6) # it really prints the cycles