Skip to content
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

Fix all uses of Val #1664

Merged
merged 19 commits into from
Apr 12, 2024
Merged
10 changes: 5 additions & 5 deletions src/AbstractAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@
# parent(b) == a && return a
# return force_coerce(a, b)
#
function force_coerce(a, b, throw_error::Type{Val{T}} = Val{true}) where {T}
if throw_error === Val{true}
function force_coerce(a, b, throw_error::Val{T} = Val(true)) where {T}
if throw_error isa Val{true}

Check warning on line 110 in src/AbstractAlgebra.jl

View check run for this annotation

Codecov / codecov/patch

src/AbstractAlgebra.jl#L109-L110

Added lines #L109 - L110 were not covered by tests
error("coercion not possible")
end
return nothing
Expand All @@ -117,15 +117,15 @@
# a common over structure
# designed(?) to be minimally invasive in AA and Nemo, but filled with
# content in Hecke/Oscar
function force_op(op::Function, throw_error::Type{Val{T}}, a...) where {T}
if throw_error === Val{true}
function force_op(op::Function, throw_error::Val{T}, a...) where {T}
if throw_error isa Val{true}

Check warning on line 121 in src/AbstractAlgebra.jl

View check run for this annotation

Codecov / codecov/patch

src/AbstractAlgebra.jl#L120-L121

Added lines #L120 - L121 were not covered by tests
error("no common overstructure for the arguments found")
end
return false
end

function force_op(op::Function, a...)
return force_op(op, Val{true}, a...)
return force_op(op, Val(true), a...)

Check warning on line 128 in src/AbstractAlgebra.jl

View check run for this annotation

Codecov / codecov/patch

src/AbstractAlgebra.jl#L128

Added line #L128 was not covered by tests
end

###############################################################################
Expand Down
17 changes: 16 additions & 1 deletion src/Deprecations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,19 @@ end
#
###############################################################################

