File tree 1 file changed +5
-2
lines changed
librapid/include/librapid/array
1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -128,8 +128,8 @@ namespace librapid {
128
128
// / \param start Starting index
129
129
// / \param end Ending index
130
130
// / \return Subshape
131
- LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto subshape (DimType start, DimType end) const
132
- -> Shape;
131
+ LIBRAPID_NODISCARD LIBRAPID_ALWAYS_INLINE auto subshape (DimType start = - 1 ,
132
+ DimType end = - 1 ) const -> Shape;
133
133
134
134
// / Return the number of elements the Shape object represents
135
135
// / \return Number of elements
@@ -377,6 +377,9 @@ namespace librapid {
377
377
LIBRAPID_NODISCARD auto Shape::ndim () const -> DimType { return m_dims; }
378
378
379
379
LIBRAPID_NODISCARD auto Shape::subshape (DimType start, DimType end) const -> Shape {
380
+ if (start < 0 ) start = 0 ;
381
+ if (end < 0 ) end = m_dims;
382
+
380
383
LIBRAPID_ASSERT_WITH_EXCEPTION (std::range_error,
381
384
start <= end,
382
385
" Start index ({}) must not be greater than end index ({})" ,
You can’t perform that action at this time.
0 commit comments