pub struct Perm { /* private fields */ }Expand description
A permutation of 0..n.
Stored as Either<usize, Vec<usize>>: Left(n) is the identity
permutation on 0..n, and Right(v) is an explicit image vector
where v[i] is the image of i.
Implementations§
Source§impl Perm
impl Perm
Sourcepub fn from_indices<I>(images: I) -> Selfwhere
I: IntoIterator<Item = usize>,
pub fn from_indices<I>(images: I) -> Selfwhere
I: IntoIterator<Item = usize>,
Create from an iterator of images. The i-th item is the image of i.
Panics if the resulting sequence is not a valid permutation.
pub fn len(&self) -> usize
Sourcepub fn apply_to<R>(&self, y: Vec<R>) -> Vec<R>
pub fn apply_to<R>(&self, y: Vec<R>) -> Vec<R>
Left group action consuming y: returns a vector result such that
result[self.at(i)] = y[i] for every i.
Sourcepub fn apply_inv_to<R>(&self, y: Vec<R>) -> Vec<R>
pub fn apply_inv_to<R>(&self, y: Vec<R>) -> Vec<R>
Inverse-left action consuming y: returns a vector result such that
result[k] = y[self.at(k)] for every k. Equivalent to
self.inv().apply_to(y) but without allocating an inverse permutation.
Sourcepub fn shift(self, r: usize) -> Self
pub fn shift(self, r: usize) -> Self
Returns a permutation of dimension self.len() + r that is the
identity on [0..r) and acts as self (shifted by r) on
[r..r + self.len()). Identity is preserved (zero-cost).
Sourcepub fn extend(self, r: usize) -> Self
pub fn extend(self, r: usize) -> Self
Returns a permutation of dimension self.len() + r that acts as
self on [0..self.len()) and the identity on the appended
[self.len()..self.len() + r). Identity is preserved (zero-cost).
Sourcepub fn forward_indices<I>(n: usize, prefix: I) -> Selfwhere
I: IntoIterator<Item = usize>,
pub fn forward_indices<I>(n: usize, prefix: I) -> Selfwhere
I: IntoIterator<Item = usize>,
Permutation p of 0..n that sends each index in prefix to a
position 0, 1, 2, ... (in the order given), with the remaining
indices filling positions in sorted order.
If prefix is empty, returns the identity (zero-cost).
Trait Implementations§
impl Eq for Perm
Source§impl MulAssign for Perm
Composition (p * q)(i) = p(q(i)) (right-to-left, math convention).
impl MulAssign for Perm
Composition (p * q)(i) = p(q(i)) (right-to-left, math convention).
Source§fn mul_assign(&mut self, rhs: Perm)
fn mul_assign(&mut self, rhs: Perm)
*= operation. Read moreSource§impl MulAssign<&Perm> for Perm
Composition (p * q)(i) = p(q(i)) (right-to-left, math convention).
impl MulAssign<&Perm> for Perm
Composition (p * q)(i) = p(q(i)) (right-to-left, math convention).
Source§fn mul_assign(&mut self, rhs: &Perm)
fn mul_assign(&mut self, rhs: &Perm)
*= operation. Read moreimpl StructuralPartialEq for Perm
Auto Trait Implementations§
impl Freeze for Perm
impl RefUnwindSafe for Perm
impl Send for Perm
impl Sync for Perm
impl Unpin for Perm
impl UnsafeUnpin for Perm
impl UnwindSafe for Perm
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, Right> ClosedMul<Right> for T
impl<T, Right> ClosedMulAssign<Right> for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.