pub fn transpose<T: Scalar>(layout: MatrixLayout, from: &[T], to: &mut [T]) -> MatrixLayout {
    let (m, n) = layout.size();
    let transposed = layout.resized(n, m).t();
    let m = m as usize;
    let n = n as usize;
    assert_eq!(from.len(), m * n);
    assert_eq!(to.len(), m * n);

    match layout {
        MatrixLayout::C { .. } => {
            for i in 0..m {
                for j in 0..n {
                    to[j * m + i] = from[i * n + j];
                }
            }
        }
        MatrixLayout::F { .. } => {
            for i in 0..m {
                for j in 0..n {
                    to[i * n + j] = from[j * m + i];
                }
            }
        }
    }
    transposed
}
/// Out-place transpose for general matrix
///
/// Inplace transpose of non-square matrices is hard.
/// See also: https://en.wikipedia.org/wiki/In-place_matrix_transposition
///
/// ```rust
/// # use lax::layout::*;
/// let layout = MatrixLayout::C { row: 2, lda: 3 };
/// let a = vec![1., 2., 3., 4., 5., 6.];
/// let mut b = vec![0.0; a.len()];
/// let l = transpose(layout, &a, &mut b);
/// assert_eq!(l, MatrixLayout::F { col: 3, lda: 2 });
/// assert_eq!(b, &[1., 4., 2., 5., 3., 6.]);
/// ```
///
/// ```rust
/// # use lax::layout::*;
/// let layout = MatrixLayout::F { col: 2, lda: 3 };
/// let a = vec![1., 2., 3., 4., 5., 6.];
/// let mut b = vec![0.0; a.len()];
/// let l = transpose(layout, &a, &mut b);
/// assert_eq!(l, MatrixLayout::C { row: 3, lda: 2 });
/// assert_eq!(b, &[1., 4., 2., 5., 3., 6.]);
/// ```
///
/// Panics
/// ------
/// - If size of `a` and `layout` size mismatch
///
Out-place transpose for general matrix
Inplace transpose of non-square matrices is hard.


Out - place transpose for general matrix Inplace transpose of non - square matrices is hard .
pub fn transpose<T: Scalar>(layout: MatrixLayout, from: &[T], to: &mut [T]) -> MatrixLayout {
    let (m, n) = layout.size();
    let transposed = layout.resized(n, m).t();
    let m = m as usize;
    let n = n as usize;
    assert_eq!(from.len(), m * n);
    assert_eq!(to.len(), m * n);
    match layout {
        MatrixLayout::C { .. } => {
            for i in 0..m {
                for j in 0..n {
                    to[j * m + i] = from[i * n + j];
                }
            }
        }
        MatrixLayout::F { .. } => {
            for i in 0..m {
                for j in 0..n {
                    to[i * n + j] = from[j * m + i];
                }
            }
        }
    }
    transposed
}
pub fn transpose < T : Scalar > ( layout : MatrixLayout , from : & [ T ] , to : & mut [ T ] ) -> MatrixLayout { let ( m , n ) = layout . size ( ) ; let transposed = layout . resized ( n , m ) . t ( ) ; let m = m as usize ; let n = n as usize ; assert_eq ! ( from len ( ) m n ) ; assert_eq ! ( to len ( ) m n ) ; match layout { MatrixLayout :: C { .. } => { for i in 0 .. m { for j in 0 .. n { to [ j * m + i ] = from [ i * n + j ] ; } } } MatrixLayout :: F { .. } => { for i in 0 .. m { for j in 0 .. n { to [ i * n + j ] = from [ j * m + i ] ; } } } } transposed }
Out-place transpose for general matrix
Inplace transpose of non-square matrices is hard.
Out - place transpose for general matrix Inplace transpose of non - square matrices is hard .
layout
MatrixLayout
from
&[T]
to
&mut [T]
layout
MatrixLayout
from
&[T]
to
&mut [T]
use lax::layout::*;
None
use lax::layout::*;


Panics

If size of `a` and `layout` size mismatch
Panics If size of ` a ` and ` layout ` size mismatch