Skip to content

Commit

Permalink
create correct Singular coeffs with create_ring_from_singular_ring (#773
Browse files Browse the repository at this point in the history
)

Co-authored-by: Max Horn <[email protected]>
  • Loading branch information
hannes14 and fingolfin authored Feb 23, 2024
1 parent 7af59ba commit 34a2556
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
32 changes: 32 additions & 0 deletions deps/src/coeffs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,38 @@ void singular_define_coeffs(jlcxx::Module & Singular)
return bool(nCoeff_is_algExt(n));
});

Singular.method("nCoeff_is_Nemo_AnticNumberField", [](coeffs n) {
return n->type==n_Nemo_AnticNumberField;
});

Singular.method("nCoeff_is_Nemo_QQField", [](coeffs n) {
return n->type==n_Nemo_QQField;
});

Singular.method("nCoeff_is_Nemo_ZZRing", [](coeffs n) {
return n->type==n_Nemo_ZZRing;
});

Singular.method("nCoeff_is_Nemo_FqPolyRepField", [](coeffs n) {
return n->type==n_Nemo_FqPolyRepField;
});

Singular.method("nCoeff_is_Nemo_fqPolyRepField", [](coeffs n) {
return n->type==n_Nemo_fqPolyRepField;
});

Singular.method("nCoeff_is_Nemo_Field", [](coeffs n) {
return n->type==n_Nemo_Field;
});

Singular.method("nCoeff_is_Nemo_Ring", [](coeffs n) {
return n->type==n_Nemo_Ring;
});

Singular.method("nGetCoeffData", [](coeffs n) {
return n->data;
});

/* make a copy of a coefficient domain (actually just increments a
* reference count) */
Singular.method("nCopyCoeff", &nCopyCoeff);
Expand Down
6 changes: 6 additions & 0 deletions src/caller.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ function create_ring_from_singular_ring(r::libSingular.ring_ptr)
minpoly = F(libSingular.algExt_GetMinpoly(c, F.ptr))
basering = N_AlgExtField(libSingular.nCopyCoeff(c), minpoly)
T = n_algExt
elseif libSingular.nCoeff_is_Nemo_Field(c) || libSingular.nCoeff_is_Nemo_Ring(c)
cf = libSingular.nCopyCoeff(c)
data_ptr = libSingular.nGetCoeffData(cf)
R = unsafe_pointer_to_objref(data_ptr)
basering = CoefficientRing(R) # FIXME: should we set cache=false ?
T = elem_type(basering)
else
basering = N_UnknownSingularCoefficientRing(libSingular.nCopyCoeff(c))
T = n_unknownsingularcoefficient
Expand Down
7 changes: 7 additions & 0 deletions test/caller-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,10 @@ end
@test Singular.libSingular.random() == 16807
@test Singular.libSingular.random() == 282475249
end

@testset "Nemo coeffs" begin
F = Nemo.fraction_field(Nemo.polynomial_ring(Nemo.ZZ)[1])
R, x = Singular.polynomial_ring(F, [:x])
S = Singular.create_ring_from_singular_ring(Singular.libSingular.rCopy(R.ptr))
@test base_ring(R) == base_ring(S)
end

0 comments on commit 34a2556

Please sign in to comment.