Function lax::layout::transpose

source ·
pub fn transpose<T: Copy>(
    layout: MatrixLayout,
    input: &[T],
) -> (MatrixLayout, Vec<T>)
Expand description

Out-place transpose for general matrix

§Examples

let layout = MatrixLayout::C { row: 2, lda: 3 };
let a = vec![1., 2., 3., 4., 5., 6.];
let (l, b) = transpose(layout, &a);
assert_eq!(l, MatrixLayout::F { col: 3, lda: 2 });
assert_eq!(b, &[1., 4., 2., 5., 3., 6.]);
let layout = MatrixLayout::F { col: 2, lda: 3 };
let a = vec![1., 2., 3., 4., 5., 6.];
let (l, b) = transpose(layout, &a);
assert_eq!(l, MatrixLayout::C { row: 3, lda: 2 });
assert_eq!(b, &[1., 4., 2., 5., 3., 6.]);

§Panics

  • If input array size and layout size mismatch