diff --git a/include/array/array.h b/include/array/array.h index dac1709..975b479 100644 --- a/include/array/array.h +++ b/include/array/array.h @@ -458,13 +458,13 @@ class dim : protected interval { using base_range::begin; using base_range::end; using base_range::extent; - using base_range::size; using base_range::is_in_range; using base_range::max; using base_range::min; using base_range::set_extent; using base_range::set_max; using base_range::set_min; + using base_range::size; /** Get or set the distance in flat indices between neighboring elements * in this dim. */ @@ -560,9 +560,7 @@ class split_iterator { split_iterator result(*this); return result += n; } - NDARRAY_HOST_DEVICE split_iterator& operator++() { - return *this += 1; - } + NDARRAY_HOST_DEVICE split_iterator& operator++() { return *this += 1; } NDARRAY_HOST_DEVICE split_iterator operator++(int) { split_iterator result(*this); *this += 1; @@ -612,15 +610,13 @@ class split_result { * - `split<5>(interval<>(0, 12))` produces the intervals `[0, 5)`, * `[5, 10)`, `[7, 12)`. Note the last two intervals overlap. */ template -NDARRAY_HOST_DEVICE internal::split_result split( - const interval& v) { +NDARRAY_HOST_DEVICE internal::split_result split(const interval& v) { assert(v.extent() >= InnerExtent); return {{fixed_interval(v.min()), v.max()}, {fixed_interval(v.max() + 1), v.max()}}; } template -NDARRAY_HOST_DEVICE internal::split_result split( - const dim& v) { +NDARRAY_HOST_DEVICE internal::split_result split(const dim& v) { return split(interval(v.min(), v.extent())); } @@ -1031,10 +1027,12 @@ NDARRAY_HOST_DEVICE const DimsSrc& assert_dims_compatible(const DimsSrc& src) { return src; } -/** Return a tuple of generic `dims` with same min and extents and all strides set to `unresolved`. */ +/** Return a tuple of generic `dims` with same min and extents and all strides set to `unresolved`. + */ template auto bounds_tuple(const Dims& dims, index_sequence) { - return std::make_tuple(dim<>(std::get(dims).min(), std::get(dims).extent(), unresolved)...); + return std::make_tuple( + dim<>(std::get(dims).min(), std::get(dims).extent(), unresolved)...); } } // namespace internal @@ -2174,26 +2172,6 @@ class array_ref { NDARRAY_HOST_DEVICE index_t rows() const { return shape_.rows(); } NDARRAY_HOST_DEVICE index_t columns() const { return shape_.columns(); } - /** Compare the contents of this array_ref to `other`. For two array_refs to - * be considered equal, they must have the same shape, and all elements - * addressable by the shape must also be equal. */ - // TODO: Maybe this should just check for equality of the shape and pointer, - // and let the free function equal serve this purpose. - NDARRAY_HOST_DEVICE bool operator!=(const array_ref& other) const { - if (shape_ != other.shape_) { return true; } - - // TODO: This currently calls operator!= on all elements of the array_ref, - // even after we find a non-equal element - // (https://github.com/dsharlet/array/issues/4). - bool result = false; - copy_shape_traits::for_each_value( - shape_, base_, other.shape_, other.base_, [&](const_reference a, const_reference b) { - if (a != b) { result = true; } - }); - return result; - } - NDARRAY_HOST_DEVICE bool operator==(const array_ref& other) const { return !operator!=(other); } - NDARRAY_HOST_DEVICE const array_ref& ref() const { return *this; } /** Allow conversion from array_ref to const_array_ref. */ @@ -2983,7 +2961,8 @@ bool equal(const array& a, const array& * `NewShape`. The new shape is copy constructed from `a.shape()`. */ template NDARRAY_HOST_DEVICE array_ref convert_shape(const array_ref& a) { - return array_ref(a.base(), convert_shape(a.shape()), internal::no_resolve{}); + return array_ref( + a.base(), convert_shape(a.shape()), internal::no_resolve{}); } template array_ref convert_shape(array& a) {