Skip to content

Commit 52fb085

Browse files
committed
Update docs.
1 parent b721712 commit 52fb085

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ non-contiguous (sub)views into *n*-dimensional arrays. Reimplements algorithms i
2424
## Example
2525

2626
```rust
27-
use ndarray_slice::{Slice1Ext, ndarray::arr2};
27+
use ndarray_slice::{ndarray::arr2, Slice1Ext};
2828

2929
// 2-dimensional array of 4 rows and 5 columns.
3030
let mut v = arr2(&[[-5, 4, 1, -3, 2], // row 0, axis 0
@@ -43,7 +43,7 @@ let mut column = v.column_mut(4);
4343
assert_eq!(column.as_slice_mut(), None);
4444

4545
// Instead, sorting is specifically implemented for non-contiguous mutable (sub)views.
46-
column.sort();
46+
column.sort_unstable();
4747

4848
assert!(v == arr2(&[[-5, 4, 1, -3, -1],
4949
[ 8, 3, 2, 4, 2],
@@ -55,13 +55,17 @@ assert!(v == arr2(&[[-5, 4, 1, -3, -1],
5555

5656
## Current Implementation
5757

58-
Complexities where *n* is the length of the (sub)view.
58+
Complexities where *n* is the length of the (sub)view and *m* the count of indices to select.
59+
60+
| Resource | Complexity | Sorting (stable) | Sorting (unstable) | Selection (unstable) | Bulk Selection (unstable) |
61+
|----------|------------|------------------|---------------------|--------------------------|---------------------------|
62+
| Time | Best | *O*(*n*) | *O*(*n*) | *O*(*n*) | *O*(*n* log *m*) |
63+
| Time | Expected | *O*(*n* log *n*) | *O*(*n* log *n*) | *O*(*n*) | *O*(*n* log *m*) |
64+
| Time | Worst | *O*(*n* log *n*) | *O*(*n* log *n*) | *O*(*n* log *n*) | *O*(*n* log *n* log *m*) |
65+
| Space | Best | *O*(1) | *O*(1) | *O*(1) | *O*(*m*) |
66+
| Space | Expected | *O*(*n*/2) | *O*(log *n*) | *O*(log *n*) | *O*(*m*+log *n*) |
67+
| Spoce | Worst | *O*(*n*/2) | *O*(log *n*) | *O*(log *n*) | *O*(*m*+log *n*) |
5968

60-
| Algorithm | Stable | Allocation | Recursive | Average | Worse-Case |
61-
|-----------|------- |------------|-----------|----------|-------------------|
62-
| Sorting | yes | yes | no | *O*(*n*) | *O*(*n* log(*n*)) |
63-
| Sorting | no | no | yes | *O*(*n*) | *O*(*n* log(*n*)) |
64-
| Selection | no | no | no | *O*(*n*) | *O*(*n* log(*n*)) |
6569

6670
[sorting]: https://en.wikipedia.org/wiki/Sorting_algorithm
6771
[selection]: https://en.wikipedia.org/wiki/Selection_algorithm
@@ -73,7 +77,7 @@ Complexities where *n* is the length of the (sub)view.
7377

7478
## Roadmap
7579

76-
* Lower worst-case complexity from *O*(*n* log(*n*)) to *O*(*n*) for selection algorithms.
80+
* Lower worst-case time complexity from *O*(*n* log *n*) to *O*(*n*) for selection algorithms.
7781
* Add `SliceExt` trait for *n*-dimensional array or (sub)view with methods expecting `Axis` as
7882
their first argument. Comparing methods will always be suffixed with `_by` or `_by_key`
7983
defining how to compare multi-dimensional elements (e.g., columns) along the provided axis

0 commit comments

Comments
 (0)