Skip to content

Commit

Permalink
is_empty for pseudo-matrices (#1691)
Browse files Browse the repository at this point in the history
* Show method for pseudo-matrices modified

Added an output for pseudo-matrices with zero rows that

* Added an 'is_empty' method for pseudo-matrices

* Tests added for is_empty

* Added test for printing
  • Loading branch information
SirToby25 authored Nov 22, 2024
1 parent b9aaec0 commit 3f95a58
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/NumFieldOrd/NfOrd/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2052,3 +2052,12 @@ function inv(x::Generic.MatSpaceElem{AbsSimpleNumFieldOrderElem})
K = nf(R)
return change_base_ring(R, inv(change_base_ring(K, x)))
end

################################################################################
#
# Emptiness check
#
################################################################################

is_empty(P::PMat) = is_empty(matrix(P))

25 changes: 25 additions & 0 deletions test/NfOrd/LinearAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,31 @@
@test Hecke._in_span(map(K, [1, 2, 3, 4]), A)[1]
@test Hecke._in_span(map(K, [5, 6, 7, 8]), A)[1] == false
end
@testset "emptiness" begin
K, a = quadratic_field(-5)
O = maximal_order(K)
ide = fractional_ideal(O, one(O))
pmat00 = pseudo_matrix(identity_matrix(K, 0), [])
pmat02 = pseudo_matrix(matrix(K, 0, 2, []), [])
pmat20 = pseudo_matrix(matrix(K, 2, 0, []), [ide, ide])
pmat11 = pseudo_matrix(identity_matrix(K, 1), [ide])
pmat23 = pseudo_matrix(matrix(K, 2, 3, [1, 2, 3, a, 2*a, 3*a]), [ide, ide])
@test is_empty(pmat00)
@test is_empty(pmat02)
@test is_empty(pmat20)
@test !is_empty(pmat11)
@test !is_empty(pmat23)
@test isempty(pmat00)
@test isempty(pmat02)
@test isempty(pmat20)
@test !is_empty(pmat11)
@test !is_empty(pmat23)

@test sprint(show, pmat00) isa String
@test sprint(show, pmat02) isa String
@test sprint(show, pmat20) isa String

end
end

@testset "rand" begin
Expand Down

0 comments on commit 3f95a58

Please sign in to comment.