From d1866723763b34fcfd355c21b53c74b3c32e284e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Tue, 13 Feb 2024 18:13:46 +0100 Subject: [PATCH] Incorporate linear independence check into ArcDiagBasis generation --- src/DeformationBases/ArcDiagDeformBasis.jl | 13 +++++-------- src/DeformationBases/PseudographDeformBasis.jl | 13 +++++-------- test/DeformationBases-test.jl | 18 ++++++------------ 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/DeformationBases/ArcDiagDeformBasis.jl b/src/DeformationBases/ArcDiagDeformBasis.jl index 587eb75..bf1a5a4 100644 --- a/src/DeformationBases/ArcDiagDeformBasis.jl +++ b/src/DeformationBases/ArcDiagDeformBasis.jl @@ -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 diff --git a/src/DeformationBases/PseudographDeformBasis.jl b/src/DeformationBases/PseudographDeformBasis.jl index dd3295b..9d91bef 100644 --- a/src/DeformationBases/PseudographDeformBasis.jl +++ b/src/DeformationBases/PseudographDeformBasis.jl @@ -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 diff --git a/test/DeformationBases-test.jl b/test/DeformationBases-test.jl index b595ad1..b036489 100644 --- a/test/DeformationBases-test.jl +++ b/test/DeformationBases-test.jl @@ -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 @@ -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