fn visit_with_transpose(
        &mut self,
        sc: SupercellWrapper<'_>,
        mut visit: impl FnMut(&M33, &M33) -> (M33, M33),
    ) {
        let mut done: Indexed<PrimI, Vec<BTreeSet<SuperI>>>;
        done = Indexed::from_elem_n(BTreeSet::new(), sc.raw.num_primitive_atoms());

        let primitive_atoms = sc.atom_primitive_atoms();
        let lattice_points = sc.atom_lattice_points();

        // Phonopy iterates by column first.  However, due to the symmetry of `visit`,
        // this has no impact on the output. (it only affects whether some matrices are given as
        // the first argument or as the second argument to the function)
        let mut bee = self.0.to_coo().into_bee();
        for prim_r in sc.primitive_indices() {
            let super_r = sc.designated_super(prim_r);
            for super_c in sc.super_indices() {
                if !done[prim_r].contains(&super_c) {
                    // Find the indices of the transposed element.
                    let (prim_r_t, super_c_t) = get_effective_indices(
                        sc, &primitive_atoms, &lattice_points,
                        (super_c, super_r),
                    );
                    assert!(!done[prim_r_t].contains(&super_c_t));

                    // NOTE: These get_muts are what cause this function to make the matrix dense,
                    //       since they are done to all indices.
                    let m = *bee.get_mut(prim_r, super_c);
                    let t = bee.get_mut(prim_r_t, super_c_t).t();
                    let (new_m, new_t) = visit(&m, &t);
                    *bee.get_mut(prim_r, super_c) = new_m;
                    *bee.get_mut(prim_r_t, super_c_t) = new_t.t();

                    done[prim_r].insert(super_c);
                    done[prim_r_t].insert(super_c_t);
                }
            }
        }
        self.0 = bee.into_csr();
    }
// this corresponds to set_index_permutation_symmetry_compact_fc in _phonopy.c
//
/// Finds each pair `(m, t)` of matrices that are supposed to be transposes of each other,
/// and calls a function to obtain new values for them.
///
/// The input function must have the following properties:
///
/// * If the inputs are reversed, the outputs are reversed.
///   (`visit(t, m) == flip(visit(m, t))`, where `flip((x, y)) = (y, x)`)
/// * If both inputs are transposed, the outputs are transposed.
/// * It is linear.  This implies `visit(zero, zero) == (zero, zero)`.
/// * `visit(m, m.t())` must return matrices that are transposes of each other.
///
/// **Warning:** The current implementation causes the ForceConstants matrix to effectively
/// become dense! (this can be avoided for this specific function, but I haven't bothered
/// fixing it because there are other functions where it can't be avoided...)
this corresponds to set_index_permutation_symmetry_compact_fc in _phonopy.c
Finds each pair `(m, t)` of matrices that are supposed to be transposes of each other,
and calls a function to obtain new values for them.

The input function must have the following properties.

If the inputs are reversed, the outputs are reversed.

