Skip to content

Commit 87fb4c1

Browse files
committed
Aff-like: Add __truediv__, floor, ceil
1 parent 6443960 commit 87fb4c1

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

namedisl/expression_like.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,11 @@ class _NamedAffLike(_NamedExpressionLike[IslAffLikeT_co]):
278278
.. automethod:: is_constant
279279
.. automethod:: gist
280280
.. automethod:: gist_params
281+
.. automethod:: div
282+
.. automethod:: __truediv__
281283
.. automethod:: __mod__
284+
.. automethod:: floor
285+
.. automethod:: ceil
282286
"""
283287

284288
def is_constant(self) -> bool:
@@ -299,9 +303,21 @@ def gist_params(self, set: Set) -> Self:
299303
return type(self)(
300304
cast("IslAffLikeT_co", self_a._obj.gist_params(set_a._obj)), self_a.space)
301305

306+
def __truediv__(self, other: Self) -> Self:
307+
self_a, other_a = _align_two_expr_likes(self, other)
308+
return type(self)(
309+
cast("IslAffLikeT_co", self_a._obj.div(other_a._obj)),
310+
self_a.space)
311+
302312
def __mod__(self, other: isl.Val | int) -> Self:
303313
return type(self)(cast("IslAffLikeT_co", self._obj.mod_val(other)), self.space)
304314

315+
def floor(self) -> Self:
316+
return type(self)(cast("IslAffLikeT_co", self._obj.floor()), self.space)
317+
318+
def ceil(self) -> Self:
319+
return type(self)(cast("IslAffLikeT_co", self._obj.ceil()), self.space)
320+
305321

306322
class _NamedHasCoefficients(NamedIslObject[IslHasCoefficientsT_co]):
307323
__doc__ = """
@@ -500,8 +516,6 @@ class PwAff(_NamedAffLike[isl.PwAff]):
500516
.. automethod:: lt_set
501517
.. automethod:: max
502518
.. automethod:: min
503-
.. automethod:: div
504-
.. automethod:: floor
505519
.. automethod:: get_aggregate_domain
506520
.. automethod:: union_max
507521
.. automethod:: union_min
@@ -600,13 +614,6 @@ def min(self, other: PwAff) -> PwAff:
600614
self_a, other_a = _align_two_expr_likes(self, other)
601615
return PwAff(self_a._obj.min(other_a._obj), self_a.space)
602616

603-
def div(self, other: PwAff) -> PwAff:
604-
self_a, other_a = _align_two_expr_likes(self, other)
605-
return PwAff(self_a._obj.div(other_a._obj), self_a.space)
606-
607-
def floor(self) -> PwAff:
608-
return PwAff(self._obj.floor(), self.space)
609-
610617
def get_pieces(self) -> list[tuple[Set, Aff]]:
611618
set_space = self.space.as_set_space()
612619
from .set_like import Set

0 commit comments

Comments
 (0)