Permute

Trait Permute 

Source
pub trait Permute: Sized {
    // Required method
    fn permuted_by(self, perm: &Perm) -> Self;
}
Expand description

Trait for applying a permutation operation.

Impls of Permute do not always necessarily apply the permutation directly to vectors contained in the type. For instance, data in a sparse format will likely use the permutation to transform stored indices.

As a conceptual tool, it can help to consider indices as having distinct types (e.g. vertex indices, component indices; or more specific things like “indices of rows when sorted by column 2”); in this model, Perm can be thought of as being parametrized over two index types, where Perm<Src, Dest> transforms data indexed by type Src into data indexed by type Dest. Again, this is just a conceptual tool; Perm does not actually have these type parameters! (More about this in this blog post)

§Laws

All implementations of Permute must satisfy the following properties, which give Permute::permuted_by the qualities of a group action. (whose group operator is, incidentally, also Permute::permuted_by!)

  • Identity:
    data.permuted_by(Perm::eye(data.len())) == data
  • Compatibility:
    data.permuted_by(a).permuted_by(b) == data.permuted_by(a.permuted_by(b))

When envisioning Perm as generic over Src and Dest types, it could perhaps be said that Perms are the morphisms of a category. (brushing aside issues of mismatched length)

Required Methods§

Source

fn permuted_by(self, perm: &Perm) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> Permute for Vec<T>

Source§

fn permuted_by(self, perm: &Perm) -> Vec<T>

Source§

impl<T: Clone> Permute for Rc<[T]>

Source§

fn permuted_by(self, perm: &Perm) -> Self

Source§

impl<T: Permute + Clone> Permute for Rc<T>

Source§

fn permuted_by(self, perm: &Perm) -> Self

Implementors§