From bf7a55efb3418a7415b6eb3b00e190bdafe0f1f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Wed, 11 Oct 2023 17:51:04 +0200 Subject: [PATCH 1/2] Rename `mul` to `*` --- docs/src/sparse/intro.md | 8 ++++---- src/Deprecations.jl | 10 ++++++++++ src/NumField/NfAbs/NormRelation/SUnits.jl | 6 +++--- src/NumFieldOrd/NfOrd/Clgp/Map.jl | 2 +- src/NumFieldOrd/NfOrd/Clgp/cm_field.jl | 2 +- src/Sparse.jl | 2 +- src/Sparse/Matrix.jl | 18 ++++++++---------- src/Sparse/Solve.jl | 12 ++++++------ test/Sparse/Matrix.jl | 12 ++++++------ test/Sparse/Solve.jl | 2 +- 10 files changed, 41 insertions(+), 33 deletions(-) diff --git a/docs/src/sparse/intro.md b/docs/src/sparse/intro.md index 6015c9cb1e..17154b9905 100644 --- a/docs/src/sparse/intro.md +++ b/docs/src/sparse/intro.md @@ -205,10 +205,10 @@ Matrices support the usual operations as well Various products: ```@docs -Hecke.mul(::SMat{T}, ::AbstractVector{T}) where {T} -Hecke.mul(::SMat{T}, ::AbstractMatrix{T}) where {T} -Hecke.mul(::SMat{T}, ::MatElem{T}) where {T} -Hecke.mul(::SRow{T}, ::SMat{T}) where {T} +*(::SMat{T}, ::AbstractVector{T}) where {T} +*(::SMat{T}, ::AbstractMatrix{T}) where {T} +*(::SMat{T}, ::MatElem{T}) where {T} +*(::SRow{T}, ::SMat{T}) where {T} ``` Other: diff --git a/src/Deprecations.jl b/src/Deprecations.jl index e842888d5b..eb134571d2 100644 --- a/src/Deprecations.jl +++ b/src/Deprecations.jl @@ -115,6 +115,16 @@ @deprecate any_root(f::Hecke.AbstractAlgebra.Generic.Poly, F::Hecke.RelFinField) any_root(F, f) +# Deprecated during 0.22.* + +@deprecate mul(A::SMat{T}, b::AbstractVector{T}) where T A*b + +@deprecate mul(A::SMat{T}, b::AbstractMatrix{T}) where T A*b + +@deprecate mul(A::SMat{T}, b::MatElem{T}) where T A*b + +@deprecate mul(A::SRow{T}, B::SMat{T}) where T A*b + # Things that moved to Nemo diff --git a/src/NumField/NfAbs/NormRelation/SUnits.jl b/src/NumField/NfAbs/NormRelation/SUnits.jl index 4d0a9b93d5..80cd352c62 100644 --- a/src/NumField/NfAbs/NormRelation/SUnits.jl +++ b/src/NumField/NfAbs/NormRelation/SUnits.jl @@ -40,7 +40,7 @@ function _add_sunits_from_norm_relation!(c, UZK, N) for l=1:ngens(Szk) u = mS(Szk[l]) #do compact rep here??? - valofnewelement = mul(mS.valuations[l], z) + valofnewelement = mS.valuations[l] * z el_to_add = FacElem(Dict{nf_elem, AnticNumberField}((N(x, i, j), v) for (x,v) = u.fac)) Hecke.class_group_add_relation(c, el_to_add, valofnewelement)#, always = false) end @@ -81,7 +81,7 @@ function _compute_sunit_and_unit_group!(c, U, N, saturate = true) u = mS(Szk[l]) for j in 1:length(induced) aut = autos[j] - valofnewelement = mul(mS.valuations[l], induced[j]) + valofnewelement = mS.valuations[l] * induced[j] el_to_add = FacElem(Dict{nf_elem, AnticNumberField}((aut(embedding(N, i)(x)), v) for (x,v) = u.fac)) Hecke.class_group_add_relation(c, el_to_add, valofnewelement)#, always = false) end @@ -228,7 +228,7 @@ function _add_sunits_from_brauer_relation!(c, UZK, N; invariant::Bool = false, c push!(add_unit_later, img_u) end else - valofnewelement = mul(mS.valuations[l], z) + valofnewelement = mS.valuations[l] * z #= if isdefined(c.M, :basis) push!(deb_rr, (deepcopy(c.M.basis), deepcopy(valofnewelement))) diff --git a/src/NumFieldOrd/NfOrd/Clgp/Map.jl b/src/NumFieldOrd/NfOrd/Clgp/Map.jl index 54bcb36e52..935e7c04a2 100644 --- a/src/NumFieldOrd/NfOrd/Clgp/Map.jl +++ b/src/NumFieldOrd/NfOrd/Clgp/Map.jl @@ -471,7 +471,7 @@ function _isprincipal_fac_elem(A::NfOrdIdl, support::Type{Val{U}} = Val{false}) if support === Val{false} return true, e else - prime_exponents = mul(sparse_row(FlintZZ, collect(1:length(base)), rs), vcat(c.M.bas_gens, c.M.rel_gens)) + prime_exponents = sparse_row(FlintZZ, collect(1:length(base)), rs) * vcat(c.M.bas_gens, c.M.rel_gens) prime_exp = [ prime_exponents[i] for i in 1:length(c.FB.ideals)] invx = inv(x) dinvx = denominator(invx) diff --git a/src/NumFieldOrd/NfOrd/Clgp/cm_field.jl b/src/NumFieldOrd/NfOrd/Clgp/cm_field.jl index 534974bca2..4a5088ad61 100644 --- a/src/NumFieldOrd/NfOrd/Clgp/cm_field.jl +++ b/src/NumFieldOrd/NfOrd/Clgp/cm_field.jl @@ -29,7 +29,7 @@ function _add_relations_from_subfield(mL::NfToNfMor; use_aut = true, redo = fals add_unit!(U, u) else img_u = FacElem(Dict{nf_elem, ZZRingElem}((_embed(mL, cache_mL, x), v) for (x,v) = u.fac if !iszero(v))) - valofnewelement = mul(mS.valuations[i], vals_subfield) + valofnewelement = mS.valuations[i] * vals_subfield Hecke.class_group_add_relation(c, u, valofnewelement, add_orbit = false, always = false) end end diff --git a/src/Sparse.jl b/src/Sparse.jl index f0db9f798f..ba514fbd58 100644 --- a/src/Sparse.jl +++ b/src/Sparse.jl @@ -22,7 +22,7 @@ import Base.push!, Base.max, Nemo.nbits, Base.Array, Base.Matrix, Base.vcat, Base.max, Base.min export vcat!, show, sub, SMat, SRow, - ZZMatrix, copy, push!, mul, mul!, to_hecke, sparse, + ZZMatrix, copy, push!, mul!, to_hecke, sparse, valence_mc, swap_rows!, elementary_divisors, rand_row, hcat, hcat!, vcat, vcat!, mod!, mod_sym! diff --git a/src/Sparse/Matrix.jl b/src/Sparse/Matrix.jl index 1680c7d1f2..40bbd1d956 100644 --- a/src/Sparse/Matrix.jl +++ b/src/Sparse/Matrix.jl @@ -516,11 +516,11 @@ end # (dense Vector{T}) * SMat{T} as (dense Vector{T}) @doc raw""" - mul(A::SMat{T}, b::AbstractVector{T}) -> Vector{T} + *(A::SMat{T}, b::AbstractVector{T}) -> Vector{T} Return the product $A \cdot b$ as a dense vector. """ -function mul(A::SMat{T}, b::AbstractVector{T}) where T +function *(A::SMat{T}, b::AbstractVector{T}) where T @assert length(b) == ncols(A) c = Vector{T}(undef, nrows(A)) mul!(c, A, b) @@ -544,11 +544,11 @@ end # - SMat{T} * Matrix{T} as Matrix{T} @doc raw""" - mul(A::SMat{T}, b::AbstractMatrix{T}) -> Matrix{T} + *(A::SMat{T}, b::AbstractMatrix{T}) -> Matrix{T} Return the product $A \cdot b$ as a dense array. """ -function mul(A::SMat{T}, b::AbstractMatrix{T}) where T +function *(A::SMat{T}, b::AbstractMatrix{T}) where T sz = size(b) @assert sz[1] == ncols(A) c = Array{T}(undef, sz[1], sz[2]) @@ -570,26 +570,24 @@ function mul!(c::MatElem{T}, A::SMat{T}, b::MatElem{T}) where T end # - SMat{T} * MatElem{T} as MatElem{T} - @doc raw""" - mul(A::SMat{T}, b::MatElem{T}) -> MatElem + *(A::SMat{T}, b::MatElem{T}) -> MatElem Return the product $A \cdot b$ as a dense matrix. """ -function mul(A::SMat{T}, b::MatElem{T}) where T +function *(A::SMat{T}, b::MatElem{T}) where T @assert nrows(b) == ncols(A) c = similar(b, nrows(A), ncols(b)) return mul!(c, A, b) end # - SRow{T} * SMat{T} as SRow{T} - @doc raw""" - mul(A::SRow, B::SMat) -> SRow + *(A::SRow, B::SMat) -> SRow Return the product $A\cdot B$ as a sparse row. """ -function mul(A::SRow{T}, B::SMat{T}) where T +function *(A::SRow{T}, B::SMat{T}) where T C = sparse_row(base_ring(B)) for (p, v) in A if iszero(v) diff --git a/src/Sparse/Solve.jl b/src/Sparse/Solve.jl index c025033cc2..e7b95a98c2 100644 --- a/src/Sparse/Solve.jl +++ b/src/Sparse/Solve.jl @@ -290,7 +290,7 @@ function solve_dixon_sf(A::SMat{ZZRingElem}, B::SMat{ZZRingElem}, is_int::Bool = last = (sol, ZZRingElem(1)) while true - bp = mul(bp, Tp) + bp = bp * Tp zp = solve_ut(Ep, bp) z = lift(zp) @@ -298,7 +298,7 @@ function solve_dixon_sf(A::SMat{ZZRingElem}, B::SMat{ZZRingElem}, is_int::Bool = pp *= ZZRingElem(p) - # @hassert :HNF 1 iszero(SRow(b_orig - Hecke.mul(sol, A), pp)) + # @hassert :HNF 1 iszero(SRow(b_orig - sol * A, pp)) if is_int fl = true @@ -310,9 +310,9 @@ function solve_dixon_sf(A::SMat{ZZRingElem}, B::SMat{ZZRingElem}, is_int::Bool = end if fl # @hassert :HNF 1 SRow(de*sol, pp) == SRow(nu, pp) - # @hassert :HNF 1 SRow(mul(nu, A), pp) == SRow(de*b_orig, pp) + # @hassert :HNF 1 SRow(nu*A, pp) == SRow(de*b_orig, pp) if last == (nu, de) - if mul(nu, A) == de*b_orig + if nu*A == de*b_orig l = lcm(den_all, de) if l == den_all push!(sol_all, div(l, de)*nu) @@ -329,8 +329,8 @@ function solve_dixon_sf(A::SMat{ZZRingElem}, B::SMat{ZZRingElem}, is_int::Bool = end end - # @hassert :HNF 1 SRow(Hecke.mul(z, A), p) == bp - b = b - mul(z, A) + # @hassert :HNF 1 SRow(z*A, p) == bp + b = b - z*A for i=1:length(b.values) # @hassert :HNF 1 b.values[i] % p == 0 diff --git a/test/Sparse/Matrix.jl b/test/Sparse/Matrix.jl index 7eea157618..26a1083ab4 100644 --- a/test/Sparse/Matrix.jl +++ b/test/Sparse/Matrix.jl @@ -136,24 +136,24 @@ using Hecke.SparseArrays D = sparse_matrix(FlintZZ, [1 5 3; 0 0 0; 0 1 0]) v = ZZRingElem[1, 2, 3] - w = @inferred mul(D, v) + w = @inferred D * v @test w == ZZRingElem[20, 0, 2] - w = @inferred mul(D, view(v, 1:3)) + w = @inferred D * view(v, 1:3) @test w == ZZRingElem[20, 0, 2] v = ZZRingElem[1 2 3; 0 0 4; 0 0 0] - w = @inferred mul(D, v) + w = @inferred D * v @test w == ZZRingElem[1 2 23; 0 0 0; 0 0 4] v = ZZRingElem[1 1 1; 1 2 3; 0 0 4; 0 0 0] - w = @inferred mul(D, view(v, 2:4, :)) + w = @inferred D * view(v, 2:4, :) @test w == ZZRingElem[1 2 23; 0 0 0; 0 0 4] v = matrix(FlintZZ, ZZRingElem[1 2 3; 0 0 4; 0 0 0]) - w = @inferred mul(D, v) + w = @inferred D * v @test w == matrix(FlintZZ, ZZRingElem[1 2 23; 0 0 0; 0 0 4]) v = sparse_row(FlintZZ, [2], ZZRingElem[1]) - w = @inferred mul(v, D) + w = @inferred v * D @test w == sparse_row(FlintZZ) # Addition diff --git a/test/Sparse/Solve.jl b/test/Sparse/Solve.jl index aaa3fbcd38..34693a3b5c 100644 --- a/test/Sparse/Solve.jl +++ b/test/Sparse/Solve.jl @@ -20,7 +20,7 @@ fl, sol = can_solve_with_solution(M, b.rows[1]) @test fl - @test mul(sol, M) == b.rows[1] + @test sol * M == b.rows[1] for i in 1:10 r = 10 From 15d561b7e1650eca9327ca51b649eb5dd3a14d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Thu, 12 Oct 2023 07:50:50 +0200 Subject: [PATCH 2/2] Update src/Deprecations.jl --- src/Deprecations.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Deprecations.jl b/src/Deprecations.jl index eb134571d2..8f99968897 100644 --- a/src/Deprecations.jl +++ b/src/Deprecations.jl @@ -123,7 +123,7 @@ @deprecate mul(A::SMat{T}, b::MatElem{T}) where T A*b -@deprecate mul(A::SRow{T}, B::SMat{T}) where T A*b +@deprecate mul(A::SRow{T}, B::SMat{T}) where T A*B # Things that moved to Nemo