From 14b78f0db9cbd253414b751d14644843354e7557 Mon Sep 17 00:00:00 2001 From: cielavenir Date: Fri, 6 Jun 2025 16:21:52 +0900 Subject: [PATCH 1/5] Add missing operators to nditerator --- pythran/pythonic/include/types/nditerator.hpp | 9 +++ pythran/pythonic/types/nditerator.hpp | 57 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/pythran/pythonic/include/types/nditerator.hpp b/pythran/pythonic/include/types/nditerator.hpp index 0d1f8281a..934e5cc0a 100644 --- a/pythran/pythonic/include/types/nditerator.hpp +++ b/pythran/pythonic/include/types/nditerator.hpp @@ -66,6 +66,9 @@ namespace types bool operator!=(nditerator const &other) const; bool operator==(nditerator const &other) const; bool operator<(nditerator const &other) const; + bool operator>(nditerator const &other) const; + bool operator<=(nditerator const &other) const; + bool operator>=(nditerator const &other) const; nditerator &operator=(nditerator const &other); }; @@ -92,6 +95,9 @@ namespace types bool operator!=(const_nditerator const &other) const; bool operator==(const_nditerator const &other) const; bool operator<(const_nditerator const &other) const; + bool operator>(const_nditerator const &other) const; + bool operator<=(const_nditerator const &other) const; + bool operator>=(const_nditerator const &other) const; const_nditerator &operator=(const_nditerator const &other); }; #ifdef USE_XSIMD @@ -115,6 +121,9 @@ namespace types bool operator!=(const_simd_nditerator const &other) const; bool operator==(const_simd_nditerator const &other) const; bool operator<(const_simd_nditerator const &other) const; + bool operator>(const_simd_nditerator const &other) const; + bool operator<=(const_simd_nditerator const &other) const; + bool operator>=(const_simd_nditerator const &other) const; const_simd_nditerator &operator=(const_simd_nditerator const &other); void store(xsimd::batch const &); }; diff --git a/pythran/pythonic/types/nditerator.hpp b/pythran/pythonic/types/nditerator.hpp index 2cb2b9047..ef2b7c4a8 100644 --- a/pythran/pythonic/types/nditerator.hpp +++ b/pythran/pythonic/types/nditerator.hpp @@ -97,6 +97,24 @@ namespace types return index < other.index; } + template + bool nditerator::operator>(nditerator const &other) const + { + return index > other.index; + } + + template + bool nditerator::operator<=(nditerator const &other) const + { + return !(index > other.index); + } + + template + bool nditerator::operator>=(nditerator const &other) const + { + return !(index < other.index); + } + template nditerator &nditerator::operator=(nditerator const &other) { @@ -188,6 +206,24 @@ namespace types return index < other.index; } + template + bool const_nditerator::operator>(const_nditerator const &other) const + { + return index > other.index; + } + + template + bool const_nditerator::operator<=(const_nditerator const &other) const + { + return !(index > other.index); + } + + template + bool const_nditerator::operator>=(const_nditerator const &other) const + { + return !(index < other.index); + } + template const_nditerator & const_nditerator::operator=(const_nditerator const &other) @@ -271,6 +307,27 @@ namespace types return data < other.data; } + template + bool const_simd_nditerator::operator>( + const_simd_nditerator const &other) const + { + return data > other.data; + } + + template + bool const_simd_nditerator::operator<=( + const_simd_nditerator const &other) const + { + return !(data > other.data); + } + + template + bool const_simd_nditerator::operator>=( + const_simd_nditerator const &other) const + { + return !(data < other.data); + } + template const_simd_nditerator & const_simd_nditerator::operator=(const_simd_nditerator const &other) -- 2.49.0