The current implementation causes the ForceConstants matrix to effectively
become dense. (this can be avoided for this specific function, but I haven't bothered
fixing it because there are other functions where it can't be avoided...)
this corresponds to set_index_permutation_symmetry_compact_fc in _phonopy . c Finds each pair ` ( m t ) ` of matrices that are supposed to be transposes of each other and calls a function to obtain new values for them . The input function must have the following properties . If the inputs are reversed the outputs are reversed . The current implementation causes the ForceConstants matrix to effectively become dense . ( this can be avoided for this specific function but I haven ' t bothered fixing it because there are other functions where it can ' t be avoided ... )
fn visit_with_transpose(
        &mut self,
        sc: SupercellWrapper<'_>,
        mut visit: impl FnMut(&M33, &M33) -> (M33, M33),
    ) {
        let mut done: Indexed<PrimI, Vec<BTreeSet<SuperI>>>;
        done = Indexed::from_elem_n(BTreeSet::new(), sc.raw.num_primitive_atoms());
        let primitive_atoms = sc.atom_primitive_atoms();
        let lattice_points = sc.atom_lattice_points();
        // Phonopy iterates by column first.  However, due to the symmetry of `visit`,
        // this has no impact on the output. (it only affects whether some matrices are given as
        // the first argument or as the second argument to the function)
        let mut bee = self.0.to_coo().into_bee();
        for prim_r in sc.primitive_indices() {
            let super_r = sc.designated_super(prim_r);
            for super_c in sc.super_indices() {
                if !done[prim_r].contains(&super_c) {
                    // Find the indices of the transposed element.
                    let (prim_r_t, super_c_t) = get_effective_indices(
                        sc, &primitive_atoms, &lattice_points,
                        (super_c, super_r),
                    );
                    assert!(!done[prim_r_t].contains(&super_c_t));
                    // NOTE: These get_muts are what cause this function to make the matrix dense,
                    //       since they are done to all indices.
                    let m = *bee.get_mut(prim_r, super_c);
                    let t = bee.get_mut(prim_r_t, super_c_t).t();
                    let (new_m, new_t) = visit(&m, &t);
                    *bee.get_mut(prim_r, super_c) = new_m;
                    *bee.get_mut(prim_r_t, super_c_t) = new_t.t();
                    done[prim_r].insert(super_c);
                    done[prim_r_t].insert(super_c_t);
                }
            }
        }
        self.0 = bee.into_csr();
    }
fn visit_with_transpose ( & mut self , sc : SupercellWrapper < ' _ > , mut visit : impl FnMut ( & M33 , & M33 ) -> ( M33 , M33 ) , ) { let mut done : Indexed < PrimI , Vec < BTreeSet < SuperI > > > ; done = Indexed :: from_elem_n ( BTreeSet :: new ( ) , sc . raw . num_primitive_atoms ( ) ) ; let primitive_atoms = sc . atom_primitive_atoms ( ) ; let lattice_points = sc . atom_lattice_points ( ) ; // Phonopy iterates by column first.  However, due to the symmetry of `visit`, // this has no impact on the output. (it only affects whether some matrices are given as // the first argument or as the second argument to the function) let mut bee = self . 0 . to_coo ( ) . into_bee ( ) ; for prim_r in sc . primitive_indices ( ) { let super_r = sc . designated_super ( prim_r ) ; for super_c in sc . super_indices ( ) { if ! done [ prim_r ] . contains ( & super_c ) { // Find the indices of the transposed element. let ( prim_r_t , super_c_t ) = get_effective_indices ( sc , & primitive_atoms , & lattice_points , ( super_c , super_r ) , ) ; assert ! ( done [ prim_r_t ] contains ( super_c_t ) ) ; // NOTE: These get_muts are what cause this function to make the matrix dense, //       since they are done to all indices. let m = * bee . get_mut ( prim_r , super_c ) ; let t = bee . get_mut ( prim_r_t , super_c_t ) . t ( ) ; let ( new_m , new_t ) = visit ( & m , & t ) ; * bee . get_mut ( prim_r , super_c ) = new_m ; * bee . get_mut ( prim_r_t , super_c_t ) = new_t . t ( ) ; done [ prim_r ] . insert ( super_c ) ; done [ prim_r_t ] . insert ( super_c_t ) ; } } } self . 0 = bee . into_csr ( ) ; }
this corresponds to set_index_permutation_symmetry_compact_fc in _phonopy.c
Finds each pair `(m, t)` of matrices that are supposed to be transposes of each other,
and calls a function to obtain new values for them.
this corresponds to set_index_permutation_symmetry_compact_fc in _phonopy . c Finds each pair ` ( m t ) ` of matrices that are supposed to be transposes of each other and calls a function to obtain new values for them .
&mut self
sc
SupercellWrapper<'_>
visit
impl FnMut(&M33, &M33) -> (M33, M33)
&mut self
sc
SupercellWrapper<'_>
visit
impl FnMut(&M33, &M33) -> (M33, M33)