diff --git a/src/ideal/ideal.jl b/src/ideal/ideal.jl index 899ed8818..bb631f7f9 100644 --- a/src/ideal/ideal.jl +++ b/src/ideal/ideal.jl @@ -327,7 +327,7 @@ end saturation{T <: Nemo.RingElem}(I::sideal{T}, J::sideal{T}) Returns the saturation of the ideal $I$ with respect to $J$, i.e. returns -the quotient ideal $(I:J^\infty)$. +the quotient ideal $(I:J^\infty)$ and the number of iterations. """ function saturation(I::sideal{T}, J::sideal{T}) where T <: Nemo.RingElem check_parent(I, J) @@ -335,11 +335,13 @@ function saturation(I::sideal{T}, J::sideal{T}) where T <: Nemo.RingElem !has_global_ordering(R) && error("Must be over a ring with global ordering") Q = quotient(I, J) # we already have contains(Q, I) automatically + k = 0 while !contains(I, Q) I = Q Q = quotient(I, J) + k = k + 1 end - return I + return I,k end ############################################################################### diff --git a/test/ideal/sideal-test.jl b/test/ideal/sideal-test.jl index 0f35445b2..ef4bb428f 100644 --- a/test/ideal/sideal-test.jl +++ b/test/ideal/sideal-test.jl @@ -161,12 +161,14 @@ end I = Ideal(R, (x^2 + x*y + 1)*(2y^2+1)^3, (2y^2 + 3)*(2y^2+1)^2) J = Ideal(R, 2y^2 + 1) - @test equal(saturation(I, J), Ideal(R, 2y^2 + 3, x^2 + x*y + 1)) + S,k = saturation(I, J) + @test equal(S, Ideal(R, 2y^2 + 3, x^2 + x*y + 1)) I = Ideal(R, (x*y + 1)*(2x^2*y^2 + x*y - 2) + 2x*y^2 + x, 2x*y + 1) J = Ideal(R, x) - @test equal(satstd(I, J), std(saturation(I, J))) + S,k = saturation(I, J) + @test equal(satstd(I, J), std(S)) end @testset "sideal.slimgb" begin