Skip to content

Commit

Permalink
fix tess
Browse files Browse the repository at this point in the history
  • Loading branch information
GiggleLiu committed Feb 25, 2024
1 parent f28ce2b commit eb438c6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/PermMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ function Base.show(io::IO, M::AbstractPermMatrix)
end
end
end
Base.hash(pm::AbstractPermMatrix) = hash((pm.perm, pm.vals))

######### sparse array interfaces #########
nnz(M::AbstractPermMatrix) = length(M.vals)
Expand Down
2 changes: 1 addition & 1 deletion src/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ end
function PermMatrixCSC{Tv,Ti}(A::AbstractMatrix) where {Tv,Ti}
i, j, v = _findnz(A)
j == collect(1:size(A, 2)) || throw(ArgumentError("This is not a PermMatrix"))
PermMatrix{Tv,Ti}(Vector{Ti}(i), Vector{Tv}(v))
PermMatrixCSC{Tv,Ti}(Vector{Ti}(i), Vector{Tv}(v))
end

for MT in [:PermMatrix, :PermMatrixCSC]
Expand Down
2 changes: 1 addition & 1 deletion src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ end
function Base.:*(A::PermMatrixCSC, B::PermMatrixCSC)
@assert basetype(A) == basetype(B)
size(A, 1) == size(B, 1) || throw(DimensionMismatch())
basetype(A)(A.perm[B.perm], B.vals .* view(A.vals, B.perm))
basetype(A)(A.perm[B.perm], [B.vals[i] * A.vals[B.perm[i]] for i in 1:size(A, 1)])
end

# to matrix
Expand Down
3 changes: 3 additions & 0 deletions test/PermMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ v = [0.5, 0.3im, 0.2, 1.0]

@testset "basic" begin
@test p1 == copy(p1)
@test hash(p1) == hash(copy(p1))
@test hash(p1) != hash(p2)
@test eltype(p1) == ComplexF64
@test eltype(p2) == Float64
@test eltype(p3) == Float64
Expand All @@ -29,6 +31,7 @@ v = [0.5, 0.3im, 0.2, 1.0]
@test p1[1, 1] === 0.1 + 0.0im
copyto!(p0, p1)
@test p0 == p1
@test PermMatrix([0.0 -1.0im; 1.0im 0.0im]) [0.0 -1.0im; 1.0im 0.0im]
end

@testset "linalg" begin
Expand Down
3 changes: 3 additions & 0 deletions test/PermMatrixCSC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ v = [0.5, 0.3im, 0.2, 1.0]

@testset "basic" begin
@test p1 == copy(p1)
@test hash(p1) == hash(copy(p1))
@test hash(p1) != hash(p2)
@test eltype(p1) == ComplexF64
@test eltype(p2) == Float64
@test eltype(p3) == Float64
Expand All @@ -29,6 +31,7 @@ v = [0.5, 0.3im, 0.2, 1.0]
@test p1[1, 1] === 0.1 + 0.0im
copyto!(p0, p1)
@test p0 == p1
@test PermMatrix([0.0 -1.0im; 1.0im 0.0im]) [0.0 -1.0im; 1.0im 0.0im]
end

@testset "linalg" begin
Expand Down

0 comments on commit eb438c6

Please sign in to comment.