Skip to content
Snippets Groups Projects
Commit 4945e596 authored by Christopher Rob Jones's avatar Christopher Rob Jones
Browse files

RichMirrorFinder: Add some asserts to validate indices are always in range.

parent 1fbc3550
No related branches found
No related tags found
2 merge requests!4386Merge master into FTRetinaSeedRawBanks,!4324RichMirrorFinder: Add some asserts to validate indices are always in range.
Pipeline #6345454 passed
...@@ -267,18 +267,25 @@ namespace Rich::Utils { ...@@ -267,18 +267,25 @@ namespace Rich::Utils {
/// Combine two (scalar) x,y indices in a single one /// Combine two (scalar) x,y indices in a single one
[[nodiscard]] ScalarIndex xyIndex( const ScalarIndex ix, // [[nodiscard]] ScalarIndex xyIndex( const ScalarIndex ix, //
const ScalarIndex iy ) const noexcept { const ScalarIndex iy ) const noexcept {
assert( ix < NXBINS );
assert( iy < NYBINS );
return ( NYBINS * ix ) + iy; return ( NYBINS * ix ) + iy;
} }
/// Combine two (SIMD) x,y indices in a single one /// Combine two (SIMD) x,y indices in a single one
[[nodiscard]] typename SIMDIndices::IndexType xyIndex( const typename SIMDIndices::IndexType& ix, // [[nodiscard]] typename SIMDIndices::IndexType xyIndex( const typename SIMDIndices::IndexType& ix, //
const typename SIMDIndices::IndexType& iy // const typename SIMDIndices::IndexType& iy //
) const noexcept { ) const noexcept {
assert( all_of( ix < SIMDIndices::IndexType( NXBINS ) ) );
assert( all_of( iy < SIMDIndices::IndexType( NYBINS ) ) );
return ( SIMDIndices::IndexType( NYBINS ) * ix ) + iy; return ( SIMDIndices::IndexType( NYBINS ) * ix ) + iy;
} }
public: public:
/// Access the mirror for a given combined xy index (Scalar) /// 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) /// Access the mirror for a given set of (x,y) indices (Scalar)
[[nodiscard]] MirrorNum get( const ScalarIndex ix, // [[nodiscard]] MirrorNum get( const ScalarIndex ix, //
const ScalarIndex iy ) const noexcept { const ScalarIndex iy ) const noexcept {
...@@ -289,6 +296,7 @@ namespace Rich::Utils { ...@@ -289,6 +296,7 @@ namespace Rich::Utils {
/// Access the mirror for a given xy index (SIMD) /// Access the mirror for a given xy index (SIMD)
[[nodiscard]] SIMDIndices get( const typename SIMDIndices::IndexType& ixy ) const noexcept { [[nodiscard]] SIMDIndices get( const typename SIMDIndices::IndexType& ixy ) const noexcept {
// gather SIMD lookup // gather SIMD lookup
assert( all_of( ixy < SIMDIndices::IndexType( size() ) ) );
return ( *this )[ixy]; return ( *this )[ixy];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment