From 159ba41502d0f22b6415b96dc791b36c483bdfd5 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 31 Oct 2023 10:58:26 +0100 Subject: [PATCH] isupper_triangular -> is_upper_triangular, isunit -> is_unit (#1265) --- docs/src/sparse/intro.md | 2 +- src/AlgAssAbsOrd/Ideal.jl | 2 +- src/AlgAssAbsOrd/LocallyFreeClassGroup.jl | 4 ++-- src/AlgAssAbsOrd/PIP.jl | 2 +- src/AlgAssAbsOrd/UnitGroup.jl | 2 +- src/LocalField/Completions.jl | 2 +- src/Misc/Matrix.jl | 2 +- src/NumFieldOrd/NfOrd/Clgp/FacBase_Euc.jl | 6 +++--- src/Sparse/HNF.jl | 10 +++++----- src/Sparse/Matrix.jl | 4 ++-- src/Sparse/Module.jl | 6 +++--- src/Sparse/Solve.jl | 12 ++++++------ test/Sparse/Matrix.jl | 6 +++--- 13 files changed, 30 insertions(+), 30 deletions(-) diff --git a/docs/src/sparse/intro.md b/docs/src/sparse/intro.md index 2a7cce961f..b3e6e8d77e 100644 --- a/docs/src/sparse/intro.md +++ b/docs/src/sparse/intro.md @@ -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}) diff --git a/src/AlgAssAbsOrd/Ideal.jl b/src/AlgAssAbsOrd/Ideal.jl index 5d9c43551f..4465dc422e 100644 --- a/src/AlgAssAbsOrd/Ideal.jl +++ b/src/AlgAssAbsOrd/Ideal.jl @@ -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) diff --git a/src/AlgAssAbsOrd/LocallyFreeClassGroup.jl b/src/AlgAssAbsOrd/LocallyFreeClassGroup.jl index 42cdfee513..980628d4b8 100644 --- a/src/AlgAssAbsOrd/LocallyFreeClassGroup.jl +++ b/src/AlgAssAbsOrd/LocallyFreeClassGroup.jl @@ -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) diff --git a/src/AlgAssAbsOrd/PIP.jl b/src/AlgAssAbsOrd/PIP.jl index 45bb658971..77f7ec64b9 100644 --- a/src/AlgAssAbsOrd/PIP.jl +++ b/src/AlgAssAbsOrd/PIP.jl @@ -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 diff --git a/src/AlgAssAbsOrd/UnitGroup.jl b/src/AlgAssAbsOrd/UnitGroup.jl index 09decef849..d748017cb7 100644 --- a/src/AlgAssAbsOrd/UnitGroup.jl +++ b/src/AlgAssAbsOrd/UnitGroup.jl @@ -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 diff --git a/src/LocalField/Completions.jl b/src/LocalField/Completions.jl index 8177cd52bf..a60ded9492 100644 --- a/src/LocalField/Completions.jl +++ b/src/LocalField/Completions.jl @@ -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) diff --git a/src/Misc/Matrix.jl b/src/Misc/Matrix.jl index 70e00be7c4..d3baa417e3 100644 --- a/src/Misc/Matrix.jl +++ b/src/Misc/Matrix.jl @@ -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 diff --git a/src/NumFieldOrd/NfOrd/Clgp/FacBase_Euc.jl b/src/NumFieldOrd/NfOrd/Clgp/FacBase_Euc.jl index 54f2d11974..77e5b6e53e 100644 --- a/src/NumFieldOrd/NfOrd/Clgp/FacBase_Euc.jl +++ b/src/NumFieldOrd/NfOrd/Clgp/FacBase_Euc.jl @@ -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 diff --git a/src/Sparse/HNF.jl b/src/Sparse/HNF.jl index add2be1296..bb391c2d73 100644 --- a/src/Sparse/HNF.jl +++ b/src/Sparse/HNF.jl @@ -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 @@ -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 @@ -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) @@ -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 @@ -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}) diff --git a/src/Sparse/Matrix.jl b/src/Sparse/Matrix.jl index c7a4000480..a01d0a642a 100644 --- a/src/Sparse/Matrix.jl +++ b/src/Sparse/Matrix.jl @@ -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]) diff --git a/src/Sparse/Module.jl b/src/Sparse/Module.jl index 98c943a75d..c670a0d604 100644 --- a/src/Sparse/Module.jl +++ b/src/Sparse/Module.jl @@ -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) @@ -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)) @@ -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 diff --git a/src/Sparse/Solve.jl b/src/Sparse/Solve.jl index e7b95a98c2..691889f3e7 100644 --- a/src/Sparse/Solve.jl +++ b/src/Sparse/Solve.jl @@ -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... @@ -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) @@ -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) @@ -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 @@ -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) @@ -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) diff --git a/test/Sparse/Matrix.jl b/test/Sparse/Matrix.jl index 4ba86ad4a4..c605b547e7 100644 --- a/test/Sparse/Matrix.jl +++ b/test/Sparse/Matrix.jl @@ -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