Skip to content

Commit

Permalink
Add hash method for RayVector (#4354)
Browse files Browse the repository at this point in the history
* added hash method for RayVector; fixed wrong test

* add isequal and corresponding test for RayVector
  • Loading branch information
alexej-jordan authored Nov 29, 2024
1 parent 17ba921 commit f83a525
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/PolyhedralGeometry/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ Base.:(==)(::PointVector, ::RayVector) =
Base.:(==)(::RayVector, ::PointVector) =
throw(ArgumentError("Cannot compare PointVector to RayVector"))

Base.isequal(x::RayVector, y::RayVector) = x == y

Base.hash(x::RayVector, h::UInt) = hash(collect(sign.(x)), hash(coefficient_field(x), h))

################################################################################
######## Halfspaces and Hyperplanes
################################################################################
Expand Down
2 changes: 1 addition & 1 deletion test/PolyhedralGeometry/cone.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
if T == QQFieldElem
@test hilbert_basis(Cone1) isa SubObjectIterator{PointVector{ZZRingElem}}
@test length(hilbert_basis(Cone1)) == 2
@test issetequal(hilbert_basis(Cone1), ray_vector.(Ref(ZZ), [[1, 0], [0, 1]]))
@test issetequal(hilbert_basis(Cone1), point_vector.(Ref(ZZ), [[1, 0], [0, 1]]))
@test generator_matrix(hilbert_basis(Cone1)) == _oscar_matrix_from_property(ZZ, hilbert_basis(Cone1))
end
@test n_rays(Cone1) == 2
Expand Down
3 changes: 3 additions & 0 deletions test/PolyhedralGeometry/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
end
end
end
if T == RayVector
@test length(Set(ray_vector.(Ref(f), [[1,2,3],[2,4,6],[-1,-2,-3]]))) == 2
end
end
end

Expand Down

0 comments on commit f83a525

Please sign in to comment.