Trait perm_vec::Permute [−][src]
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 Perm
s are the morphisms of a category. (brushing
aside issues of mismatched length)