Trait for 1d to nd index conversion
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
Hướng nghiên cứu
Start with the generic shuffle example and inspect the Array, Array1, and Dimension indexing, flattening, and reshaping APIs mentioned in the issue. A complete contribution would establish whether a single usize can be converted safely for arbitrary dimensions and document or test the resulting behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Given an array of arbitrary dimension, is it possible to index into it using a single usize?
fn shuffle1<E>(values: &mut Array1<E>) {
let mut i = values.len();
while i >= 2 {
// invariant: elements with index >= i have been locked in place.
i -= 1;
// lock element i in place.
values.swap(i, thread_rng().gen_range(0, i + 1));
}
}
fn shuffle<E, D: Dimension>(values: &mut Array<E, D>) {
let mut i = values.len();
while i >= 2 {
i -= 1;
values.swap(i, thread_rng().gen_range(0, i + 1));
// This won't work as a single usize is not necessarily a valid index,
// the usize must be converted to a index of dimension D
}
}
One possible solution is probably to flatten the array, then shuffle it, then reshape it back, although I do think a method for indexing into the array with a single integer could be useful in general.
- Ngôn ngữ chính
- Rust
- Star
- 4.3k
- Fork
- 391
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rust-ndarray/ndarray
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
rust-ndarray/ndarray#1612 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
rust-ndarray/ndarray#1617 · 1 bình luận ·
-
Stack overflow in `triu` Đang mởbug good first issue
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
rust-ndarray/ndarray#1615 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
rust-ndarray/ndarray#1610 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
rust-ndarray/ndarray#1609 ·