diff --git a/Rich/RichFutureUtils/include/RichFutureUtils/RichMirrorFinder.h b/Rich/RichFutureUtils/include/RichFutureUtils/RichMirrorFinder.h index 215b57534e903ef0791cc5f74a884f55ef66d8f4..3163d366d86458b32cd8f26b6c787f9039eec968 100644 --- a/Rich/RichFutureUtils/include/RichFutureUtils/RichMirrorFinder.h +++ b/Rich/RichFutureUtils/include/RichFutureUtils/RichMirrorFinder.h @@ -267,18 +267,25 @@ namespace Rich::Utils { /// Combine two (scalar) x,y indices in a single one [[nodiscard]] ScalarIndex xyIndex( const ScalarIndex ix, // const ScalarIndex iy ) const noexcept { + assert( ix < NXBINS ); + assert( iy < NYBINS ); return ( NYBINS * ix ) + iy; } /// Combine two (SIMD) x,y indices in a single one [[nodiscard]] typename SIMDIndices::IndexType xyIndex( const typename SIMDIndices::IndexType& ix, // const typename SIMDIndices::IndexType& iy // ) const noexcept { + assert( all_of( ix < SIMDIndices::IndexType( NXBINS ) ) ); + assert( all_of( iy < SIMDIndices::IndexType( NYBINS ) ) ); return ( SIMDIndices::IndexType( NYBINS ) * ix ) + iy; } public: /// Access the mirror for a given combined xy index (Scalar) - [[nodiscard]] MirrorNum get( const ScalarIndex ixy ) const noexcept { return ( *this )[ixy]; } + [[nodiscard]] MirrorNum get( const ScalarIndex ixy ) const noexcept { + assert( ixy < size() ); + return ( *this )[ixy]; + } /// Access the mirror for a given set of (x,y) indices (Scalar) [[nodiscard]] MirrorNum get( const ScalarIndex ix, // const ScalarIndex iy ) const noexcept { @@ -289,6 +296,7 @@ namespace Rich::Utils { /// Access the mirror for a given xy index (SIMD) [[nodiscard]] SIMDIndices get( const typename SIMDIndices::IndexType& ixy ) const noexcept { // gather SIMD lookup + assert( all_of( ixy < SIMDIndices::IndexType( size() ) ) ); return ( *this )[ixy]; }