Skip to content

Commit 6c8679e

Browse files
committed
Improve reorder_v2 function documentation
Added more illustrations to example code
1 parent b1a3250 commit 6c8679e

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

src/data/mod.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,11 +513,14 @@ where
513513
temp.into()
514514
}
515515

516-
/// Reorder the array in specified order
516+
/// Reorder the array according to the new specified axes
517517
///
518-
/// The default order of axes in ArrayFire is axis with smallest distance
519-
/// between adjacent elements towards an axis with highest distance between
520-
/// adjacent elements.
518+
/// Exchanges data within an array such that the requested change in axes is
519+
/// satisfied. The linear ordering of data within the array is preserved.
520+
///
521+
/// The default order of axes in ArrayFire is [0 1 2 3] i.e. axis with smallest
522+
/// distance between adjacent elements followed by next smallest distance axis and
523+
/// so on. See [examples](#examples) to have a basic idea of how data is re-ordered.
521524
///
522525
///# Parameters
523526
///
@@ -537,7 +540,29 @@ where
537540
/// let a = randu::<f32>(Dim4::new(&[5, 3, 1, 1]));
538541
/// let b = reorder_v2(&a, 1, 0, None);
539542
/// print(&a);
543+
///
544+
/// // [5 3 1 1]
545+
/// // 0.8104 0.2990 0.3014
546+
/// // 0.6913 0.2802 0.6938
547+
/// // 0.7821 0.1480 0.3513
548+
/// // 0.3054 0.1330 0.7176
549+
/// // 0.1673 0.4696 0.1181
550+
///
540551
/// print(&b);
552+
/// // [3 5 1 1]
553+
/// // 0.8104 0.6913 0.7821 0.3054 0.1673
554+
/// // 0.2990 0.2802 0.1480 0.1330 0.4696
555+
/// // 0.3014 0.6938 0.3513 0.7176 0.1181
556+
///
557+
/// let c = reorder_v2(&a, 2, 0, Some(vec![1]));
558+
/// print(&c);
559+
///
560+
/// // [1 5 3 1]
561+
/// // 0.8104 0.6913 0.7821 0.3054 0.1673
562+
/// //
563+
/// // 0.2990 0.2802 0.1480 0.1330 0.4696
564+
/// //
565+
/// // 0.3014 0.6938 0.3513 0.7176 0.1181
541566
/// ```
542567
pub fn reorder_v2<T>(
543568
input: &Array<T>,

0 commit comments

Comments
 (0)