Skip to content

Commit

Permalink
Revise normalization handling (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Nov 6, 2024
1 parent 204f4a0 commit 23062ba
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
7 changes: 3 additions & 4 deletions src/DeformationBases/ArcDiagDeformBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct ArcDiagDeformBasis{T <: SmashProductLieElem} <: DeformBasis{T}
len::Int
iter
extra_data::Dict{DeformationMap{T}, Set{ArcDiagram}}
normalize
no_normalize::Bool

function ArcDiagDeformBasis(
sp::SmashProductLie{C, LieC, LieT},
Expand Down Expand Up @@ -44,7 +44,6 @@ struct ArcDiagDeformBasis{T <: SmashProductLieElem} <: DeformBasis{T}
end

extra_data = Dict{DeformationMap{elem_type(sp)}, Set{ArcDiagram}}()
normalize = no_normalize ? identity : normalize_default

n_cases = div(length(V_nice_summands) * (length(V_nice_summands) + 1), 2)
lens = Int[]
Expand Down Expand Up @@ -107,9 +106,9 @@ struct ArcDiagDeformBasis{T <: SmashProductLieElem} <: DeformBasis{T}
_, rels = is_linearly_independent_with_relations(coefficient_ring(sp), collected)
inds = [findlast(!iszero, vec(rels[i, :]))::Int for i in 1:nrows(rels)]
deleteat!(collected, inds)
return new{elem_type(sp)}(length(collected), collected, extra_data, normalize)
return new{elem_type(sp)}(length(collected), collected, extra_data, no_normalize)
end
return new{elem_type(sp)}(len, iter, extra_data, normalize)
return new{elem_type(sp)}(len, iter, extra_data, no_normalize)
end
end

Expand Down
6 changes: 4 additions & 2 deletions src/DeformationBases/DeformBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ Look up additional data that was used to generate the deformation map `m` in the
This can e.g. be an arc diagram or a pseudograph.
"""
function lookup_data(m::DeformationMap{T}, basis::DeformBasis{T}) where {T <: SmashProductLieElem}
m = basis.normalize(m)
if !basis.no_normalize
m = normalize(m)
end
if haskey(basis.extra_data, m)
return basis.extra_data[m]
else
return nothing
end
end

function normalize_default(m::DeformationMap{T}) where {T <: SmashProductLieElem}
function normalize(m::DeformationMap{T}) where {T <: SmashProductLieElem}
nz_index = findfirst(x -> !iszero(x), m)
if nz_index === nothing
return m
Expand Down
7 changes: 3 additions & 4 deletions src/DeformationBases/PseudographDeformBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct PseudographDeformBasis{T <: SmashProductLieElem} <: DeformBasis{T}
len::Int
iter
extra_data::Dict{DeformationMap{T}, Set{Tuple{PseudographLabelled{Int}, Partition{Int}}}}
normalize
no_normalize::Bool

function PseudographDeformBasis(
sp::SmashProductLie{C, LieC, LieT},
Expand All @@ -34,7 +34,6 @@ struct PseudographDeformBasis{T <: SmashProductLieElem} <: DeformBasis{T}
@req fl && _is_standard_module(Vbase) "Only works for exterior powers of the standard module."

extra_data = Dict{DeformationMap{elem_type(sp)}, Set{Tuple{PseudographLabelled{Int}, Partition{Int}}}}()
normalize = no_normalize ? identity : normalize_default

lens = []
iters = []
Expand Down Expand Up @@ -69,9 +68,9 @@ struct PseudographDeformBasis{T <: SmashProductLieElem} <: DeformBasis{T}
_, rels = is_linearly_independent_with_relations(coefficient_ring(sp), reverse(collected))
inds = [1 + ncols(rels) - (findfirst(!iszero, vec(rels[i, :]))::Int) for i in nrows(rels):-1:1]
deleteat!(collected, inds)
return new{elem_type(sp)}(length(collected), collected, extra_data, normalize)
return new{elem_type(sp)}(length(collected), collected, extra_data, no_normalize)
end
return new{elem_type(sp)}(len, iter, extra_data, normalize)
return new{elem_type(sp)}(len, iter, extra_data, no_normalize)
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/DeformationBases/StdDeformBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct StdDeformBasis{T <: SmashProductLieElem} <: DeformBasis{T}
len::Int
iter
extra_data::Dict{DeformationMap{T}, Nothing}
normalize
no_normalize::Bool

function StdDeformBasis(
sp::SmashProductLie{C, LieC, LieT},
Expand All @@ -27,7 +27,7 @@ struct StdDeformBasis{T <: SmashProductLieElem} <: DeformBasis{T}
)

len = div(dimV * (dimV - 1), 2) * sum(binomial(dimL + k - 1, k) for k in degs)
return new{elem_type(sp)}(len, iter, Dict{DeformationMap{elem_type(sp)}, Nothing}(), normalize_default)
return new{elem_type(sp)}(len, iter, Dict{DeformationMap{elem_type(sp)}, Nothing}(), false)
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/DeformationBases-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
end

@testset "SO_2, T³V" begin
deformmap(sp::SmashProductLie, diag::String) = PBWDeformations.normalize_default(
deformmap(sp::SmashProductLie, diag::String) = PBWDeformations.normalize(
PBWDeformations.arcdiag_to_deformationmap(PBWDeformations.SO(), arc_diagram(Undirected, diag), sp),
)

Expand All @@ -142,7 +142,7 @@
end

@testset "SO_3, T³V" begin
deformmap(sp::SmashProductLie, diag::String) = PBWDeformations.normalize_default(
deformmap(sp::SmashProductLie, diag::String) = PBWDeformations.normalize(
PBWDeformations.arcdiag_to_deformationmap(PBWDeformations.SO(), arc_diagram(Undirected, diag), sp),
)

Expand Down

0 comments on commit 23062ba

Please sign in to comment.