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
95
95
auto & reshape (S&& shape, layout_type layout = base_type::static_layout) &;
96
96
97
97
layout_type layout () const ;
98
+ bool is_contiguous () const noexcept ;
98
99
99
100
using base_type::operator ();
100
101
using base_type::operator [];
@@ -465,6 +466,27 @@ namespace xt
465
466
}
466
467
}
467
468
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
+
468
490
/* *
469
491
* Import the numpy Python module.
470
492
*/
You can’t perform that action at this time.
0 commit comments