1
0
mirror of https://github.com/kalmarek/GroupRings.jl.git synced 2024-11-19 06:30:27 +01:00

replace fastm keyword by cachedmul

This commit is contained in:
kalmarek 2019-01-09 16:53:44 +01:00
parent 43b10d8029
commit e39a1c8b4d
2 changed files with 19 additions and 15 deletions

View File

@ -22,9 +22,10 @@ mutable struct GroupRing{Gr<:Group, T<:GroupElem} <: Ring
basis_dict::Dict{T, Int} basis_dict::Dict{T, Int}
pm::Array{Int,2} pm::Array{Int,2}
function GroupRing(G::Gr, basis::Vector{T}; fastm::Bool=false) where {Gr, T} function GroupRing(G::Gr, basis::Vector{T};
cachedmul::Bool=false) where {Gr, T}
RG = new{Gr, T}(G, basis, reverse_dict(basis)) RG = new{Gr, T}(G, basis, reverse_dict(basis))
fastm && fastm!(RG) cachedmul && initializepm!(RG)
return RG return RG
end end
@ -69,8 +70,8 @@ function GroupRingElem(c::AbstractVector, RG::GroupRing)
return GroupRingElem{eltype(c), typeof(c), typeof(RG)}(c, RG) return GroupRingElem{eltype(c), typeof(c), typeof(RG)}(c, RG)
end end
function GroupRing(G::Generic.PermGroup; fastm::Bool=false) function GroupRing(G::Generic.PermGroup; cachedmul::Bool=false)
return GroupRing(G, vec(collect(G)), fastm=fastm) return GroupRing(G, vec(collect(G)), cachedmul=cachedmul)
end end
function GroupRing(G::Group, basis::Vector, pm::Array{Int,2}) function GroupRing(G::Group, basis::Vector, pm::Array{Int,2})
@ -272,9 +273,9 @@ end
function (==)(A::GroupRing, B::GroupRing) function (==)(A::GroupRing, B::GroupRing)
A.group == B.group || return false A.group == B.group || return false
if isdefined(A, :pm) && isdefined(B, :pm) if isdefined(A, :basis) && isdefined(B, :basis)
complete!(A) A.basis == B.basis || return false
complete!(B) elseif isdefined(A, :pm) && isdefined(B, :pm)
A.pm == B.pm || return false A.pm == B.pm || return false
end end
return true return true
@ -564,7 +565,10 @@ end
function complete!(RG::GroupRing) function complete!(RG::GroupRing)
isdefined(RG, :basis) || throw(ArgumentError("Provide basis for completion first!")) isdefined(RG, :basis) || throw(ArgumentError("Provide basis for completion first!"))
fastm!(RG, fill=false) if !isdefined(RG, :pm)
initializepm!(RG, fill=false)
return RG
end
warning = false warning = false
for idx in findall(RG.pm .== 0) for idx in findall(RG.pm .== 0)
@ -582,7 +586,7 @@ function complete!(RG::GroupRing)
return RG return RG
end end
function fastm!(RG::GroupRing; fill::Bool=false) function initializepm!(RG::GroupRing; fill::Bool=false)
isdefined(RG, :basis) || throw("For baseless Group Rings You need to provide pm.") isdefined(RG, :basis) || throw("For baseless Group Rings You need to provide pm.")
isdefined(RG, :pm) && return RG isdefined(RG, :pm) && return RG
if fill if fill

View File

@ -20,13 +20,13 @@ using SparseArrays
@test isa(GroupRing(PermutationGroup(6), rand(1:6, 6,6)), GroupRing) @test isa(GroupRing(PermutationGroup(6), rand(1:6, 6,6)), GroupRing)
RG = GroupRing(G, fastm=true) RG = GroupRing(G, cachedmul=true)
@test isdefined(RG, :pm) == true @test isdefined(RG, :pm) == true
@test RG.pm == zeros(Int, (6,6)) @test RG.pm == zeros(Int, (6,6))
@test isa(complete!(RG), GroupRing) @test isa(complete!(RG), GroupRing)
@test all(RG.pm .> 0) @test all(RG.pm .> 0)
@test RG.pm == GroupRings.fastm!(GroupRing(G, fastm=false), fill=true).pm @test RG.pm == GroupRings.initializepm!(GroupRing(G, cachedmul=false), fill=true).pm
@test RG.basis_dict == GroupRings.reverse_dict(collect(G)) @test RG.basis_dict == GroupRings.reverse_dict(collect(G))
@ -80,7 +80,7 @@ using SparseArrays
@testset "GroupRingElems constructors/basic manipulation" begin @testset "GroupRingElems constructors/basic manipulation" begin
G = PermutationGroup(3) G = PermutationGroup(3)
RG = GroupRing(G, fastm=true) RG = GroupRing(G, cachedmul=true)
a = rand(6) a = rand(6)
@test isa(GroupRingElem(a, RG), GroupRingElem) @test isa(GroupRingElem(a, RG), GroupRingElem)
@test isa(RG(a), GroupRingElem) @test isa(RG(a), GroupRingElem)
@ -119,7 +119,7 @@ using SparseArrays
@testset "Arithmetic" begin @testset "Arithmetic" begin
G = PermutationGroup(3) G = PermutationGroup(3)
RG = GroupRing(G, fastm=true) RG = GroupRing(G, cachedmul=true)
a = RG(ones(Int, order(G))) a = RG(ones(Int, order(G)))
@testset "scalar operators" begin @testset "scalar operators" begin
@ -214,8 +214,8 @@ using SparseArrays
@testset "HPC multiplicative operations" begin @testset "HPC multiplicative operations" begin
G = PermutationGroup(5) G = PermutationGroup(5)
RG = GroupRing(G, fastm=true) RG = GroupRing(G, cachedmul=true)
RG2 = GroupRing(G, fastm=false) RG2 = GroupRing(G, cachedmul=false)
Z = RG() Z = RG()
W = RG() W = RG()