-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds free resolutions over quotient rings by using Singular.sres
#4134
Changes from 9 commits
6b9dcc6
f8a555b
3d35d0a
6925b56
f47f456
14c7ab3
452dd02
8588359
71cbe8c
5c2a895
bb81af4
16985d5
846a464
11bf9f4
de3ec65
3db4e44
64f6b44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,22 +261,49 @@ end | |
|
||
Convert a Singular vector to a free module element. | ||
""" | ||
function (F::FreeMod)(s::Singular.svector) | ||
pos = Int[] | ||
values = [] | ||
function (F::FreeMod{<:MPolyRingElem})(s::Singular.svector) | ||
Rx = base_ring(F) | ||
R = base_ring(Rx) | ||
for (i, e, c) = s | ||
f = Base.findfirst(==(i), pos) | ||
if f === nothing | ||
push!(values, MPolyBuildCtx(base_ring(F))) | ||
f = length(values) | ||
push!(pos, i) | ||
R = coefficient_ring(Rx) | ||
ctx = MPolyBuildCtx(Rx) | ||
|
||
# shortcut in order not to allocate the dictionary | ||
# if isone(length(s)) # TODO: length doesn't work! | ||
# (i, e, c) = first(s) | ||
# push_term!(ctx, R(c), e) | ||
# return FreeModElem(sparse_row(Qx, [(i, finish(ctx))])) | ||
# end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does anyone know what is the correct way to check whether a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. length(p::svector) = Int(libSingular.pLength(p.ptr)) should do it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update: @hannes14 's PR on Singular.jl just got merged. Do we have to wait for a release there? Or can we remove the method here already? ping @lgoettgens There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You will need to wait for a new release of Singular.jl, and then adapt the |
||
|
||
cache = IdDict{Int, typeof(ctx)}() | ||
for (i, e, c) in s | ||
ctx = get!(cache, i) do | ||
MPolyBuildCtx(Rx) | ||
end | ||
push_term!(values[f], R(c), e) | ||
push_term!(ctx, R(c), e) | ||
end | ||
pv = Tuple{Int, elem_type(Rx)}[(pos[i], base_ring(F)(finish(values[i]))) for i=1:length(pos)] | ||
return FreeModElem(sparse_row(base_ring(F), pv), F) | ||
return FreeModElem(sparse_row(Rx, [(i, finish(ctx)) for (i, ctx) in cache]), F) | ||
end | ||
|
||
function (F::FreeMod{<:MPolyQuoRingElem})(s::Singular.svector) | ||
Qx = base_ring(F)::MPolyQuoRing | ||
Rx = base_ring(Qx)::MPolyRing | ||
R = coefficient_ring(Rx) | ||
ctx = MPolyBuildCtx(Rx) | ||
|
||
# shortcut in order not to allocate the dictionary | ||
# if isone(length(s)) # TODO: length doesn't work! | ||
# (i, e, c) = first(s) | ||
# push_term!(ctx, R(c), e) | ||
# return FreeModElem(sparse_row(Qx, [(i, Qx(finish(ctx)))])) | ||
# end | ||
|
||
cache = IdDict{Int, typeof(ctx)}() | ||
for (i, e, c) in s | ||
ctx = get!(cache, i) do | ||
MPolyBuildCtx(Rx) | ||
end | ||
push_term!(ctx, R(c), e) | ||
end | ||
return FreeModElem(sparse_row(Qx, [(i, Qx(finish(ctx))) for (i, ctx) in cache]), F) | ||
end | ||
|
||
# After creating the required infrastruture in Singular, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Singular's sres sets a default of nvars(basering) modules to be computed, if no length is specified. It might be better for compatibility to document this fallback instead of throwing an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking a look. Having this default nvars(basering) length is the same they had in Macaulay2, they told me that they removed this at some point for clarity for the users.
But if you prefer to have this default, I will of course make the appropriate changes.