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

Rename mul to * #1243

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/src/sparse/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions src/Deprecations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@

# 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

@deprecate field_of_fractions(O::GenOrd) function_field(O::GenOrd)

# Things that moved to Nemo
Expand Down
6 changes: 3 additions & 3 deletions src/NumField/NfAbs/NormRelation/SUnits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

for l=1:ngens(Szk)
u = mS(Szk[l]) #do compact rep here???
valofnewelement = mul(mS.valuations[l], z)
valofnewelement = mS.valuations[l] * z

Check warning on line 43 in src/NumField/NfAbs/NormRelation/SUnits.jl

View check run for this annotation

Codecov / codecov/patch

src/NumField/NfAbs/NormRelation/SUnits.jl#L43

Added line #L43 was not covered by tests
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
Expand Down Expand Up @@ -81,7 +81,7 @@
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]

Check warning on line 84 in src/NumField/NfAbs/NormRelation/SUnits.jl

View check run for this annotation

Codecov / codecov/patch

src/NumField/NfAbs/NormRelation/SUnits.jl#L84

Added line #L84 was not covered by tests
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
Expand Down Expand Up @@ -228,7 +228,7 @@
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)))
Expand Down
2 changes: 1 addition & 1 deletion src/NumFieldOrd/NfOrd/Clgp/Map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@
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)

Check warning on line 474 in src/NumFieldOrd/NfOrd/Clgp/Map.jl

View check run for this annotation

Codecov / codecov/patch

src/NumFieldOrd/NfOrd/Clgp/Map.jl#L474

Added line #L474 was not covered by tests
prime_exp = [ prime_exponents[i] for i in 1:length(c.FB.ideals)]
invx = inv(x)
dinvx = denominator(invx)
Expand Down
2 changes: 1 addition & 1 deletion src/NumFieldOrd/NfOrd/Clgp/cm_field.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
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

Check warning on line 32 in src/NumFieldOrd/NfOrd/Clgp/cm_field.jl

View check run for this annotation

Codecov / codecov/patch

src/NumFieldOrd/NfOrd/Clgp/cm_field.jl#L32

Added line #L32 was not covered by tests
Hecke.class_group_add_relation(c, u, valofnewelement, add_orbit = false, always = false)
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/Sparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
18 changes: 8 additions & 10 deletions src/Sparse/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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])
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions src/Sparse/Solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,15 @@ 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)

sol += pp*z

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
Expand All @@ -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)
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions test/Sparse/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/Sparse/Solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading