Skip to content

Commit

Permalink
isupper_triangular -> is_upper_triangular, isunit -> is_unit (#1265)
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin authored Oct 31, 2023
1 parent 6dcd2c8 commit 159ba41
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion docs/src/sparse/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ nrows(::SMat)
ncols(::SMat)
isone(::SMat)
iszero(::SMat)
isupper_triangular(::SMat)
is_upper_triangular(::SMat)
maximum(::SMat)
minimum(::SMat)
maximum(::typeof(abs), ::SMat{ZZRingElem})
Expand Down
2 changes: 1 addition & 1 deletion src/AlgAssAbsOrd/Ideal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ function _lattice_with_local_conditions_contained(O, ps, Is)
end

for I in Is
@assert isunit(denominator(I, O))
@assert is_unit(denominator(I, O))
end

for i in 1:length(ps)
Expand Down
4 changes: 2 additions & 2 deletions src/AlgAssAbsOrd/LocallyFreeClassGroup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ function _unit_group_generators(A::AlgMat{<:FinFieldElem})
for i in 2:d
g2[i, i - 1] = -1
end
@assert isunit(det(g1))
@assert isunit(det(g2))
@assert is_unit(det(g1))
@assert is_unit(det(g2))
push!(res, g1, g2)
end
return map(A, res)
Expand Down
2 changes: 1 addition & 1 deletion src/AlgAssAbsOrd/PIP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ function _GLn_generators_quadratic(OK, n)
res = dense_matrix_type(K)[]
for w in v[3]
mat = matrix(K, 2, 2, [i(L(u)) for u in w])
@assert isunit(det(mat))
@assert is_unit(det(mat))
push!(res, mat)
end
return res
Expand Down
2 changes: 1 addition & 1 deletion src/AlgAssAbsOrd/UnitGroup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function _unit_group_maximal(O::AlgAssAbsOrd)
U, mU = unit_groups[i]
OK = codomain(mU)
y = OK(AtoK(elem_in_algebra(x, copy = false)))
@assert isunit(y)
@assert is_unit(y)
u = mU\y
g = hcat(g, u.coeff)
end
Expand Down
2 changes: 1 addition & 1 deletion src/LocalField/Completions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function image(f::CompletionMap, a::nf_elem)
end
Qx = parent(parent(a).pol)
z = evaluate(Qx(a), f.prim_img)
if !isunit(z)
if !is_unit(z)
v = valuation(a, f.P)
a = a*uniformizer(f.P).elem_in_nf^-v
z = evaluate(Qx(a), f.prim_img)
Expand Down
2 changes: 1 addition & 1 deletion src/Misc/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ function snf_for_groups(A::ZZMatrix, mod::ZZRingElem)
R = mul!(R, T, R)
ccall((:fmpz_mat_transpose, libflint), Nothing,
(Ref{ZZMatrix}, Ref{ZZMatrix}), S, S)
if isupper_triangular(S)
if is_upper_triangular(S)
break
end
end
Expand Down
6 changes: 3 additions & 3 deletions src/NumFieldOrd/NfOrd/Clgp/FacBase_Euc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ function is_smooth(c::FactorBase{T}, a::T) where T
a = divexact(a, g)
g = gcd(g, a)
end
return isunit(a)
return is_unit(a)
end

function is_smooth!(c::FactorBase{ZZRingElem}, a::ZZRingElem)
@assert a != 0
g = gcd(c.prod, a)
if isone(g)
return isunit(a), a
return is_unit(a), a
end
b = copy(a)
while !isone(g)
divexact!(b, b, g)
gcd!(g, g, b)
end
return isunit(b), b
return is_unit(b), b
end


Expand Down
10 changes: 5 additions & 5 deletions src/Sparse/HNF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function reduce(A::SMat{zzModRingElem}, g::SRow{zzModRingElem})
end

function _reduce_field(A::SMat{T}, g::SRow{T}) where {T}
@hassert :HNF 1 isupper_triangular(A)
@hassert :HNF 1 is_upper_triangular(A)
#assumes A is upper triangular, reduces g modulo A
# supposed to be a field...
if A.r == A.c
Expand Down Expand Up @@ -58,7 +58,7 @@ Given an upper triangular matrix $A$ over a field and a sparse row $g$, this
function reduces $g$ modulo $A$.
"""
function reduce(A::SMat{T}, g::SRow{T}) where {T}
@hassert :HNF 1 isupper_triangular(A)
@hassert :HNF 1 is_upper_triangular(A)
#assumes A is upper triangular, reduces g modulo A
#until the 1st (pivot) change in A
new_g = false
Expand Down Expand Up @@ -121,7 +121,7 @@ integer $m$, this function reduces $g$ modulo $A$ and returns $g$
modulo $m$ with respect to the symmetric residue system.
"""
function reduce(A::SMat{T}, g::SRow{T}, m::T) where {T}
@hassert :HNF 1 isupper_triangular(A)
@hassert :HNF 1 is_upper_triangular(A)
#assumes A is upper triangular, reduces g modulo A
g = deepcopy(g)
mod_sym!(g, m)
Expand Down Expand Up @@ -214,7 +214,7 @@ for all $j > 1$. It is assumed that $A$ is upper triangular.
If such an index does not exist, find the smallest index larger.
"""
function find_row_starting_with(A::SMat, p::Int)
# @hassert :HNF 1 isupper_triangular(A)
# @hassert :HNF 1 is_upper_triangular(A)
start = 0
stop = nrows(A)+1
while start < stop - 1
Expand Down Expand Up @@ -272,7 +272,7 @@ If `trafo` is set to `Val{true}`, then additionally an array of transformations
is returned.
"""
function reduce_full(A::SMat{T}, g::SRow{T}, trafo::Type{Val{N}} = Val{false}) where {N, T}
# @hassert :HNF 1 isupper_triangular(A)
# @hassert :HNF 1 is_upper_triangular(A)
#assumes A is upper triangular, reduces g modulo A

with_transform = (trafo == Val{true})
Expand Down
4 changes: 2 additions & 2 deletions src/Sparse/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1244,11 +1244,11 @@ end
################################################################################

@doc raw"""
isupper_triangular(A::SMat)
is_upper_triangular(A::SMat)
Returns true if and only if $A$ is upper (right) triangular.
"""
function isupper_triangular(A::SMat)
function is_upper_triangular(A::SMat)
for i=2:A.r
if iszero(A[i - 1])
if iszero(A[i])
Expand Down
6 changes: 3 additions & 3 deletions src/Sparse/Module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Hecke.lift, Hecke.rational_reconstruction, Hecke.elementary_divisors,
# Hecke.rank, Hecke.det

export det_mc, id, isupper_triangular, norm2, hadamard_bound2,
export det_mc, id, is_upper_triangular, norm2, hadamard_bound2,
hnf, hnf!, echelon_with_transform

add_verbosity_scope(:HNF)
Expand Down Expand Up @@ -78,7 +78,7 @@ function check_index(M::ModuleCtx_fmpz)

if isdefined(M, :basis)
C = copy(M.basis)
@assert isupper_triangular(C)
@assert is_upper_triangular(C)
@assert M.basis_idx != 0
else
d = abs(det_mc(M.bas_gens))
Expand All @@ -98,7 +98,7 @@ function check_index(M::ModuleCtx_fmpz)
C.c = max(C.c, h.pos[end])
end
M.max_indep = copy(C)
@assert isupper_triangular(C)
@assert is_upper_triangular(C)
M.basis_idx = prod([C[i,i] for i=1:nrows(C)])
end

Expand Down
12 changes: 6 additions & 6 deletions src/Sparse/Solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Nemo: can_solve, can_solve_with_solution
function can_solve_ut(A::SMat{T}, g::SRow{T}) where T <: Union{FieldElem, zzModRingElem}
# Works also for non-square matrices
#@hassert :HNF 1 ncols(A) == nrows(A)
@hassert :HNF 2 isupper_triangular(A)
@hassert :HNF 2 is_upper_triangular(A)
# assumes A is upper triangular, reduces g modulo A to zero and collects
# the transformation
# supposed to be over a field...
Expand Down Expand Up @@ -88,7 +88,7 @@ function rational_reconstruction(A::SRow{ZZRingElem}, M::ZZRingElem)
end

function solve_ut(A::SMat{ZZRingElem}, b::SRow{ZZRingElem})
@hassert :HNF 1 isupper_triangular(A)
@hassert :HNF 1 is_upper_triangular(A)
#still assuming A to be upper-triag

sol = sparse_row(FlintZZ)
Expand All @@ -114,7 +114,7 @@ function solve_ut(A::SMat{ZZRingElem}, b::SRow{ZZRingElem})
end

function solve_ut(A::SMat{ZZRingElem}, b::SMat{ZZRingElem})
@hassert :HNF 1 isupper_triangular(A)
@hassert :HNF 1 is_upper_triangular(A)
#still assuming A to be upper-triag
d = ZZRingElem(1)
r = sparse_matrix(FlintZZ)
Expand Down Expand Up @@ -149,7 +149,7 @@ Uses the dense (zzModMatrix) determinant on $A$ for various primes $p$.
function det_mc(A::SMat{ZZRingElem})

@hassert :HNF 1 A.r == A.c
if isupper_triangular(A)
if is_upper_triangular(A)
z = ZZRingElem[ A[i, i] for i in 1:A.r]
return prod(z)
end
Expand Down Expand Up @@ -190,7 +190,7 @@ Uses the dense (zzModMatrix) determinant on $A$ for various primes $p$.
"""
function det(A::SMat{ZZRingElem})
@hassert :HNF 1 A.r == A.c
if isupper_triangular(A)
if is_upper_triangular(A)
return prod(ZZRingElem[A[i,i] for i=1:A.r]) end

b = div(nbits(hadamard_bound2(A)), 2)
Expand Down Expand Up @@ -268,7 +268,7 @@ function solve_dixon_sf(A::SMat{ZZRingElem}, B::SMat{ZZRingElem}, is_int::Bool =
reverse_rows!(Ep)
Ep = transpose(Ep)
reverse_rows!(Ep)
# @hassert :HNF 1 Hecke.isupper_triangular(Ep)
# @hassert :HNF 1 Hecke.is_upper_triangular(Ep)

reverse_rows!(Tp)
Tp = transpose(Tp)
Expand Down
6 changes: 3 additions & 3 deletions test/Sparse/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,11 @@ using Hecke.SparseArrays
@test b == QQFieldElem(-10)

D = sparse_matrix(FlintZZ, [0 2 0; 0 0 1; 0 0 0])
@test @inferred isupper_triangular(D)
@test @inferred is_upper_triangular(D)
D = sparse_matrix(FlintZZ, [0 0 2; 0 0 1; 0 0 0])
@test !isupper_triangular(D)
@test !is_upper_triangular(D)
D = sparse_matrix(FlintZZ, [0 0 0; 0 0 0; 0 0 0])
@test @inferred isupper_triangular(D)
@test @inferred is_upper_triangular(D)

# Zero and identity matrix

Expand Down

0 comments on commit 159ba41

Please sign in to comment.