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..de70527ae 100644 --- a/test/resolution/sresolution-test.jl +++ b/test/resolution/sresolution-test.jl @@ -107,3 +107,16 @@ 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, y ) + v2 = vector(R, x) + v3 = vector(R, x+y) + + 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])) +end