Skip to content

Commit

Permalink
Incorporate linear independence check into ArcDiagBasis generation
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Feb 23, 2024
1 parent 0d49beb commit d186672
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 28 deletions.
13 changes: 5 additions & 8 deletions src/DeformationBases/ArcDiagDeformBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,11 @@ struct ArcDiagDeformBasis{C <: RingElem} <: DeformBasis{C}
iter = Iterators.flatten(iters)
if !no_normalize
iter = unique(Iterators.filter(b -> !iszero(b), iter))
collected = Vector{eltype(iter)}(collect(iter))
if !isempty(collected)
_, 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)
end
iter = collected
len = length(iter)
collected = Vector{DeformationMap{C}}(collect(iter))
_, 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{C}(length(collected), collected, extra_data, normalize)
end
return new{C}(len, iter, extra_data, normalize)
end
Expand Down
13 changes: 5 additions & 8 deletions src/DeformationBases/PseudographDeformBasis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,11 @@ struct PseudographDeformBasis{C <: RingElem} <: DeformBasis{C}
iter = Iterators.flatten(iters)
if !no_normalize
iter = unique(Iterators.filter(b -> !iszero(b), iter))
collected = Vector{eltype(iter)}(collect(iter))
if !isempty(collected)
_, 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)
end
iter = collected
len = length(iter)
collected = Vector{DeformationMap{C}}(collect(iter))
_, 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{C}(length(collected), collected, extra_data, normalize)
end
return new{C}(len, iter, extra_data, normalize)
end
Expand Down
18 changes: 6 additions & 12 deletions test/DeformationBases-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@
@test all_pbwdeformations(sp, b) == collect(b)

b = ArcDiagDeformBasis{QQFieldElem}(sp, 0:3)
@test length(collect(b)) == 4
@test all_pbwdeformations(sp, b; special_return=SMat)[1] ==
matrix(QQ, 4, 3, [1, 0, 0, 0, -3 // 2, 1 // 2, 0, 1, 0, 0, 0, 1])
@test length(collect(b)) == 3
@test all_pbwdeformations(sp, b; special_return=SMat)[1] == matrix(QQ, [1 0; 0 -3//2; 0 1])
ms = all_pbwdeformations(sp, b)
@test length(ms) == 3
@test length(ms) == 2
@test ms[1] == collect(b)[1]
@test 2 * ms[2] == -3 * collect(b)[2] + 2 * collect(b)[3]
@test 2 * ms[3] == 1 * collect(b)[2] + 2 * collect(b)[4]
@test iszero(ms[2] + ms[3]) # TODO: Check result for linear independence
end

@testset "SO_5, ⋀²V" begin
Expand Down Expand Up @@ -139,15 +136,12 @@
@test all_pbwdeformations(sp, b) == collect(b)

b = PseudographDeformBasis{QQFieldElem}(sp, 0:3)
@test length(collect(b)) == 4
@test all_pbwdeformations(sp, b; special_return=SMat)[1] ==
matrix(QQ, 4, 3, [1, 0, 0, 0, -3 // 2, 1 // 2, 0, 1, 0, 0, 0, 1])
@test length(collect(b)) == 3
@test all_pbwdeformations(sp, b; special_return=SMat)[1] == matrix(QQ, [1 0; 0 -3//2; 0 1])
ms = all_pbwdeformations(sp, b)
@test length(ms) == 3
@test length(ms) == 2
@test ms[1] == collect(b)[1]
@test 2 * ms[2] == -3 * collect(b)[2] + 2 * collect(b)[3]
@test 2 * ms[3] == 1 * collect(b)[2] + 2 * collect(b)[4]
@test iszero(ms[2] + ms[3])
end

@testset "SO_5, ⋀²V" begin
Expand Down

0 comments on commit d186672

Please sign in to comment.