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)
|
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] = get(basis_dict, x*basis[j], 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -553,16 +553,13 @@ function check_pm(product_matrix, basis, twisted=false)
|
|||||||
if idx != nothing
|
if idx != nothing
|
||||||
@warn("Product is not supported on basis")
|
@warn("Product is not supported on basis")
|
||||||
i,j = Tuple(idx)
|
i,j = Tuple(idx)
|
||||||
x = basis[i]
|
x = (twisted ? inv(basis[i]) : basis[i])
|
||||||
if twisted
|
|
||||||
x = inv(x)
|
|
||||||
end
|
|
||||||
throw(KeyError(x*basis[j]))
|
throw(KeyError(x*basis[j]))
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function complete!(RG::GroupRing)
|
function complete!(RG::GroupRing, twisted::Bool=false)
|
||||||
isdefined(RG, :basis) || throw(ArgumentError("Provide basis for completion first!"))
|
isdefined(RG, :basis) || throw(ArgumentError("Provide basis for completion first!"))
|
||||||
if !isdefined(RG, :pm)
|
if !isdefined(RG, :pm)
|
||||||
initializepm!(RG, fill=false)
|
initializepm!(RG, fill=false)
|
||||||
@ -572,13 +569,11 @@ function complete!(RG::GroupRing)
|
|||||||
warning = false
|
warning = false
|
||||||
for idx in findall(RG.pm .== 0)
|
for idx in findall(RG.pm .== 0)
|
||||||
i,j = Tuple(idx)
|
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)
|
if haskey(RG.basis_dict, g)
|
||||||
RG.pm[i,j] = RG.basis_dict[g]
|
RG.pm[i,j] = RG.basis_dict[g]
|
||||||
else
|
else
|
||||||
if !warning
|
warning = true
|
||||||
warning = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
warning && @warn("Some products were not supported on basis")
|
warning && @warn("Some products were not supported on basis")
|
||||||
|
@ -61,14 +61,11 @@ using SparseArrays
|
|||||||
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))
|
RF = GroupRing(F, basis, cachedmul=true)
|
||||||
nz1 = count(!iszero, RF.pm)
|
@test count(!iszero, RF.pm) == 0
|
||||||
@test nz1 > 1000
|
|
||||||
|
|
||||||
GroupRings.complete!(RF)
|
GroupRings.complete!(RF)
|
||||||
nz2 = count(!iszero, RF.pm)
|
@test count(!iszero, RF.pm) == 45469
|
||||||
@test nz2 > nz1
|
|
||||||
@test nz2 == 45469
|
|
||||||
|
|
||||||
g = B()
|
g = B()
|
||||||
s = S[2]
|
s = S[2]
|
||||||
|
Loading…
Reference in New Issue
Block a user