Skip to content

Commit

Permalink
Update jldoctests
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Nov 7, 2024
1 parent daae100 commit 14f1a85
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 75 deletions.
100 changes: 50 additions & 50 deletions src/Modules/ModulesGraded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1426,29 +1426,32 @@ of `F` in form of a Betti table.
Alternatively, use `betti`.
# Examples
```julia
```jldoctest
julia> R, (w, x, y, z) = graded_polynomial_ring(QQ, [:w, :x, :y, :z]);
julia> I = ideal(R, [x*z, y*z, x*w^2, y*w^2])
ideal(x*z, y*z, w^2*x, w^2*y)
Ideal generated by
x*z
y*z
w^2*x
w^2*y
julia> A, _= quo(R, I)
(Quotient of multivariate polynomial ring by ideal with 4 generators, Map from
R to A defined by a julia-function with inverse)
(Quotient of multivariate polynomial ring by ideal (x*z, y*z, w^2*x, w^2*y), Map: R -> A)
julia> FA = free_resolution(A)
Free resolution of A
R^1 <---- R^4 <---- R^4 <---- R^1 <---- 0
0 1 2 3 4
julia> betti_table(FA)
0 1 2 3
degree: 0 1 2 3
------------------
0 : 1 - - -
1 : - 2 1 -
2 : - 2 3 1
0: 1 - - -
1: - 2 1 -
2: - 2 3 1
------------------
total: 1 4 4 1
total: 1 4 4 1
julia> R, (x, y) = graded_polynomial_ring(QQ, [:x, :y]);
Expand All @@ -1459,12 +1462,11 @@ julia> M = quotient_ring_as_module(I);
julia> FM = free_resolution(M, algorithm = :nres);
julia> betti_table(FM)
0 1 2
degree: 0 1 2
---------------
-1 : - - 1
0 : 1 3 1
0: 1 2 1
---------------
total: 1 3 2
total: 1 2 1
```
"""
function betti_table(F::FreeResolution; project::Union{FinGenAbGroupElem, Nothing} = nothing, reverse_direction::Bool=false)
Expand Down Expand Up @@ -2507,23 +2509,22 @@ multivariate polynomial ring with coefficients in a field, return the Betti Tabl
of the minimal free resolution of `M`. Similarly for `A` and `I`.
# Examples
```julia
```jldoctest
julia> R, (w, x, y, z) = graded_polynomial_ring(QQ, [:w, :x, :y, :z]);
julia> I = ideal(R, [w^2-x*z, w*x-y*z, x^2-w*y, x*y-z^2, y^2-w*z]);
julia> A, _ = quo(R, I)
(Quotient of multivariate polynomial ring by ideal with 5 generators, Map from
R to A defined by a julia-function with inverse)
(Quotient of multivariate polynomial ring by ideal (w^2 - x*z, w*x - y*z, -w*y + x^2, x*y - z^2, -w*z + y^2), Map: R -> A)
julia> minimal_betti_table(A)
0 1 2 3
degree: 0 1 2 3
------------------
0 : 1 - - -
1 : - 5 5 -
2 : - - - 1
0: 1 - - -
1: - 5 5 -
2: - - - 1
------------------
total: 1 5 5 1
total: 1 5 5 1
```
"""
function minimal_betti_table(M::ModuleFP{T}; check::Bool=true) where {T<:MPolyDecRingElem}
Expand Down Expand Up @@ -2559,37 +2560,36 @@ Betti table of the minimal free resolution arising from `F`.
The algorithm proceeds without actually minimizing the resolution.
# Examples
```julia
```jldoctest
julia> R, (w, x, y, z) = graded_polynomial_ring(QQ, [:w, :x, :y, :z]);
julia> I = ideal(R, [w^2-x*z, w*x-y*z, x^2-w*y, x*y-z^2, y^2-w*z]);
julia> A, _ = quo(R, I)
(Quotient of multivariate polynomial ring by ideal with 5 generators, Map from
R to A defined by a julia-function with inverse)
(Quotient of multivariate polynomial ring by ideal (w^2 - x*z, w*x - y*z, -w*y + x^2, x*y - z^2, -w*z + y^2), Map: R -> A)
julia> FA = free_resolution(A)
Free resolution of A
R^1 <---- R^5 <---- R^6 <---- R^2 <---- 0
0 1 2 3 4
julia> betti_table(FA)
0 1 2 3
degree: 0 1 2 3
------------------
0 : 1 - - -
1 : - 5 5 1
2 : - - 1 1
0: 1 - - -
1: - 5 5 1
2: - - 1 1
------------------
total: 1 5 6 2
total: 1 5 6 2
julia> minimal_betti_table(FA)
0 1 2 3
degree: 0 1 2 3
------------------
0 : 1 - - -
1 : - 5 5 -
2 : - - - 1
0: 1 - - -
1: - 5 5 -
2: - - - 1
------------------
total: 1 5 5 1
total: 1 5 5 1
```
"""
function minimal_betti_table(res::FreeResolution{T}; check::Bool=true) where {T<:ModuleFP}
Expand Down Expand Up @@ -2814,7 +2814,7 @@ multivariate polynomial ring with coefficients in a field, return the
Castelnuovo-Mumford regularity of `I`.
# Examples
```julia
```jldoctest
julia> R, (x, y, z) = graded_polynomial_ring(QQ, [:x, :y, :z]);
julia> F = graded_free_module(R, 1);
Expand All @@ -2831,16 +2831,16 @@ julia> cm_regularity(M)
3
julia> minimal_betti_table(M)
0 1 2 3
--------------
0 : 1 - - -
1 : - 3 - -
2 : - - 3 -
3 : - - - 1
--------------
total: 1 3 3 1
degree: 0 1 2 3
------------------
0: 1 - - -
1: - 3 - -
2: - - 3 -
3: - - - 1
------------------
total: 1 3 3 1
```
```julia
```jldoctest
julia> R, (w, x, y, z) = graded_polynomial_ring(QQ, [:w, :x, :y, :z]);
julia> I = ideal(R, [-x*z+y^2, x*y-w*z, x^2-w*y]);
Expand All @@ -2851,12 +2851,12 @@ julia> cm_regularity(I)
julia> A, _ = quo(R, I);
julia> minimal_betti_table(A)
0 1 2
------------
0 : 1 - -
1 : - 3 2
------------
total: 1 3 2
degree: 0 1 2
---------------
0: 1 - -
1: - 3 2
---------------
total: 1 3 2
```
"""
function cm_regularity(M::ModuleFP; check::Bool=true)
Expand Down
48 changes: 24 additions & 24 deletions src/Modules/UngradedModules/FreeResolutions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ julia> is_complete(fr)
true
```
```
```jldoctest
julia> R, (w, x, y, z) = graded_polynomial_ring(QQ, [:w, :x, :y, :z]);
julia> Z = R(0)
Expand Down Expand Up @@ -334,14 +334,14 @@ R^2 <---- R^7 <---- R^8 <---- R^3 <---- 0
0 1 2 3 4
julia> betti_table(FM1)
0 1 2 3
-----------------
-1 : - 1 - -
0 : 2 - - -
1 : - 3 3 1
2 : - 3 5 2
-----------------
total: 2 7 8 3
degree: 0 1 2 3
------------------
-1: - 1 - -
0: 2 - - -
1: - 3 3 1
2: - 3 5 2
------------------
total: 2 7 8 3
julia> matrix(map(FM1, 1))
[1 0]
Expand All @@ -358,14 +358,14 @@ R^2 <---- R^4 <---- R^4 <---- R^2 <---- 0
0 1 2 3 4
julia> betti_table(FM2)
0 1 2 3
-----------------
-1 : - 1 - -
0 : 2 - - -
1 : - 3 - -
2 : - - 4 2
-----------------
total: 2 4 4 2
degree: 0 1 2 3
------------------
-1: - 1 - -
0: 2 - - -
1: - 3 - -
2: - - 4 2
------------------
total: 2 4 4 2
julia> matrix(map(FM2, 1))
[1 0]
Expand All @@ -379,13 +379,13 @@ R^1 <---- R^3 <---- R^4 <---- R^2 <---- 0
0 1 2 3 4
julia> betti_table(FM3)
0 1 2 3
-----------------
0 : 1 - - -
1 : - 3 - -
2 : - - 4 2
-----------------
total: 1 3 4 2
degree: 0 1 2 3
------------------
0: 1 - - -
1: - 3 - -
2: - - 4 2
------------------
total: 1 3 4 2
julia> matrix(map(FM3, 1))
[-x*z + y^2]
Expand Down
10 changes: 9 additions & 1 deletion src/Rings/mpoly-graded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2383,7 +2383,15 @@ julia> I = ideal(R, [y^2*z − x^2*w, z^4 − x*w^3]);
julia> cm_regularity(I)
6
julia> minimal_betti_table(I);
julia> minimal_betti_table(I)
degree: 0 1
------------
3: 1 -
4: 1 -
5: - -
6: - 1
------------
total: 2 1
```
"""
function cm_regularity(I::MPolyIdeal)
Expand Down

0 comments on commit 14f1a85

Please sign in to comment.