fn compute_symmetry_info(&self) -> (Indexed<StarI, Vec<StarData>>, Indexed<PrimI, Vec<PrimData>>) {

        // Gather displacements for each star of sites.
        //
        // The non-equivalent atoms were discovered by phonopy and taken into account
        // in its generated displacements (always using the same atom from each star).
        // All we have to do is gather displacements with the same index.
        //
        // (NOTE: At this point it is assumed that the input displacements only
        //  ever displace one representative atom from each star, so that every
        //  unique index in `displacements` corresponds to a star.
        //  If this turns out not to be true, it will be caught later.)
        let star_data: Indexed<StarI, Vec<StarData>>;
        star_data = {
            // Use BTreeMap for consistent ordering, because the result of this block
            // is what defines the meaning of `StarI`.
            let mut map = BTreeMap::<PrimI, _>::new();
            for (disp_i, &(prim_i, _)) in self.displacements.iter_enumerated() {
                map.entry(prim_i)
                    .or_insert_with(Vec::new)
                    .push(disp_i)
            }
            map.into_iter()
                .map(|(representative, displacements)| StarData { representative, displacements })
                .collect()
        };

        // Gather data relating each primitive atom to its site-symmetry representative.
        let prim_data: Indexed<PrimI, Vec<PrimData>> = {
            let mut data = Indexed::<PrimI, _>::from_elem_n(None, self.sc.raw.num_primitive_atoms());
            for (star, star_data) in star_data.iter_enumerated() {
                let representative_atom = self.sc.atom_from_lattice_point(star_data.representative, self.sc.designated_lattice_point);
                for oper in self.oper_indices() {
                    let permuted_atom = self.rotate_atom(oper, representative_atom);
                    let prim = self.primitive_atoms[permuted_atom];

                    if data[prim].is_none() {
                        data[prim] = Some(PrimData { star, opers_from_rep: vec![] });
                    }

                    let existing = data[prim].as_mut().expect("BUG!");
                    assert_eq!(
                        star, existing.star,
                        "displacements contained multiple atoms in same symmetry star!",
                    );
                    existing.opers_from_rep.push(oper)
                }
            }
            data.into_iter_enumerated().map(|(prim, d)| d.unwrap_or_else(|| {
                panic!(
                    "\
                        None of the displaced sites are equivalent under symmetry \
                        to primitive site {}!!\
                    ", prim,
                );
            })).collect()
        };
        (star_data, prim_data)
    }
// FIXME: It'd be nice if this used the new `Stars` type, but then the trouble is that
//        the indices used in the displacements might not be the same indices chosen as
//        representatives by `Stars`.
It'd be nice if this used the new `Stars` type, but then the trouble is that
the indices used in the displacements might not be the same indices chosen as
representatives by `Stars`.
It ' d be nice if this used the new ` Stars ` type but then the trouble is that the indices used in the displacements might not be the same indices chosen as representatives by ` Stars ` .
fn compute_symmetry_info(&self) -> (Indexed<StarI, Vec<StarData>>, Indexed<PrimI, Vec<PrimData>>) {
        // Gather displacements for each star of sites.
        //
        // The non-equivalent atoms were discovered by phonopy and taken into account
        // in its generated displacements (always using the same atom from each star).
        // All we have to do is gather displacements with the same index.
        //
        // (NOTE: At this point it is assumed that the input displacements only
        //  ever displace one representative atom from each star, so that every
        //  unique index in `displacements` corresponds to a star.
        //  If this turns out not to be true, it will be caught later.)
        let star_data: Indexed<StarI, Vec<StarData>>;
        star_data = {
            // Use BTreeMap for consistent ordering, because the result of this block
            // is what defines the meaning of `StarI`.
            let mut map = BTreeMap::<PrimI, _>::new();
            for (disp_i, &(prim_i, _)) in self.displacements.iter_enumerated() {
                map.entry(prim_i)
                    .or_insert_with(Vec::new)
                    .push(disp_i)
            }
            map.into_iter()
                .map(|(representative, displacements)| StarData { representative, displacements })
                .collect()
        };
        // Gather data relating each primitive atom to its site-symmetry representative.
        let prim_data: Indexed<PrimI, Vec<PrimData>> = {
            let mut data = Indexed::<PrimI, _>::from_elem_n(None, self.sc.raw.num_primitive_atoms());
            for (star, star_data) in star_data.iter_enumerated() {
                let representative_atom = self.sc.atom_from_lattice_point(star_data.representative, self.sc.designated_lattice_point);
                for oper in self.oper_indices() {
                    let permuted_atom = self.rotate_atom(oper, representative_atom);
                    let prim = self.primitive_atoms[permuted_atom];
                    if data[prim].is_none() {
                        data[prim] = Some(PrimData { star, opers_from_rep: vec![] });
                    }
                    let existing = data[prim].as_mut().expect("BUG!");
                    assert_eq!(
                        star, existing.star,
                        "displacements contained multiple atoms in same symmetry star!",
                    );
                    existing.opers_from_rep.push(oper)
                }
            }
            data.into_iter_enumerated().map(|(prim, d)| d.unwrap_or_else(|| {
                panic!(
                    "\
                        None of the displaced sites are equivalent under symmetry \
                        to primitive site {}!!\
                    ", prim,
                );
            })).collect()
        };
        (star_data, prim_data)
    }
