mirror of
https://github.com/kalmarek/GroupRings.jl.git
synced 2024-11-14 21:25:28 +01:00
add check_pm function to test against zeros;
Since we can not throw from a thread, after introduction of Threading into create_pm doesn't warn user on the possible not supported product. Indeed threading quits immediately after first error is thrown, leaving the pm matrix under-populated; we check on zeros and warn the user on the situation;
This commit is contained in:
parent
0e8cec9f41
commit
e223763b75
@ -518,7 +518,7 @@ function reverse_dict(iter)
|
||||
end
|
||||
|
||||
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))
|
||||
Threads.@threads for i in 1:limit
|
||||
x = basis[i]
|
||||
@ -526,12 +526,29 @@ function create_pm{T<:GroupElem}(basis::Vector{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] = basis_dict[x*basis[j]]
|
||||
end
|
||||
end
|
||||
|
||||
check && check_pm(product_matrix, basis, twisted)
|
||||
|
||||
return product_matrix
|
||||
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))
|
||||
|
||||
function complete!(RG::GroupRing)
|
||||
|
Loading…
Reference in New Issue
Block a user