#= currently none =#
# deprecated during 0.40.*
@deprecate force_coerce(a, b, throw_error::Type{Val{T}}) where {T} force_coerce(a, b, Val(T))
@deprecate force_op(op::Function, throw_error::Type{Val{T}}, a...) where {T} force_op(op, Val(T), a...)
@deprecate _hnf_minors!(H::MatrixElem{T}, U::MatrixElem{T}, with_transform::Type{Val{S}}) where {T <: RingElement, S} _hnf_minors!(H, U, Val(S))
@deprecate _hnf_kb(A, trafo::Type{Val{T}}) where T _hnf_kb(A, Val(T))
@deprecate _snf_kb(A::MatrixElem{T}, trafo::Type{Val{V}}) where {V, T <: RingElement} _snf_kb(A, Val(V))
@deprecate _weak_popov(A::MatElem{T}, trafo::Type{Val{S}}) where {T <: PolyRingElem, S} _weak_popov(A, Val(S))
@deprecate _extended_weak_popov(A::MatElem{T}, V::MatElem{T}, trafo::Type{Val{S}}) where {T <: PolyRingElem, S} _extended_weak_popov(A, V, Val(S))
@deprecate _popov(A::MatElem{T}, trafo::Type{Val{S}}) where {T <: PolyRingElem, S} _popov(A, Val(S))
@deprecate _hnf_via_popov(A::MatElem{T}, trafo::Type{Val{S}}) where {T <: PolyRingElem, S} _hnf_via_popov(A, Val(S))
@deprecate gen(a::MPolyRing{T}, i::Int, ::Type{Val{ord}}) where {T <: RingElement, ord} gen(a, i, Val(ord))
import .Generic: exponent_vector; @deprecate exponent_vector(a::Generic.MPoly{T}, i::Int, ::Type{Val{ord}}) where {T <: RingElement, ord} exponent_vector(a, i, Val(ord))
import .Generic: exponent; @deprecate exponent(a::Generic.MPoly{T}, i::Int, j::Int, ::Type{Val{ord}}) where {T <: RingElement, ord} exponent(a, i, j, Val(ord))
import .Generic: set_exponent_vector!; @deprecate set_exponent_vector!(a::Generic.MPoly{T}, i::Int, exps::Vector{Int}, ::Type{Val{ord}}) where {T <: RingElement, ord} set_exponent_vector!(a, i, exps, Val(ord))
import .Generic: is_gen; @deprecate is_gen(x::Generic.MPoly{T}, ::Type{Val{ord}}) where {T <: RingElement, ord} is_gen(x, Val(ord))
import .Generic: degree; @deprecate degree(f::Generic.MPoly{T}, i::Int, ::Type{Val{ord}}) where {T <: RingElement, ord} degree(f, i, Val(ord))
74 changes: 36 additions & 38 deletions src/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4462,7 +4462,7 @@
"""
function hnf_minors(A::MatrixElem{T}) where {T <: RingElement}
H = deepcopy(A)
_hnf_minors!(H, similar(A, 0, 0), Val{false})
_hnf_minors!(H, similar(A, 0, 0), Val(false))
return H
end

Expand All @@ -4476,11 +4476,11 @@
function hnf_minors_with_transform(A::MatrixElem{T}) where {T <: RingElement}
H = deepcopy(A)
U = similar(A, nrows(A), nrows(A))
_hnf_minors!(H, U, Val{true})
_hnf_minors!(H, U, Val(true))
return H, U
end

function _hnf_minors!(H::MatrixElem{T}, U::MatrixElem{T}, with_transform::Type{Val{S}} = Val{false}) where {T <: RingElement, S}
function _hnf_minors!(H::MatrixElem{T}, U::MatrixElem{T}, ::Val{with_transform} = Val(false)) where {T <: RingElement, with_transform}
m = nrows(H)
n = ncols(H)

Expand All @@ -4489,9 +4489,7 @@

R = base_ring(H)

with_trafo = with_transform == Val{true} ? true : false

if with_trafo
if with_transform
for i in 1:m
for j in 1:m
if j == i
Expand Down Expand Up @@ -4546,7 +4544,7 @@
t = mul!(t, q, H[j, j2])
H[k, j2] = add!(H[k, j2], H[k, j2], t)
end
if with_trafo
if with_transform
for j2 in 1:m
t = mul!(t, q, U[j, j2])
U[k, j2] = add!(U[k, j2], U[k, j2], t)
Expand All @@ -4572,7 +4570,7 @@
H[k, j2] = reduce!(H[k, j2])
H[j, j2] = reduce!(H[j, j2])
end
if with_trafo
if with_transform
for j2 in 1:m
b = mul_red!(b, u, U[j, j2], false)
t2 = mul_red!(t2, v, U[k, j2], false)
Expand All @@ -4588,7 +4586,7 @@

if is_zero_entry(H, k, k)
swap_rows!(H, k, l)
if with_trafo
if with_transform
swap_rows!(U, k, l)
end
l = l - 1
Expand All @@ -4602,7 +4600,7 @@
for j in k:n
H[k, j] = mul!(H[k, j], H[k, j], u)
end
if with_trafo
if with_transform
for j in 1:m
U[k, j] = mul!(U[k, j], U[k, j], u)
end
Expand All @@ -4620,7 +4618,7 @@
t = mul!(t, q, H[j, j2])
H[i, j2] = add!(H[i, j2], H[i, j2], t)
end
if with_trafo
if with_transform
for j2 in 1:m
t = mul!(t, q, U[j, j2])
U[i, j2] = add!(U[i, j2], U[i, j2], t)
Expand Down Expand Up @@ -4658,7 +4656,7 @@
t = mul!(t, q, H[j, j2])
H[k, j2] = add!(H[k, j2], H[k, j2], t)
end
if with_trafo
if with_transform

Check warning on line 4659 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L4659

Added line #L4659 was not covered by tests
for j2 in 1:m
t = mul!(t, q, U[j, j2])
U[k, j2] = add!(U[k, j2], U[k, j2], t)
Expand All @@ -4681,7 +4679,7 @@
H[k, j2] = reduce!(H[k, j2])
H[j, j2] = reduce!(H[j, j2])
end
if with_trafo
if with_transform

Check warning on line 4682 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L4682

Added line #L4682 was not covered by tests
for j2 in 1:m
b = mul_red!(b, u, U[j, j2], false)
t2 = mul_red!(t2, v, U[k, j2], false)
Expand All @@ -4705,7 +4703,7 @@
t = mul!(t, q, H[j, j2])
H[i, j2] = add!(H[i, j2], H[i, j2], t)
end
if with_trafo
if with_transform

Check warning on line 4706 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L4706

Added line #L4706 was not covered by tests
for j2 in 1:m
t = mul!(t, q, U[j, j2])
U[i, j2] = add!(U[i, j2], U[i, j2], t)
Expand All @@ -4727,7 +4725,7 @@
of the algorithm of Kannan-Bachem.
"""
function hnf_kb(A::MatrixElem{T}) where {T <: RingElement}
return _hnf_kb(A, Val{false})
return _hnf_kb(A, Val(false))
end

