Skip to content

Commit

Permalink
Collect _copy_matrix_into_matrix methods, fix name of one (#1541)
Browse files Browse the repository at this point in the history
Now all _copy_matrix_into_matrix are next to each other and the
one for QQMatrix has the right name
  • Loading branch information
fingolfin authored Jun 19, 2024
1 parent 0cf400d commit 5d876ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
11 changes: 10 additions & 1 deletion src/Misc/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ function _copy_matrix_into_matrix(A::ZZMatrix, i::Int, j::Int, B::ZZMatrix)
end
end

function _copy_matrix_into_matrix!(A::QQMatrix, i::Int, j::Int, B::QQMatrix)
function _copy_matrix_into_matrix(A::QQMatrix, i::Int, j::Int, B::QQMatrix)
@GC.preserve A B begin
for k in 0:nrows(B) - 1
for l in 0:ncols(B) - 1
Expand All @@ -348,6 +348,15 @@ function _copy_matrix_into_matrix!(A::QQMatrix, i::Int, j::Int, B::QQMatrix)
end
end

function _copy_matrix_into_matrix(A::MatElem, i::Int, j::Int, B::MatElem)
for k in 0:nrows(B) - 1
for l in 0:ncols(B) - 1
setindex!(A, B[k+1, l+1], i+k, j+l)
end
end
return nothing
end

function _copy_matrix_into_matrix(A::MatElem, r::Vector{Int}, c::Vector{Int}, B::MatElem)
for i = 1:length(r)
for j = 1:length(c)
Expand Down
9 changes: 0 additions & 9 deletions src/Misc/jordan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,6 @@ function decompose_primary(M::MatElem{T}) where T <: FieldElem
return L
end

function _copy_matrix_into_matrix(A::MatElem, i::Int, j::Int, B::MatElem)
for k in 0:nrows(B) - 1
for l in 0:ncols(B) - 1
setindex!(A, B[k+1, l+1], i+k, j+l)
end
end
return nothing
end


@doc raw"""
companion_matrix(p::PolyRingElem) -> MatElem
Expand Down
4 changes: 2 additions & 2 deletions test/Misc/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
A = QQ[1 2; 3 4]
B = QQ[1;]
Z = zero_matrix(QQ, 3, 3)
Hecke._copy_matrix_into_matrix!(Z, 1, 1, A)
Hecke._copy_matrix_into_matrix!(Z, 3, 3, B)
Hecke._copy_matrix_into_matrix(Z, 1, 1, A)
Hecke._copy_matrix_into_matrix(Z, 3, 3, B)
@test Z == diagonal_matrix(A, B)

A = ZZ[1 2; 3 4]
Expand Down

0 comments on commit 5d876ad

Please sign in to comment.