|
1 | 1 | @doc raw"""
|
2 | 2 | common_refinement(PC1::PolyhedralComplex{T},PC2::PolyhedralComplex{T}) where T<:scalar_types
|
3 | 3 |
|
4 |
| -Return the common refinement of two polyhedral complexes. |
| 4 | +Return the common refinement of two polyhedral complexes. |
5 | 5 |
|
6 | 6 | # Examples
|
7 | 7 | ```jldoctest
|
@@ -75,3 +75,68 @@ function k_skeleton(PC::PolyhedralComplex{T}, k::Int) where {T<:scalar_types}
|
75 | 75 | )
|
76 | 76 | return PolyhedralComplex{T}(ksk, coefficient_field(PC))
|
77 | 77 | end
|
| 78 | + |
| 79 | + |
| 80 | +############################################################################### |
| 81 | +## Scalar product |
| 82 | +############################################################################### |
| 83 | + |
| 84 | +function *(c::QQFieldElem, Sigma::PolyhedralComplex) |
| 85 | + # if scalar is zero, return polyhedral complex consisting only of the origin |
| 86 | + if iszero(c) |
| 87 | + return polyhedral_complex(convex_hull(zero_matrix(QQ,1,ambient_dim(Sigma)))) |
| 88 | + end |
| 89 | + |
| 90 | + # if scalar is non-zero, multiple all vertices and rays by said scalar |
| 91 | + SigmaVertsAndRays = vertices_and_rays(Sigma) |
| 92 | + SigmaRayIndices = findall(vr -> vr isa RayVector, SigmaVertsAndRays) |
| 93 | + SigmaLineality = lineality_space(Sigma) |
| 94 | + SigmaIncidence = maximal_polyhedra(IncidenceMatrix,Sigma) |
| 95 | + return polyhedral_complex(SigmaIncidence, multiply_by_nonzero_scalar.(SigmaVertsAndRays,c), SigmaRayIndices, SigmaLineality) |
| 96 | +end |
| 97 | +*(c::Union{ZZRingElem,Rational,Int}, Sigma::PolyhedralComplex) = QQ(c)*Sigma |
| 98 | +*(Sigma::PolyhedralComplex, c::Union{QQFieldElem,ZZRingElem,Rational,Int}) = c*Sigma |
| 99 | + |
| 100 | + |
| 101 | +############################################################################### |
| 102 | +## Negation |
| 103 | +############################################################################### |
| 104 | + |
| 105 | +function -(Sigma::PolyhedralComplex) |
| 106 | + SigmaVertsAndRays = vertices_and_rays(Sigma) |
| 107 | + SigmaRayIndices = findall(vr -> vr isa RayVector, SigmaVertsAndRays) |
| 108 | + SigmaLineality = lineality_space(Sigma) |
| 109 | + SigmaIncidence = maximal_polyhedra(IncidenceMatrix,Sigma) |
| 110 | + return polyhedral_complex(SigmaIncidence, -SigmaVertsAndRays, SigmaRayIndices, SigmaLineality) |
| 111 | +end |
| 112 | + |
| 113 | +############################################################################### |
| 114 | +## Translation |
| 115 | +############################################################################### |
| 116 | + |
| 117 | +function translate_by_vector(u::PointVector{QQFieldElem}, v::Vector{QQFieldElem}) |
| 118 | + return u .+ v |
| 119 | +end |
| 120 | +function translate_by_vector(u::RayVector{QQFieldElem}, ::Vector{QQFieldElem}) |
| 121 | + return u |
| 122 | +end |
| 123 | +function +(v::Vector{QQFieldElem}, Sigma::PolyhedralComplex) |
| 124 | + @req length(v)==ambient_dim(Sigma) "ambient dimension mismatch" |
| 125 | + SigmaVertsAndRays = vertices_and_rays(Sigma) |
| 126 | + SigmaRayIndices = findall(vr -> vr isa RayVector, SigmaVertsAndRays) |
| 127 | + SigmaLineality = lineality_space(Sigma) |
| 128 | + SigmaIncidence = maximal_polyhedra(IncidenceMatrix,Sigma) |
| 129 | + return polyhedral_complex(SigmaIncidence, translate_by_vector.(SigmaVertsAndRays,Ref(v)), SigmaRayIndices, SigmaLineality) |
| 130 | +end |
| 131 | ++(v::Vector{ZZRingElem}, Sigma::PolyhedralComplex) = QQ.(v)+Sigma |
| 132 | ++(v::Vector{Rational}, Sigma::PolyhedralComplex) = QQ.(v)+Sigma |
| 133 | ++(v::Vector{Int}, Sigma::PolyhedralComplex) = QQ.(v)+Sigma |
| 134 | + |
| 135 | ++(Sigma::PolyhedralComplex, v::Vector{QQFieldElem}) = v+Sigma |
| 136 | ++(Sigma::PolyhedralComplex, v::Vector{ZZRingElem}) = QQ.(v)+Sigma |
| 137 | ++(Sigma::PolyhedralComplex, v::Vector{Rational}) = QQ.(v)+Sigma |
| 138 | ++(Sigma::PolyhedralComplex, v::Vector{Int}) = QQ.(v)+Sigma |
| 139 | + |
| 140 | +# Vector addition for polyhedral fans |
| 141 | ++(Sigma::PolyhedralFan, v::Vector) = polyhedral_complex(Sigma)+v |
| 142 | ++(v::Vector, Sigma::PolyhedralFan) = v+polyhedral_complex(Sigma) |
0 commit comments