2018-09-05 08:58:46 +02:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Laplacians
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
function spLaplacian(RG::GroupRing, S, T::Type=Float64)
|
|
|
|
result = RG(T)
|
|
|
|
result[RG.group()] = T(length(S))
|
|
|
|
for s in S
|
|
|
|
result[s] -= one(T)
|
|
|
|
end
|
|
|
|
return result
|
|
|
|
end
|
|
|
|
|
|
|
|
function spLaplacian(RG::GroupRing{R}, S, T::Type=Float64) where {R<:Ring}
|
|
|
|
result = RG(T)
|
|
|
|
result[one(RG.group)] = T(length(S))
|
|
|
|
for s in S
|
|
|
|
result[s] -= one(T)
|
|
|
|
end
|
|
|
|
return result
|
|
|
|
end
|
|
|
|
|
2018-09-16 18:01:44 +02:00
|
|
|
function Laplacian(S::Vector{E}, radius) where E<:AbstractAlgebra.RingElem
|
2018-09-05 08:58:46 +02:00
|
|
|
R = parent(first(S))
|
2018-09-16 18:01:44 +02:00
|
|
|
return Laplacian(S, one(R), radius)
|
2018-09-05 08:58:46 +02:00
|
|
|
end
|
|
|
|
|
2018-09-16 18:01:44 +02:00
|
|
|
function Laplacian(S::Vector{E}, radius) where E<:AbstractAlgebra.GroupElem
|
2018-09-05 08:58:46 +02:00
|
|
|
G = parent(first(S))
|
2018-09-16 18:01:44 +02:00
|
|
|
return Laplacian(S, G(), radius)
|
2018-09-05 08:58:46 +02:00
|
|
|
end
|
|
|
|
|
2018-09-16 18:01:44 +02:00
|
|
|
function Laplacian(S, Id, radius)
|
2019-01-11 06:32:09 +01:00
|
|
|
@info("Generating metric ball of radius $(2radius)...")
|
2018-09-05 08:58:46 +02:00
|
|
|
@time E_R, sizes = Groups.generate_balls(S, Id, radius=2radius)
|
2019-01-11 06:32:09 +01:00
|
|
|
@info("Generated balls of sizes $sizes.")
|
2018-09-05 08:58:46 +02:00
|
|
|
|
|
|
|
@time pm = GroupRings.create_pm(E_R, GroupRings.reverse_dict(E_R), sizes[radius]; twisted=true)
|
2019-01-11 06:32:09 +01:00
|
|
|
@info("Creating product matrix...")
|
2018-09-05 08:58:46 +02:00
|
|
|
|
|
|
|
RG = GroupRing(parent(Id), E_R, pm)
|
|
|
|
Δ = spLaplacian(RG, S)
|
|
|
|
return Δ
|
|
|
|
end
|
|
|
|
|
2018-09-16 18:02:35 +02:00
|
|
|
function saveGRElem(filename::String, g::GroupRingElem)
|
|
|
|
RG = parent(g)
|
|
|
|
JLD.save(filename, "coeffs", g.coeffs, "pm", RG.pm, "G", RG.group)
|
|
|
|
end
|
|
|
|
|
|
|
|
function loadGRElem(fname::String, G::Group)
|
|
|
|
if isfile(fname)
|
2019-01-11 06:32:09 +01:00
|
|
|
@info("Loading precomputed Δ...")
|
2018-09-16 18:02:35 +02:00
|
|
|
coeffs, pm = load(fname, "coeffs", "pm")
|
|
|
|
RG = GroupRing(G, pm)
|
|
|
|
Δ = GroupRingElem(coeffs, RG)
|
2018-09-05 08:58:46 +02:00
|
|
|
else
|
2018-09-16 18:02:35 +02:00
|
|
|
throw(ErrorException("You need to precompute $fname first!"))
|
2018-09-05 08:58:46 +02:00
|
|
|
end
|
|
|
|
return Δ
|
|
|
|
end
|