Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PolyhedralGeometry: minor fixes #4253

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/PolyhedralGeometry/helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,10 @@ function _parent_or_coefficient_field(::Type{T}, x, y...) where {T<:scalar_types
missing
end

function _parent_or_coefficient_field(::Type{T}, c::Tuple) where {T<:FieldElem}
return _parent_or_coefficient_field(T, c...)
end

function _determine_parent_and_scalar(f::Union{Field,ZZRing}, x...)
_check_field_polyhedral(elem_type(f))
return (f, elem_type(f))
Expand Down
5 changes: 5 additions & 0 deletions test/PolyhedralGeometry/scalar_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
)
@test number_field(coefficient_field(j)) == number_field(coefficient_field(jj))
end
let ng = n_gon(5)
(A,b) = halfspace_matrix_pair(facets(ng))
@test typeof(polyhedron(A,b)) == typeof(ng)
@test coefficient_field(polyhedron(A,b)) == coefficient_field((ng))
end
end

@testset "Cross scalar operations" begin
Expand Down
34 changes: 17 additions & 17 deletions test/PolyhedralGeometry/setup_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ if !isdefined(Main, :_prepare_scalar_types)
KK, (a1, a2) = embedded_number_field([x^2 - 2, x^3 - 5], [(0, 2), (0, 2)])
return [(f, elem_type(f)) for f in (QQ, K, KK)]
end
end

function _check_im_perm_rows(inc::IncidenceMatrix, o)
oinc = incidence_matrix(o)
nr, nc = size(inc)
(nr, nc) == size(oinc) &&
issetequal(Polymake.row.(Ref(inc), 1:nr),
Polymake.row.(Ref(oinc), 1:nr))
end
function _check_im_perm_rows(inc::IncidenceMatrix, o)
oinc = incidence_matrix(o)
nr, nc = size(inc)
(nr, nc) == size(oinc) &&
issetequal(Polymake.row.(Ref(inc), 1:nr),
Polymake.row.(Ref(oinc), 1:nr))
end

_matrix_from_property(b::SubObjectIterator{<:Union{LinearHalfspace, LinearHyperplane}}) = permutedims(hcat([normal_vector(be) for be in b]...))
_matrix_from_property(b::SubObjectIterator{<:Union{LinearHalfspace, LinearHyperplane}}) = permutedims(hcat([normal_vector(be) for be in b]...))

_matrix_from_property(b::SubObjectIterator{<:Union{AffineHalfspace, AffineHyperplane}}) = permutedims(hcat([vcat(-negbias(be), normal_vector(be)) for be in b]...))
_matrix_from_property(b::SubObjectIterator{<:Union{AffineHalfspace, AffineHyperplane}}) = permutedims(hcat([vcat(-negbias(be), normal_vector(be)) for be in b]...))

# only used for cones that are linear halfspaces
_matrix_from_property(b::SubObjectIterator{Cone{T}}) where T = _matrix_from_property(SubObjectIterator{LinearHalfspace{T}}(b.Obj, b.Acc, b.n))
# only used for cones that are linear halfspaces
_matrix_from_property(b::SubObjectIterator{Cone{T}}) where T = _matrix_from_property(SubObjectIterator{LinearHalfspace{T}}(b.Obj, b.Acc, b.n))

_matrix_from_property(b::SubObjectIterator) = permutedims(hcat(b...))
_matrix_from_property(b::SubObjectIterator) = permutedims(hcat(b...))

_oscar_matrix_from_property(a, b::SubObjectIterator) = matrix(a, _matrix_from_property(b))
_oscar_matrix_from_property(a, b::SubObjectIterator) = matrix(a, _matrix_from_property(b))

function _polymake_matrix_from_property(b::SubObjectIterator)
m = _matrix_from_property(b)
return Polymake.Matrix{Oscar._scalar_type_to_polymake(eltype(m))}(m)
function _polymake_matrix_from_property(b::SubObjectIterator)
m = _matrix_from_property(b)
return Polymake.Matrix{Oscar._scalar_type_to_polymake(eltype(m))}(m)
end
end
Loading