mirror of
https://github.com/kalmarek/GroupRings.jl.git
synced 2024-10-15 07:50:35 +02:00
use get in create_pm
This commit is contained in:
parent
d574b2a881
commit
82ca5abed3
@ -537,7 +537,7 @@ function create_pm(basis::AbstractVector{T}, basis_dict::Dict{T, Int},
|
||||
x = inv(x)
|
||||
end
|
||||
for j in 1:limit
|
||||
product_matrix[i,j] = basis_dict[x*basis[j]]
|
||||
product_matrix[i,j] = get(basis_dict, x*basis[j], 0)
|
||||
end
|
||||
end
|
||||
|
||||
@ -553,16 +553,13 @@ function check_pm(product_matrix, basis, twisted=false)
|
||||
if idx != nothing
|
||||
@warn("Product is not supported on basis")
|
||||
i,j = Tuple(idx)
|
||||
x = basis[i]
|
||||
if twisted
|
||||
x = inv(x)
|
||||
end
|
||||
x = (twisted ? inv(basis[i]) : basis[i])
|
||||
throw(KeyError(x*basis[j]))
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function complete!(RG::GroupRing)
|
||||
function complete!(RG::GroupRing, twisted::Bool=false)
|
||||
isdefined(RG, :basis) || throw(ArgumentError("Provide basis for completion first!"))
|
||||
if !isdefined(RG, :pm)
|
||||
initializepm!(RG, fill=false)
|
||||
@ -572,13 +569,11 @@ function complete!(RG::GroupRing)
|
||||
warning = false
|
||||
for idx in findall(RG.pm .== 0)
|
||||
i,j = Tuple(idx)
|
||||
g = RG.basis[i]*RG.basis[j]
|
||||
g = (twisted ? inv(RG.basis[i]) : 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
|
||||
warning = true
|
||||
end
|
||||
end
|
||||
warning && @warn("Some products were not supported on basis")
|
||||
|
@ -61,14 +61,11 @@ using SparseArrays
|
||||
B = GroupRing(F, basis, d, pm)
|
||||
@test A == B
|
||||
|
||||
RF = GroupRing(F, basis, d, create_pm(basis, d, check=false))
|
||||
nz1 = count(!iszero, RF.pm)
|
||||
@test nz1 > 1000
|
||||
RF = GroupRing(F, basis, cachedmul=true)
|
||||
@test count(!iszero, RF.pm) == 0
|
||||
|
||||
GroupRings.complete!(RF)
|
||||
nz2 = count(!iszero, RF.pm)
|
||||
@test nz2 > nz1
|
||||
@test nz2 == 45469
|
||||
@test count(!iszero, RF.pm) == 45469
|
||||
|
||||
g = B()
|
||||
s = S[2]
|
||||
|
Loading…
Reference in New Issue
Block a user