pub struct Permutation {
pub perm: Vec<usize>,
pub iperm: Vec<usize>,
}Expand description
A permutation with its inverse, for reordering matrix rows/columns.
Fields§
§perm: Vec<usize>Forward permutation: new[i] = old[perm[i]].
iperm: Vec<usize>Inverse permutation: old[i] = new[iperm[i]].
Implementations§
Source§impl Permutation
impl Permutation
Sourcepub fn new(perm: Vec<usize>) -> SolverResult<Self>
pub fn new(perm: Vec<usize>) -> SolverResult<Self>
Create a permutation from a forward mapping. Returns an error if any index is out of range or duplicated.
Sourcepub fn apply<T: Copy>(&self, data: &[T]) -> Vec<T>
pub fn apply<T: Copy>(&self, data: &[T]) -> Vec<T>
Apply permutation to a slice: result[i] = data[perm[i]].
Sourcepub fn compose(&self, other: &Permutation) -> SolverResult<Permutation>
pub fn compose(&self, other: &Permutation) -> SolverResult<Permutation>
Compose two permutations: result[i] = self.perm[other.perm[i]].
Trait Implementations§
Source§impl Clone for Permutation
impl Clone for Permutation
Source§fn clone(&self) -> Permutation
fn clone(&self) -> Permutation
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for Permutation
impl RefUnwindSafe for Permutation
impl Send for Permutation
impl Sync for Permutation
impl Unpin for Permutation
impl UnsafeUnpin for Permutation
impl UnwindSafe for Permutation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more