Skip to content

Commit

Permalink
Move some stuff into more appropriate places (#1562)
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin authored Oct 27, 2023
1 parent fc0d071 commit 89ba431
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
25 changes: 0 additions & 25 deletions src/HeckeMiscMatrix.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
export is_zero_row, is_diagonal, is_lower_triangular, is_positive_entry, is_upper_triangular, diagonal

function mul!(a::zzModMatrix, b::zzModMatrix, c::zzModRingElem)
ccall((:nmod_mat_scalar_mul, libflint), Nothing,
(Ref{zzModMatrix}, Ref{zzModMatrix}, UInt), a, b, c.data)
return a
end

################################################################################
#
Expand All @@ -25,18 +20,6 @@ end

transpose!(A::Union{ZZMatrix,QQMatrix}) = is_square(A) ? transpose!(A, A) : transpose(A)

function transpose!(A::ZZMatrix, B::ZZMatrix)
ccall((:fmpz_mat_transpose, libflint), Nothing,
(Ref{ZZMatrix}, Ref{ZZMatrix}), A, B)
return A
end

function transpose!(A::QQMatrix, B::QQMatrix)
ccall((:fmpq_mat_transpose, libflint), Nothing,
(Ref{QQMatrix}, Ref{QQMatrix}), A, B)
return A
end

function matrix(A::Matrix{ZZRingElem})
m = matrix(FlintZZ, A)
return m
Expand Down Expand Up @@ -65,14 +48,6 @@ function is_zero_row(M::ZZMatrix, i::Int)
return true
end

function is_positive_entry(M::ZZMatrix, i::Int, j::Int)
GC.@preserve M begin
m = ccall((:fmpz_mat_entry, libflint), Ptr{ZZRingElem}, (Ref{ZZMatrix}, Int, Int), M, i - 1, j - 1)
fl = ccall((:fmpz_sgn, libflint), Int, (Ptr{ZZRingElem},), m)
return isone(fl)
end
end

function is_zero_row(M::zzModMatrix, i::Int)
zero = UInt(0)
for j in 1:ncols(M)
Expand Down
4 changes: 0 additions & 4 deletions src/HeckeMoreStuff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,6 @@ function addmul!(A::fpMatrix, B::fpMatrix, C::fpFieldElem, D::fpMatrix)
return A
end

function mul!(A::fpMatrix, B::fpFieldElem, D::fpMatrix)
ccall((:nmod_mat_scalar_mul_ui, libflint), Nothing, (Ref{fpMatrix}, Ref{fpMatrix}, UInt), A, D, B.data)
end

function lift(R::ZZAbsPowerSeriesRing, f::ZZModAbsPowerSeriesRingElem)
r = R()
for i = 0:length(f)-1
Expand Down
6 changes: 6 additions & 0 deletions src/flint/fmpq_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ function transpose(x::QQMatrix)
return z
end

function transpose!(A::QQMatrix, B::QQMatrix)
ccall((:fmpq_mat_transpose, libflint), Nothing,
(Ref{QQMatrix}, Ref{QQMatrix}), A, B)
return A
end

###############################################################################
#
# Row and column swapping
Expand Down
14 changes: 14 additions & 0 deletions src/flint/fmpz_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ isone(a::ZZMatrix) = ccall((:fmpz_mat_is_one, libflint), Bool,
end
end

function is_positive_entry(M::ZZMatrix, i::Int, j::Int)
GC.@preserve M begin
m = mat_entry_ptr(M, i, j)
fl = ccall((:fmpz_sgn, libflint), Int, (Ptr{ZZRingElem},), m)
return isone(fl)
end
end

function deepcopy_internal(d::ZZMatrix, dict::IdDict)
z = ZZMatrix(d)
return z
Expand Down Expand Up @@ -238,6 +246,12 @@ function transpose(x::ZZMatrix)
return z
end

function transpose!(A::ZZMatrix, B::ZZMatrix)
ccall((:fmpz_mat_transpose, libflint), Nothing,
(Ref{ZZMatrix}, Ref{ZZMatrix}), A, B)
return A
end

###############################################################################
#
# Row and column swapping
Expand Down
9 changes: 9 additions & 0 deletions src/flint/nmod_mat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,15 @@ function mul!(z::Vector{UInt}, a::Vector{UInt}, b::T) where T <: Zmodn_mat
return z
end

function mul!(a::zzModMatrix, b::zzModMatrix, c::zzModRingElem)
ccall((:nmod_mat_scalar_mul, libflint), Nothing,
(Ref{zzModMatrix}, Ref{zzModMatrix}, UInt), a, b, c.data)
return a
end

function mul!(A::fpMatrix, B::fpFieldElem, D::fpMatrix)
ccall((:nmod_mat_scalar_mul_ui, libflint), Nothing, (Ref{fpMatrix}, Ref{fpMatrix}, UInt), A, D, B.data)
end

################################################################################
#
Expand Down

0 comments on commit 89ba431

Please sign in to comment.