@doc raw"""
Expand All @@ -4738,13 +4736,13 @@
Kannan-Bachem.
"""
function hnf_kb_with_transform(A::MatrixElem{T}) where {T <: RingElement}
return _hnf_kb(A, Val{true})
return _hnf_kb(A, Val(true))
end

function _hnf_kb(A, trafo::Type{Val{T}} = Val{false}) where T
function _hnf_kb(A, ::Val{with_transform} = Val(false)) where {with_transform}
H = deepcopy(A)
m = nrows(H)
if trafo == Val{true}
if with_transform
U = identity_matrix(A, m)
hnf_kb!(H, U, true)
return H, U
Expand Down Expand Up @@ -5041,18 +5039,18 @@
end

function snf_kb(A::MatrixElem{T}) where {T <: RingElement}
return _snf_kb(A, Val{false})
return _snf_kb(A, Val(false))
end

function snf_kb_with_transform(A::MatrixElem{T}) where {T <: RingElement}
return _snf_kb(A, Val{true})
return _snf_kb(A, Val(true))
end

function _snf_kb(A::MatrixElem{T}, trafo::Type{Val{V}} = Val{false}) where {V, T <: RingElement}
function _snf_kb(A::MatrixElem{T}, ::Val{with_transform} = Val(false)) where {T <: RingElement, with_transform}
S = deepcopy(A)
m = nrows(S)
n = ncols(S)
if trafo == Val{true}
if with_transform
U = identity_matrix(A, m)
K = identity_matrix(A, n)
snf_kb!(S, U, K, true)
Expand Down Expand Up @@ -5275,7 +5273,7 @@
Return the weak Popov form of $A$.
"""
function weak_popov(A::MatElem{T}) where {T <: PolyRingElem}
return _weak_popov(A, Val{false})
return _weak_popov(A, Val(false))
end

@doc raw"""
Expand All @@ -5285,14 +5283,14 @@
is a transformation matrix so that $P = UA$.
"""
function weak_popov_with_transform(A::MatElem{T}) where {T <: PolyRingElem}
return _weak_popov(A, Val{true})
return _weak_popov(A, Val(true))
end

function _weak_popov(A::MatElem{T}, trafo::Type{Val{S}} = Val{false}) where {T <: PolyRingElem, S}
function _weak_popov(A::MatElem{T}, ::Val{with_transform} = Val(false)) where {T <: PolyRingElem, with_transform}
P = deepcopy(A)
m = nrows(P)
W = similar(A, 0, 0)
if trafo == Val{true}
if with_transform
U = identity_matrix(A, m)
weak_popov!(P, W, U, false, true)
return P, U
Expand All @@ -5311,7 +5309,7 @@
Return the tuple $(P, W)$.
"""
function extended_weak_popov(A::MatElem{T}, V::MatElem{T}) where {T <: PolyRingElem}
return _extended_weak_popov(A, V, Val{false})
return _extended_weak_popov(A, V, Val(false))

