| 1 |
# transpose |
| 2 |
|
| 3 |
[](https://crates.io/crates/transpose) |
| 4 |
[](https://crates.io/crates/transpose) |
| 5 |
[](https://docs.rs/transpose/) |
| 6 |
 |
| 7 |
|
| 8 |
Utility for transposing multi-dimensional data See the [API Documentation](https://docs.rs/transpose/) for more details. |
| 9 |
|
| 10 |
`transpose` is `#![no_std]` |
| 11 |
|
| 12 |
## Example |
| 13 |
```rust |
| 14 |
// Create a 2D array in row-major order: the rows of our 2D array are contiguous, |
| 15 |
// and the columns are strided |
| 16 |
let input_array = vec![ 1, 2, 3, |
| 17 |
4, 5, 6]; |
| 18 |
|
| 19 |
// Treat our 6-element array as a 2D 3x2 array, and transpose it to a 2x3 array |
| 20 |
let mut output_array = vec![0; 6]; |
| 21 |
transpose::transpose(&input_array, &mut output_array, 3, 2); |
| 22 |
|
| 23 |
// The rows have become the columns, and the columns have become the rows |
| 24 |
let expected_array = vec![ 1, 4, |
| 25 |
2, 5, |
| 26 |
3, 6]; |
| 27 |
assert_eq!(output_array, expected_array); |
| 28 |
``` |
| 29 |
|
| 30 |
## Compatibility |
| 31 |
|
| 32 |
The `transpose` crate requires rustc 1.26 or greater. |
| 33 |
|
| 34 |
## License |
| 35 |
|
| 36 |
Licensed under either of |
| 37 |
|
| 38 |
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) |
| 39 |
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) |
| 40 |
|
| 41 |
at your option. |
| 42 |
|
| 43 |
### Contribution |
| 44 |
|
| 45 |
Unless you explicitly state otherwise, any contribution intentionally |
| 46 |
submitted for inclusion in the work by you, as defined in the Apache-2.0 |
| 47 |
license, shall be dual licensed as above, without any additional terms or |
| 48 |
conditions. |