[][src]Struct q1tsim::permutation::Permutation

pub struct Permutation { /* fields omitted */ }

Struct for permutations

Struct Permutation is used to represents permutations. It can be used to shuffle the elements in a vector, or rows and columns in a matrix.

Methods

impl Permutation[src]

pub fn new(idxs: Vec<usize>) -> Result<Self>[src]

Create a new permutation.

Create a new permutation from idxs. If n is the length of idxs, the array should contain all elements in the range [0, n-1] (inclusive). When idxs[i] = j, application of the permutation on a vector means that the the jth element of the original vector is taken to position i in the permuted vector.

pub fn indices(&self) -> &[usize][src]

Return the permutation index vector

pub fn size(&self) -> usize[src]

Return the size of the permutation

pub fn inverse(&self) -> Self[src]

The inverse permutation

Compute the inverse of this permutation. If this permutation maps element i to j, then then in the inverse j is mapped to i.

pub fn matrix<T>(&self) -> Array2<T> where
    T: Clone + Zero + One
[src]

Matrix representation.

Return a matrix representation of the permutation. For a matrix representation P of permutation perm, the result of P.dot(v) for a vector v is the same as perm.apply_vec(&mut v).

pub fn apply_vec_in_place<T>(&self, v: &mut Array1<T>)[src]

Permute a vector

Apply this permutation to vector v.

pub fn apply_vec_into<T>(&self, v: ArrayView1<T>, perm_v: ArrayViewMut1<T>) where
    T: Copy
[src]

Permute a vector

Apply this permutation to vector v, and store the result in perm_v.

pub fn apply_inverse_vec_into<T>(
    &self,
    v: ArrayView1<T>,
    inv_perm_v: ArrayViewMut1<T>
) where
    T: Copy
[src]

Permute a vector

Apply the inverse of this permutation to vector v, and store the result in inv_perm_v.

pub fn transform<T>(&self, a: &Array2<T>) -> Array2<T> where
    T: Copy
[src]

Transform a matrix

Transform matrix a, permuting both its rows and columns by this permutation.

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,