/// In-place transpose of a square matrix by keeping F/C layout
///
/// Transpose for C-continuous array
///
/// ```rust
/// # use lax::layout::*;
/// let layout = MatrixLayout::C { row: 2, lda: 2 };
/// let mut a = vec![1., 2., 3., 4.];
/// square_transpose(layout, &mut a);
/// assert_eq!(a, &[1., 3., 2., 4.]);
/// ```
///
/// Transpose for F-continuous array
///
/// ```rust
/// # use lax::layout::*;
/// let layout = MatrixLayout::F { col: 2, lda: 2 };
/// let mut a = vec![1., 3., 2., 4.];
/// square_transpose(layout, &mut a);
/// assert_eq!(a, &[1., 2., 3., 4.]);
/// ```
///
/// Panics
/// ------
/// - If size of `a` and `layout` size mismatch
///
In-place transpose of a square matrix by keeping F/C layout
Transpose for C-continuous array


In - place transpose of a square matrix by keeping F / C layout Transpose for C - continuous array
pub fn square_transpose<T: Scalar>(layout: MatrixLayout, a: &mut [T]) {
    let (m, n) = layout.size();
    let n = n as usize;
    let m = m as usize;
    assert_eq!(a.len(), n * m);
    for i in 0..m {
        for j in (i + 1)..n {
            let a_ij = a[i * n + j];
            let a_ji = a[j * m + i];
            a[i * n + j] = a_ji.conj();
            a[j * m + i] = a_ij.conj();
        }
    }
}
pub fn square_transpose < T : Scalar > ( layout : MatrixLayout , a : & mut [ T ] ) { let ( m , n ) = layout . size ( ) ; let n = n as usize ; let m = m as usize ; assert_eq ! ( a len ( ) n m ) ; for i in 0 .. m { for j in ( i + 1 ) .. n { let a_ij = a [ i * n + j ] ; let a_ji = a [ j * m + i ] ; a [ i * n + j ] = a_ji . conj ( ) ; a [ j * m + i ] = a_ij . conj ( ) ; } } }
In-place transpose of a square matrix by keeping F/C layout
Transpose for C-continuous array
In - place transpose of a square matrix by keeping F / C layout Transpose for C - continuous array
layout
MatrixLayout
a
&mut [T]
use lax::layout::*;


Transpose for F-continuous array


Transpose for F - continuous array
use lax::layout::*;


Panics

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