Skip to content

Commit

Permalink
add mres_with_map
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes14 committed Aug 23, 2023
1 parent 0050da0 commit 04e6c87
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
25 changes: 25 additions & 0 deletions deps/src/ideals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@ auto id_res_helper(sip_sideal * I, int n, int minimize, ring R)
return std::make_tuple(s, minimal);
}

auto id_mres_map_helper(sip_sideal * I, int n, ring R)
{
auto origin = currRing;
rChangeCurrRing(R);
ideal T;
syStrategy s = syMres_with_map(I, n, NULL, T);
matrix TT=id_Module2Matrix(T,currRing);
rChangeCurrRing(origin);
auto r = s->minres;
bool minimal = true;
if (r == NULL) {
r = s->fullres;
}
for(int i=0;i<=n+1;i++)
{
if (r[i]==NULL)
{
r[i]=idInit(1,1);
break;
}
}
return std::make_tuple(s, TT);
}

ideal id_Syzygies_internal(ideal m, ring o)
{
ideal id = NULL;
Expand Down Expand Up @@ -339,6 +363,7 @@ void singular_define_ideals(jlcxx::Module & Singular)
Singular.method("id_fres", &id_fres_helper);

Singular.method("id_res", &id_res_helper);
Singular.method("id_mres_map", &id_mres_map_helper);

Singular.method("id_Slimgb", &id_Slimgb_helper);

Expand Down
23 changes: 22 additions & 1 deletion src/ideal/ideal.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export sideal, IdealSet, syz, lead, normalize!, is_constant, is_zerodim, fglm,
fres, dimension, highcorner, jet, kbase, minimal_generating_set,
independent_sets, maximal_independent_set, mres, ngens, nres, sres,
independent_sets, maximal_independent_set, mres, mres_with_map,
ngens, nres, sres,
intersection, homogenize_ideal, homogenize_ideal_with_weights,
quotient, reduce, eliminate, kernel, equal, contains, is_var_generated,
saturation, saturation2, satstd, slimgb, std, vdim, interreduce, degree, mult,
Expand Down Expand Up @@ -986,6 +987,26 @@ function mres(I::sideal{spoly{T}}, max_length::Int) where T <: Nemo.FieldElem
return sresolution{spoly{T}}(R, r, Bool(minimal), true)
end

@doc raw"""
mres_with_map(id::sideal{spoly{T}}, max_length::Int) where T <: Nemo.FieldElem
Compute a minimal (free) resolution of the given ideal up to the maximum
given length. The ideal 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 ideal.
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::sideal{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, true),smatrix{spoly{T}}(R,TT_ptr)
end

@doc raw"""
nres(id::sideal{spoly{T}}, max_length::Int) where T <: Nemo.FieldElem
Expand Down
6 changes: 6 additions & 0 deletions test/ideal/sideal-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ end
F2 = @inferred sres(std(I), 4)
F3 = @inferred nres(I, 4)
F4 = @inferred mres(I, 4)
F5,TT = @inferred mres_with_map(I, 4)

# check resolution is of the correct length
@test (@inferred length(F1)) == 2
Expand All @@ -494,11 +495,16 @@ end
M4 = @inferred Singular.Matrix(F4[1])
N4 = @inferred Singular.Matrix(F4[2])

M5 = @inferred Singular.Matrix(F5[1])
N5 = @inferred Singular.Matrix(F5[2])

# check we have a complex
@test iszero(M1*N1)
@test iszero(M2*N2)
@test iszero(M3*N3)
@test iszero(M4*N4)
@test iszero(M5*N5)
@test iszero(Singular.Matrix(I)*TT-M5)
end

@testset "sideal.syzygy" begin
Expand Down

0 comments on commit 04e6c87

Please sign in to comment.