@@ -76,6 +76,9 @@ namespace xt
76
76
template <class E >
77
77
auto vsplit (E& e, std::size_t n);
78
78
79
+ template <class E >
80
+ auto flip (E&& e);
81
+
79
82
template <class E >
80
83
auto flip (E&& e, std::size_t axis);
81
84
@@ -589,7 +592,7 @@ namespace xt
589
592
/* *
590
593
* @brief Split an xexpression into subexpressions horizontally (column-wise)
591
594
*
592
- * This method is equivalent to ``split(e, n, 1)``.
595
+ * This method is equivalent to ``split(e, n, 1)``.
593
596
*
594
597
* @param e input xexpression
595
598
* @param n number of elements to return
@@ -618,6 +621,24 @@ namespace xt
618
621
* flip implementation *
619
622
***********************/
620
623
624
+ /* *
625
+ * @brief Reverse the order of elements in an xexpression along every axis.
626
+ *
627
+ * @param e the input xexpression
628
+ *
629
+ * @return returns a view with the result of the flip.
630
+ */
631
+ template <class E >
632
+ inline auto flip (E&& e)
633
+ {
634
+ using size_type = typename std::decay_t <E>::size_type;
635
+ auto r = flip (e, 0 );
636
+ for (size_type d = 1 ; d < e.dimension (); ++d) {
637
+ r = flip (r, d);
638
+ }
639
+ return r;
640
+ }
641
+
621
642
/* *
622
643
* @brief Reverse the order of elements in an xexpression along the given axis.
623
644
* Note: A NumPy/Matlab style `flipud(arr)` is equivalent to `xt::flip(arr, 0)`,
@@ -902,7 +923,7 @@ namespace xt
902
923
* @brief Repeats elements of an expression along a given axis.
903
924
*
904
925
* @param e the input xexpression
905
- * @param repeats The number of repetition of each elements. The size of \ref repeats
926
+ * @param repeats The number of repetition of each elements. The size of \ref repeats
906
927
* must match the shape of the given \ref axis.
907
928
* @param axis the axis along which to repeat the value
908
929
*
@@ -918,7 +939,7 @@ namespace xt
918
939
* @brief Repeats elements of an expression along a given axis.
919
940
*
920
941
* @param e the input xexpression
921
- * @param repeats The number of repetition of each elements. The size of \ref repeats
942
+ * @param repeats The number of repetition of each elements. The size of \ref repeats
922
943
* must match the shape of the given \ref axis.
923
944
* @param axis the axis along which to repeat the value
924
945
*
0 commit comments