Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Sep 26, 2023
1 parent ec1ac49 commit d44095a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Sparse/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ similar(A::SMat, m::Int, n::Int) = sparse_matrix(base_ring(A), m, n)

################################################################################
#
# (Block) diagonal matrices
# Block diagonal matrices
#
################################################################################

Expand Down
2 changes: 1 addition & 1 deletion src/Sparse/Row.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ end
Constructs the sparse row $(a_i)_i$ over $R$ with $a_{i_j} = x_j$, where
$J = (i_j)_j$ and $V = (x_j)_j$.
"""
function sparse_row(R::Ring, pos::Vector{Int}, val::Vector{T}; sort::Bool = true) where T
function sparse_row(R::Ring, pos::Vector{Int}, val::AbstractVector{T}; sort::Bool = true) where T
if sort
p = sortperm(pos)
pos = pos[p]
Expand Down
2 changes: 1 addition & 1 deletion src/Sparse/ZZRow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function sparse_row(R::ZZRing, A::Vector{Tuple{Int64, ZZRingElem}}; sort::Bool =
return SRow(R, l, a)
end

function sparse_row(R::ZZRing, pos::Vector{Int64}, val::Vector{ZZRingElem}; sort::Bool = true)
function sparse_row(R::ZZRing, pos::Vector{Int64}, val::AbstractVector{ZZRingElem}; sort::Bool = true)
if sort
p = sortperm(pos)
pos = pos[p]
Expand Down
11 changes: 11 additions & 0 deletions test/Sparse/Matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,17 @@ using Hecke.SparseArrays
@test D == sparse_matrix(FlintZZ, [0 0 0; 0 0 0; 0 0 0; 0 0 0]);
@test D == sparse_matrix(FlintZZ, 4, 3)

# Block diag matrix

D1 = sparse_matrix(FlintZZ, [1 5; 0 1])
D2 = sparse_matrix(FlintZZ, [2 3 8; 4 0 0])
D = @inferred block_diagonal_matrix([D1, D2])
@test D == sparse_matrix(FlintZZ, [1 5 0 0 0; 0 1 0 0 0; 0 0 2 3 8; 0 0 4 0 0])
D = @inferred diagonal_matrix([D1, D2])
@test D == sparse_matrix(FlintZZ, [1 5 0 0 0; 0 1 0 0 0; 0 0 2 3 8; 0 0 4 0 0])
D = @inferred diagonal_matrix(D1, D2)
@test D == sparse_matrix(FlintZZ, [1 5 0 0 0; 0 1 0 0 0; 0 0 2 3 8; 0 0 4 0 0])

# Concatenation syntax

D = sparse_matrix(FlintZZ, [1 5 3; 0 -10 0; 0 1 0])
Expand Down

0 comments on commit d44095a

Please sign in to comment.