From b3be7273c1b895f705b34dc1c8822920f62a004a Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Fri, 1 Sep 2023 14:58:03 +0200 Subject: [PATCH 1/2] mres_with_map for smodule --- src/module/module.jl | 20 ++++++++++++++++++++ test/resolution/sresolution-test.jl | 12 ++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/module/module.jl b/src/module/module.jl index 002ee98ea..5f8766923 100644 --- a/src/module/module.jl +++ b/src/module/module.jl @@ -312,6 +312,26 @@ function mres(I::smodule{spoly{T}}, max_length::Int) where T <: Nemo.FieldElem return sresolution{spoly{T}}(R, r, Bool(minimal), false) end +@doc raw""" + mres_with_map(id::smodule{spoly{T}}, max_length::Int) where T <: Nemo.FieldElem + +Compute a minimal (free) resolution of the given module up to the maximum +given length. The module must be over a polynomial ring over a field. +The result is given as a resolution, whose i-th entry is +the syzygy module of the previous module, starting with the given module. +The `max_length` can be set to $0$ if the full free resolution is required. +Returns the resolution R and the transformation matrix of id to R[1]. +""" +function mres_with_map(I::smodule{spoly{T}}, max_length::Int) where T <: Nemo.FieldElem + R = base_ring(I) + if max_length == 0 + max_length = nvars(R) + # TODO: consider qrings + end + r, TT_ptr = GC.@preserve I R libSingular.id_mres_map(I.ptr, Cint(max_length + 1), R.ptr) + return sresolution{spoly{T}}(R, r, true, false),smatrix{spoly{T}}(R,TT_ptr) +end + @doc raw""" nres(id::smodule{spoly{T}}, max_length::Int) where T <: Nemo.FieldElem diff --git a/test/resolution/sresolution-test.jl b/test/resolution/sresolution-test.jl index 4feb7b3fb..cb904457a 100644 --- a/test/resolution/sresolution-test.jl +++ b/test/resolution/sresolution-test.jl @@ -107,3 +107,15 @@ end @test iszero(M1*M2) @test iszero(M2*M3) end + +@testset "sresolution.mres_module" begin + R, (x, y) = polynomial_ring(QQ, ["x", "y"]) + + v1 = vector(R, x + 1, x*y + 1, y) + v2 = vector(R, x^2 + 1, 2x + 3y, x) + + M = Singular.Module(R, v1, v2) + L,TT = mres_with_map(M,0) + @test iszero(Singular.Matrix(M)*TT-Singular.Matrix(L[1])) + @test iszero(Singular.Matrix(L[1])*Singular.Matrix(L[2])) +end From 7566d61c351c2606e0062b2b1c8532cd818cf49e Mon Sep 17 00:00:00 2001 From: Hans Schoenemann Date: Fri, 1 Sep 2023 15:18:53 +0200 Subject: [PATCH 2/2] fix test --- test/resolution/sresolution-test.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/resolution/sresolution-test.jl b/test/resolution/sresolution-test.jl index cb904457a..de70527ae 100644 --- a/test/resolution/sresolution-test.jl +++ b/test/resolution/sresolution-test.jl @@ -111,10 +111,11 @@ end @testset "sresolution.mres_module" begin R, (x, y) = polynomial_ring(QQ, ["x", "y"]) - v1 = vector(R, x + 1, x*y + 1, y) - v2 = vector(R, x^2 + 1, 2x + 3y, x) + v1 = vector(R, y ) + v2 = vector(R, x) + v3 = vector(R, x+y) - M = Singular.Module(R, v1, v2) + M = Singular.Module(R, v1, v2, v3) L,TT = mres_with_map(M,0) @test iszero(Singular.Matrix(M)*TT-Singular.Matrix(L[1])) @test iszero(Singular.Matrix(L[1])*Singular.Matrix(L[2]))