pub fn from_all_members(
        members: Vec<G>,
        mut compose: impl FnMut(&G, &G) -> G,
    ) -> Self
    where G: Hash + Eq + Clone,
    {
        // we cannot construct the identity without any generators
        assert!(members.len() > 0, "empty groups do not exist!");

        let indices: std::collections::HashMap<G, usize> =
            members.iter().cloned()
            .enumerate().map(|(i, x)| (x, i))
            .collect();

        // Brute force O(G)^2 attempt to fill the tree.
        // I'm fairly certain this can be improved in some way by using
        // known element-inverse pairs to quickly find new members,
        // but I don't think it's worth it since this will probably only ever
        // be used on spacegroups, which are not terribly large.
        let mut decomps = vec![None; members.len()];
        for a in 0..members.len() {
            for b in 0..=a {
                let c = indices[&compose(&members[a], &members[b])];
                if c > a {
                    decomps[c] = Some((a, b));
                }
            }
        }
        GroupTree { members, decomps }
    }
/// Constructs a `GroupTree<G>` given a sequence that contains
/// each member of a finite group exactly once.
///
/// A `GroupTree<G>` constructed in this manner is guaranteed to
/// order its elements in the same order as the input `Vec`.
///
/// In line with the library's predominantly row-centric design,
/// arguments of the closure are flipped from the typical mathematical
/// convention. `compose(a, b)` should perform *`a` followed by `b`*,
/// (i.e. "`b` of `a`").
Constructs a `GroupTree` given a sequence that contains
each member of a finite group exactly once.

A `GroupTree` constructed in this manner is guaranteed to
order its elements in the same order as the input `Vec`.

In line with the library's predominantly row-centric design,
arguments of the closure are flipped from the typical mathematical
convention.
Constructs a ` GroupTree ` given a sequence that contains each member of a finite group exactly once . A ` GroupTree ` constructed in this manner is guaranteed to order its elements in the same order as the input ` Vec ` . In line with the library ' s predominantly row - centric design arguments of the closure are flipped from the typical mathematical convention .
pub fn from_all_members(
        members: Vec<G>,
        mut compose: impl FnMut(&G, &G) -> G,
    ) -> Self
    where G: Hash + Eq + Clone,
    {
        // we cannot construct the identity without any generators
        assert!(members.len() > 0, "empty groups do not exist!");
        let indices: std::collections::HashMap<G, usize> =
            members.iter().cloned()
            .enumerate().map(|(i, x)| (x, i))
            .collect();
        // Brute force O(G)^2 attempt to fill the tree.
        // I'm fairly certain this can be improved in some way by using
        // known element-inverse pairs to quickly find new members,
        // but I don't think it's worth it since this will probably only ever
        // be used on spacegroups, which are not terribly large.
        let mut decomps = vec![None; members.len()];
        for a in 0..members.len() {
            for b in 0..=a {
                let c = indices[&compose(&members[a], &members[b])];
                if c > a {
                    decomps[c] = Some((a, b));
                }
            }
        }
        GroupTree { members, decomps }
    }
pub fn from_all_members ( members : Vec < G > , mut compose : impl FnMut ( & G , & G ) -> G , ) -> Self where G : Hash + Eq + Clone , { // we cannot construct the identity without any generators assert ! ( members len ( ) 0 " " ) ; let indices : std :: collections :: HashMap < G , usize > = members . iter ( ) . cloned ( ) . enumerate ( ) . map ( | ( i , x ) | ( x , i ) ) . collect ( ) ; // Brute force O(G)^2 attempt to fill the tree. // I'm fairly certain this can be improved in some way by using // known element-inverse pairs to quickly find new members, // but I don't think it's worth it since this will probably only ever // be used on spacegroups, which are not terribly large. let mut decomps = vec ! [ None members len ( ) ] ; for a in 0 .. members . len ( ) { for b in 0 ..= a { let c = indices [ & compose ( & members [ a ] , & members [ b ] ) ] ; if c > a { decomps [ c ] = Some ( ( a , b ) ) ; } } } GroupTree { members , decomps } }
Constructs a `GroupTree<G>` given a sequence that contains
each member of a finite group exactly once.
Constructs a ` GroupTree<G > ` given a sequence that contains each member of a finite group exactly once .
members
Vec<G>
compose
impl FnMut(&G, &G) -> G
members
Vec<G>
compose
impl FnMut(&G, &G) -> G