From f57e226e85e9cc3804f423af9124fcf9c5f7de61 Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Tue, 23 Jan 2024 09:41:53 +0100 Subject: [PATCH] add prune_with_map_projection (#751) * add prune_with_map_projection * test prune_with_map_projection * Update src/module/module.jl Co-authored-by: Max Horn * docstring for prune_with_map_projection * Update src/module/module.jl --------- Co-authored-by: Max Horn Co-authored-by: ederc --- src/module/module.jl | 20 +++++++++++++++++++- test/module/smodule-test.jl | 5 +++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/module/module.jl b/src/module/module.jl index af52fb695..f780674d8 100644 --- a/src/module/module.jl +++ b/src/module/module.jl @@ -1,5 +1,6 @@ export jet, minimal_generating_set, ModuleClass, rank, smodule, slimgb, - eliminate, modulo, lift, division, divrem, prune_with_map + eliminate, modulo, lift, division, divrem, prune_with_map, + prune_with_map_projection ############################################################################### # @@ -407,6 +408,23 @@ function prune_with_map(I::smodule{spoly{T}}) where T <: Nemo.FieldElem return smodule{spoly{T}}(R, r),smatrix{spoly{T}}(R,TT_ptr) end +@doc raw""" + prune_with_map_projection(id::smodule{spoly{T}}) where T <: Nemo.FieldElem + +Return a module `R`, a transformation matrix `M` and a projection map `p` +satisfying the following properties: `R` is minimally embedded in a free +module `parent(R)` such that the quotient `parent(R)/R` is isomorphic to +`parent(id)/id`, with `M` together with the projection given by the vector `p` +describing this isomorphism. +`p` maps `gen(parent(id),i)` to `gen(parent(R),p[i])` +""" +function prune_with_map_projection(I::smodule{spoly{T}}) where T <: Nemo.FieldElem + R = base_ring(I) + a = Vector{Int32}() + r, TT_ptr = GC.@preserve I R libSingular.id_prune_map_v(I.ptr, a, R.ptr) + return smodule{spoly{T}}(R, r),smatrix{spoly{T}}(R,TT_ptr),a +end + @doc raw""" nres(id::smodule{spoly{T}}, max_length::Int) where T <: Nemo.FieldElem diff --git a/test/module/smodule-test.jl b/test/module/smodule-test.jl index b5c6c293f..46c0ffe8a 100644 --- a/test/module/smodule-test.jl +++ b/test/module/smodule-test.jl @@ -324,4 +324,9 @@ end @test G[1] == vector(R, z) @test T[3,1] == R(1) + G,T,p = prune_with_map_projection(M) + @test p[1] == 1 + @test p[2] == 1 + @test p[3] == 2 + end