@@ -76,65 +76,76 @@ function k_skeleton(PC::PolyhedralComplex{T}, k::Int) where {T<:scalar_types}
76
76
return PolyhedralComplex {T} (ksk, coefficient_field (PC))
77
77
end
78
78
79
-
80
79
# ##############################################################################
81
80
# # Scalar product
82
81
# ##############################################################################
83
82
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)
83
+ function * (c:: scalar_types_extended , Sigma:: PolyhedralComplex )
84
+ # if scalar is zero, return polyhedral complex consisting only of the origin
85
+ if iszero (c)
86
+ return polyhedral_complex (convex_hull (zero_matrix (QQ, 1 , ambient_dim (Sigma))))
87
+ end
88
+
89
+ # if scalar is non-zero, multiple all vertices and rays by said scalar
90
+ SigmaVertsAndRays = vertices_and_rays (Sigma)
91
+ SigmaRayIndices = findall (vr -> vr isa RayVector, SigmaVertsAndRays)
92
+ SigmaLineality = lineality_space (Sigma)
93
+ SigmaIncidence = maximal_polyhedra (IncidenceMatrix, Sigma)
94
+ return polyhedral_complex (
95
+ coefficient_field (Sigma),
96
+ SigmaIncidence,
97
+ SigmaVertsAndRays .* c,
98
+ SigmaRayIndices,
99
+ SigmaLineality,
100
+ )
96
101
end
97
- * (c:: RationalUnion , Sigma:: PolyhedralComplex ) = QQ (c)* Sigma
98
- * (Sigma:: PolyhedralComplex , c:: RationalUnion ) = c* Sigma
99
-
102
+ * (Sigma:: PolyhedralComplex , c:: scalar_types_extended ) = c * Sigma
100
103
101
104
# ##############################################################################
102
105
# # Negation
103
106
# ##############################################################################
104
107
105
108
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)
109
+ SigmaVertsAndRays = vertices_and_rays (Sigma)
110
+ SigmaRayIndices = findall (vr -> vr isa RayVector, SigmaVertsAndRays)
111
+ SigmaLineality = lineality_space (Sigma)
112
+ SigmaIncidence = maximal_polyhedra (IncidenceMatrix, Sigma)
113
+ return polyhedral_complex (
114
+ SigmaIncidence, - SigmaVertsAndRays, SigmaRayIndices, SigmaLineality
115
+ )
111
116
end
112
117
113
118
# ##############################################################################
114
119
# # Translation
115
120
# ##############################################################################
116
121
117
- function translate_by_vector (u:: PointVector{QQFieldElem} , v:: Vector{QQFieldElem} )
118
- return u .+ v
122
+ # requires separate function because to ensure that translation does not change ray vectors
123
+ function translate_by_vector (
124
+ u:: PointVector{<:scalar_types_extended} , v:: Vector{<:scalar_types_extended}
125
+ )
126
+ return u + v
119
127
end
120
- function translate_by_vector (u:: RayVector{QQFieldElem} , :: Vector{QQFieldElem} )
121
- return u
128
+ function translate_by_vector (
129
+ u:: RayVector{<:scalar_types_extended} , :: Vector{<:scalar_types_extended}
130
+ )
131
+ return u
122
132
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)
133
+ function + (v:: Vector{<:scalar_types_extended} , Sigma:: PolyhedralComplex )
134
+ @req length (v) == ambient_dim (Sigma) " ambient dimension mismatch"
135
+ SigmaVertsAndRays = vertices_and_rays (Sigma)
136
+ SigmaRayIndices = findall (vr -> vr isa RayVector, SigmaVertsAndRays)
137
+ SigmaLineality = lineality_space (Sigma)
138
+ SigmaIncidence = maximal_polyhedra (IncidenceMatrix, Sigma)
139
+ return polyhedral_complex (
140
+ coefficient_field (Sigma),
141
+ SigmaIncidence,
142
+ translate_by_vector .(SigmaVertsAndRays, Ref (v)),
143
+ SigmaRayIndices,
144
+ SigmaLineality,
145
+ )
130
146
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{<:RationalUnion} ) = QQ .(v)+ Sigma
147
+ + (Sigma:: PolyhedralComplex , v:: Vector{<:scalar_types_extended} ) = v + Sigma
137
148
138
149
# Vector addition for polyhedral fans
139
- + (Sigma:: PolyhedralFan , v:: Vector ) = polyhedral_complex (Sigma)+ v
140
- + (v:: Vector , Sigma:: PolyhedralFan ) = v+ polyhedral_complex (Sigma)
150
+ + (Sigma:: PolyhedralFan , v:: Vector{<:scalar_types_extended} ) = polyhedral_complex (Sigma) + v
151
+ + (v:: Vector{<:scalar_types_extended} , Sigma:: PolyhedralFan ) = v + polyhedral_complex (Sigma)
0 commit comments