mirror of
https://github.com/kalmarek/GroupRings.jl.git
synced 2024-12-29 11:00:28 +01:00
Merge branch 'master' into enh/julia-v0.6
This commit is contained in:
commit
b0cce16dfa
@ -11,6 +11,8 @@ import Base: convert, show, hash, ==, +, -, *, //, /, length, norm, rationalize,
|
|||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
baseless_warn = false
|
||||||
|
|
||||||
type GroupRing{Gr<:Group, T<:GroupElem} <: Ring
|
type GroupRing{Gr<:Group, T<:GroupElem} <: Ring
|
||||||
group::Gr
|
group::Gr
|
||||||
basis::Vector{T}
|
basis::Vector{T}
|
||||||
@ -232,7 +234,7 @@ function show(io::IO, X::GroupRingElem)
|
|||||||
end
|
end
|
||||||
print(io, str)
|
print(io, str)
|
||||||
else
|
else
|
||||||
warn("Basis of the parent Group is not defined, showing coeffs")
|
baseless_warn && warn("Basis of the parent Group is not defined, showing coeffs")
|
||||||
show(io, MIME("text/plain"), X.coeffs)
|
show(io, MIME("text/plain"), X.coeffs)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -257,7 +259,7 @@ function (==)(A::GroupRing, B::GroupRing)
|
|||||||
if isdefined(A, :basis) && isdefined(B, :basis)
|
if isdefined(A, :basis) && isdefined(B, :basis)
|
||||||
A.basis == B.basis || return false
|
A.basis == B.basis || return false
|
||||||
else
|
else
|
||||||
warn("Bases of GroupRings are not defined, comparing products mats.")
|
baseless_warn && warn("Bases of GroupRings are not defined, comparing products mats.")
|
||||||
A.pm == B.pm || return false
|
A.pm == B.pm || return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
@ -518,7 +520,7 @@ function reverse_dict(iter)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function create_pm{T<:GroupElem}(basis::Vector{T}, basis_dict::Dict{T, Int},
|
function create_pm{T<:GroupElem}(basis::Vector{T}, basis_dict::Dict{T, Int},
|
||||||
limit::Int=length(basis); twisted::Bool=false)
|
limit::Int=length(basis); twisted::Bool=false, check=true)
|
||||||
product_matrix = zeros(Int, (limit,limit))
|
product_matrix = zeros(Int, (limit,limit))
|
||||||
Threads.@threads for i in 1:limit
|
Threads.@threads for i in 1:limit
|
||||||
x = basis[i]
|
x = basis[i]
|
||||||
@ -526,12 +528,29 @@ function create_pm{T<:GroupElem}(basis::Vector{T}, basis_dict::Dict{T, Int},
|
|||||||
x = inv(x)
|
x = inv(x)
|
||||||
end
|
end
|
||||||
for j in 1:limit
|
for j in 1:limit
|
||||||
product_matrix[i,j] = basis_dict[x*(basis[j])]
|
product_matrix[i,j] = basis_dict[x*basis[j]]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
check && check_pm(product_matrix, basis, twisted)
|
||||||
|
|
||||||
return product_matrix
|
return product_matrix
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function check_pm(product_matrix, basis, twisted)
|
||||||
|
idx = findfirst(product_matrix' .== 0)
|
||||||
|
if idx != 0
|
||||||
|
warn("Product is not supported on basis")
|
||||||
|
i,j = ind2sub(product_matrix, idx)
|
||||||
|
x = basis[i]
|
||||||
|
if twisted
|
||||||
|
x = inv(x)
|
||||||
|
end
|
||||||
|
throw(KeyError(x*basis[j]))
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
create_pm{T<:GroupElem}(b::Vector{T}) = create_pm(b, reverse_dict(b))
|
create_pm{T<:GroupElem}(b::Vector{T}) = create_pm(b, reverse_dict(b))
|
||||||
|
|
||||||
function complete!(RG::GroupRing)
|
function complete!(RG::GroupRing)
|
||||||
@ -539,12 +558,21 @@ function complete!(RG::GroupRing)
|
|||||||
RG.basis = [elements(RG.group)...]
|
RG.basis = [elements(RG.group)...]
|
||||||
end
|
end
|
||||||
|
|
||||||
fastm!(RG, fill=true)
|
fastm!(RG, fill=false)
|
||||||
|
|
||||||
|
warning = false
|
||||||
for linidx in find(RG.pm .== 0)
|
for linidx in find(RG.pm .== 0)
|
||||||
i,j = ind2sub(size(RG.pm), linidx)
|
i,j = ind2sub(size(RG.pm), linidx)
|
||||||
RG.pm[i,j] = RG.basis_dict[RG.basis[i]*RG.basis[j]]
|
g = RG.basis[i]*RG.basis[j]
|
||||||
|
if haskey(RG.basis_dict, g)
|
||||||
|
RG.pm[i,j] = RG.basis_dict[g]
|
||||||
|
else
|
||||||
|
if !warning
|
||||||
|
warning = true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
warning && warn("Some products were not supported on basis")
|
||||||
return RG
|
return RG
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@ using Nemo
|
|||||||
F = FreeGroup(3)
|
F = FreeGroup(3)
|
||||||
S = gens(F)
|
S = gens(F)
|
||||||
append!(S, [inv(s) for s in S])
|
append!(S, [inv(s) for s in S])
|
||||||
S = unique(S)
|
|
||||||
|
|
||||||
basis, sizes = Groups.generate_balls(S, F(), radius=4)
|
basis, sizes = Groups.generate_balls(S, F(), radius=4)
|
||||||
d = GroupRings.reverse_dict(basis)
|
d = GroupRings.reverse_dict(basis)
|
||||||
@ -58,6 +57,15 @@ using Nemo
|
|||||||
B = GroupRing(F, basis, d, pm)
|
B = GroupRing(F, basis, d, pm)
|
||||||
@test A == B
|
@test A == B
|
||||||
|
|
||||||
|
RF = GroupRing(F, basis, d, create_pm(basis, d, check=false))
|
||||||
|
nz1 = countnz(RF.pm)
|
||||||
|
@test nz1 > 1000
|
||||||
|
|
||||||
|
GroupRings.complete!(RF)
|
||||||
|
nz2 = countnz(RF.pm)
|
||||||
|
@test nz2 > nz1
|
||||||
|
@test nz2 == 45469
|
||||||
|
|
||||||
g = B()
|
g = B()
|
||||||
s = S[2]
|
s = S[2]
|
||||||
g[s] = 1
|
g[s] = 1
|
||||||
|
Loading…
Reference in New Issue
Block a user