Check warning on line 5312 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L5312

Added line #L5312 was not covered by tests
end

@doc raw"""
Expand All @@ -5323,15 +5321,15 @@
Return the tuple $(P, W, U)$.
"""
function extended_weak_popov_with_transform(A::MatElem{T}, V::MatElem{T}) where {T <: PolyRingElem}
return _extended_weak_popov(A, V, Val{true})
return _extended_weak_popov(A, V, Val(true))

Check warning on line 5324 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L5324

Added line #L5324 was not covered by tests
end

function _extended_weak_popov(A::MatElem{T}, V::MatElem{T}, trafo::Type{Val{S}} = Val{false}) where {T <: PolyRingElem, S}
function _extended_weak_popov(A::MatElem{T}, V::MatElem{T}, ::Val{with_transform} = Val(false)) where {T <: PolyRingElem, with_transform}

Check warning on line 5327 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L5327

Added line #L5327 was not covered by tests
@assert nrows(V) == nrows(A) && ncols(V) == 1
P = deepcopy(A)
W = deepcopy(V)
m = nrows(P)
if trafo == Val{true}
if with_transform

Check warning on line 5332 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L5332

Added line #L5332 was not covered by tests
U = identity_matrix(A)
weak_popov!(P, W, U, true, true)
return P, W, U
Expand Down Expand Up @@ -5547,7 +5545,7 @@
Return the Popov form of $A$.
"""
function popov(A::MatElem{T}) where {T <: PolyRingElem}
return _popov(A, Val{false})
return _popov(A, Val(false))
end

@doc raw"""
Expand All @@ -5557,13 +5555,13 @@
is a transformation matrix so that $P = UA$.
"""
function popov_with_transform(A::MatElem{T}) where {T <: PolyRingElem}
return _popov(A, Val{true})
return _popov(A, Val(true))
end

function _popov(A::MatElem{T}, trafo::Type{Val{S}} = Val{false}) where {T <: PolyRingElem, S}
function _popov(A::MatElem{T}, ::Val{with_transform} = Val(false)) where {T <: PolyRingElem, with_transform}
P = deepcopy(A)
m = nrows(P)
if trafo == Val{true}
if with_transform
U = identity_matrix(A, m)
popov!(P, U, true)
return P, U
Expand Down Expand Up @@ -5688,17 +5686,17 @@
end

function hnf_via_popov(A::MatElem{T}) where {T <: PolyRingElem}
return _hnf_via_popov(A, Val{false})
return _hnf_via_popov(A, Val(false))

Check warning on line 5689 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L5689

Added line #L5689 was not covered by tests
end

function hnf_via_popov_with_transform(A::MatElem{T}) where {T <: PolyRingElem}
return _hnf_via_popov(A, Val{true})
return _hnf_via_popov(A, Val(true))

Check warning on line 5693 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L5693

Added line #L5693 was not covered by tests
end

function _hnf_via_popov(A::MatElem{T}, trafo::Type{Val{S}} = Val{false}) where {T <: PolyRingElem, S}
function _hnf_via_popov(A::MatElem{T}, ::Val{with_transform} = Val(false)) where {T <: PolyRingElem, with_transform}

Check warning on line 5696 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L5696

Added line #L5696 was not covered by tests
H = deepcopy(A)
m = nrows(H)
if trafo == Val{true}
if with_transform

Check warning on line 5699 in src/Matrix.jl

View check run for this annotation

Codecov / codecov/patch

src/Matrix.jl#L5699

Added line #L5699 was not covered by tests
U = identity_matrix(A, m)
hnf_via_popov!(H, U, true)
return H, U
Expand Down
Loading
Loading