File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ namespace xt
9595 auto & reshape (S&& shape, layout_type layout = base_type::static_layout) &;
9696
9797 layout_type layout () const ;
98+ bool is_contiguous () const noexcept ;
9899
99100 using base_type::operator ();
100101 using base_type::operator [];
@@ -465,6 +466,27 @@ namespace xt
465466 }
466467 }
467468
469+ /* *
470+ * Return whether or not the container uses contiguous buffer
471+ * @return Boolean for contiguous buffer
472+ */
473+ template <class D >
474+ inline bool pycontainer<D>::is_contiguous() const noexcept
475+ {
476+ if (PyArray_CHKFLAGS (python_array (), NPY_ARRAY_C_CONTIGUOUS))
477+ {
478+ return 1 == this ->strides ().back ();
479+ }
480+ else if (PyArray_CHKFLAGS (python_array (), NPY_ARRAY_F_CONTIGUOUS))
481+ {
482+ return 1 == this ->strides ().front ();
483+ }
484+ else
485+ {
486+ return false ;
487+ }
488+ }
489+
468490 /* *
469491 * Import the numpy Python module.
470492 */
You can’t perform that action at this time.
0 commit comments