#2d-array #array #transpose #2d

no-std mattr

Utility for transposing multi-dimensional data

1 unstable release

0.0.2 Oct 2, 2023
0.0.1 Oct 2, 2023
0.0.0 Oct 2, 2023

#2454 in Algorithms

Download history 7/week @ 2024-07-22 59/week @ 2024-07-29 19/week @ 2024-08-05 12/week @ 2024-08-12 4/week @ 2024-08-19 19/week @ 2024-08-26 12/week @ 2024-09-02 23/week @ 2024-09-09 22/week @ 2024-09-16 52/week @ 2024-09-23 14/week @ 2024-09-30 7/week @ 2024-10-07 22/week @ 2024-10-14 14/week @ 2024-10-21 13/week @ 2024-10-28 24/week @ 2024-11-04

73 downloads per month
Used in 5 crates (via fimg)

MIT/Apache

18KB
284 lines

transpose

crate license documentation minimum rustc 1.26

Utility for transposing multi-dimensional data See the API Documentation for more details.

transpose is #![no_std]

Example

// Create a 2D array in row-major order: the rows of our 2D array are contiguous,
// and the columns are strided
let input_array = vec![ 1, 2, 3,
                        4, 5, 6];

// Treat our 6-element array as a 2D 3x2 array, and transpose it to a 2x3 array
let mut output_array = vec![0; 6];
transpose::transpose(&input_array, &mut output_array, 3, 2);

// The rows have become the columns, and the columns have become the rows
let expected_array =  vec![ 1, 4,
                            2, 5,
                            3, 6];
assert_eq!(output_array, expected_array);

Compatibility

The transpose crate requires rustc 1.26 or greater.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

No runtime deps