[−][src]Struct q1tsim::permutation::Permutation
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 j
th 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]
T: Clone + Zero + One,
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]
T: Copy,
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]
&self,
v: ArrayView1<T>,
inv_perm_v: ArrayViewMut1<T>
) where
T: Copy,
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]
T: Copy,
Transform a matrix
Transform matrix a
, permuting both its rows and columns by this
permutation.
Auto Trait Implementations
impl Send for Permutation
impl Unpin for Permutation
impl Sync for Permutation
impl UnwindSafe for Permutation
impl RefUnwindSafe for Permutation
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,