fn compute_symmetry_info ( & self ) -> ( Indexed < StarI , Vec < StarData > > , Indexed < PrimI , Vec < PrimData > > ) { // Gather displacements for each star of sites. // // The non-equivalent atoms were discovered by phonopy and taken into account // in its generated displacements (always using the same atom from each star). // All we have to do is gather displacements with the same index. // // (NOTE: At this point it is assumed that the input displacements only //  ever displace one representative atom from each star, so that every //  unique index in `displacements` corresponds to a star. //  If this turns out not to be true, it will be caught later.) let star_data : Indexed < StarI , Vec < StarData > > ; star_data = { // Use BTreeMap for consistent ordering, because the result of this block // is what defines the meaning of `StarI`. let mut map = BTreeMap :: < PrimI , _ > :: new ( ) ; for ( disp_i , & ( prim_i , _ ) ) in self . displacements . iter_enumerated ( ) { map . entry ( prim_i ) . or_insert_with ( Vec :: new ) . push ( disp_i ) } map . into_iter ( ) . map ( | ( representative , displacements ) | StarData { representative , displacements } ) . collect ( ) } ; // Gather data relating each primitive atom to its site-symmetry representative. let prim_data : Indexed < PrimI , Vec < PrimData > > = { let mut data = Indexed :: < PrimI , _ > :: from_elem_n ( None , self . sc . raw . num_primitive_atoms ( ) ) ; for ( star , star_data ) in star_data . iter_enumerated ( ) { let representative_atom = self . sc . atom_from_lattice_point ( star_data . representative , self . sc . designated_lattice_point ) ; for oper in self . oper_indices ( ) { let permuted_atom = self . rotate_atom ( oper , representative_atom ) ; let prim = self . primitive_atoms [ permuted_atom ] ; if data [ prim ] . is_none ( ) { data [ prim ] = Some ( PrimData { star , opers_from_rep : vec ! [ ] } ) ; } let existing = data [ prim ] . as_mut ( ) . expect ( " " ) ; assert_eq ! ( star existing star " " ) ; existing . opers_from_rep . push ( oper ) } } data . into_iter_enumerated ( ) . map ( | ( prim , d ) | d . unwrap_or_else ( | | { panic ! ( " \
 \
 \
 " prim ) ; } ) ) . collect ( ) } ; ( star_data , prim_data ) }
FIXME: It'd be nice if this used the new `Stars` type, but then the trouble is that
the indices used in the displacements might not be the same indices chosen as
representatives by `Stars`.
FIXME : It ' d be nice if this used the new ` Stars ` type but then the trouble is that the indices used in the displacements might not be the same indices chosen as representatives by ` Stars ` .
&self
&self