-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from RafaelDavidMohr/rm/dimension
Adds function for dimension computation
- Loading branch information
Showing
5 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
@doc Markdown.doc""" | ||
dimension(I::Ideal{T}) where T <: MPolyRingElem | ||
Compute the Krull dimension of a given polynomial ideal `I`. | ||
**Note**: This requires a Gröbner basis of `I`. | ||
# Examples | ||
```jldoctest | ||
julia> using AlgebraicSolving | ||
julia> R, (x, y, z) = polynomial_ring(QQ, ["x", "y", "z"]); | ||
julia> I = Ideal([x*y,x*z,y*z]); | ||
julia> dimension(I) | ||
1 | ||
``` | ||
""" | ||
function dimension(I::Ideal{T}) where T <: MPolyRingElem | ||
|
||
gb = isempty(values(I.gb)) ? groebner_basis(I) : first(values(I.gb)) | ||
R = parent(first(gb)) | ||
res = [trues(ngens(R))] | ||
|
||
lms = (Nemo.leading_monomial).(gb) | ||
for lm in lms | ||
to_del = Int[] | ||
new_miss = BitVector[] | ||
for (i, mis) in enumerate(res) | ||
nz_exps_inds = findall(e -> !iszero(e), | ||
first(Nemo.exponent_vectors(lm))) | ||
ind_var_inds = findall(mis) | ||
if issubset(nz_exps_inds, ind_var_inds) | ||
for j in nz_exps_inds | ||
new_mis = copy(mis) | ||
new_mis[j] = false | ||
push!(new_miss, new_mis) | ||
end | ||
push!(to_del, i) | ||
end | ||
end | ||
deleteat!(res, to_del) | ||
append!(res, new_miss) | ||
unique!(res) | ||
end | ||
|
||
max_length = maximum(mis -> length(findall(mis)), res) | ||
return max_length | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export polynomial_ring, MPolyRing, GFElem, MPolyRingElem, finite_field, GF, fpMPolyRingElem, | ||
characteristic, degree, ZZ, QQ, vars, nvars, ngens, ZZRingElem, QQFieldElem, QQMPolyRingElem, | ||
base_ring, coefficient_ring, evaluate, prime_field, sig_groebner_basis, cyclic, leading_coefficient, | ||
FqMPolyRingElem | ||
FqMPolyRingElem, dimension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@testset "dimension" begin | ||
R, (x,y) = polynomial_ring(QQ,["x","y"]) | ||
I = Ideal([x^2,x*y]) | ||
@test isone(dimension(I)) | ||
|
||
R, (x,y,z) = polynomial_ring(GF(101),["x","y","z"]) | ||
I = Ideal([x+2*y+2*z-1, x^2+2*y^2+2*z^2-x, 2*x*y+2*y*z-y]) | ||
@test isone(dimension(I)) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters