fn compute_representative_rows(
        &self,
        star_data: &Indexed<StarI, [StarData]>,
        prim_data: &Indexed<PrimI, [PrimData]>,
    ) -> FailResult<BTreeMap<PrimI, BTreeMap<SuperI, M3<V3<f64>>>>> {
        let mut computed_rows: BTreeMap<PrimI, BTreeMap<SuperI, M33>> = Default::default();
        for (star, data) in star_data.iter_enumerated() {
            let StarData {
                representative,
                displacements: ref disp_indices,
            } = *data;

            // Expand the available data using symmetry to ensure we have enough
            // independent equations for pseudoinversion.
            //
            // Ignore symmetry operators that map the representative to another
            // primitive site. (after we solve for the representative's force
            // constants, the others within its star are related by symmetry)
            assert_eq!(star, prim_data[representative].star, "BUG!");

            let (
                row_displacements,
                row_forces,
            ) = self.build_all_equations_for_representative_row(
                representative,
                &disp_indices,
                &prim_data[representative].opers_from_rep,
            );

            use rsp2_linalg::{CMatrix, dot, left_pseudoinverse};

            // all forces we just computed use the same displacements,
            // so we only need to compute a single pseudoinverse
            let pseudoinverse: CMatrix = left_pseudoinverse((&row_displacements.raw[..]).into())?;

            let force_constants_row: BTreeMap<SuperI, M33> = {
                row_forces.into_iter()
                    // solve for the fcs
                    .map(|(atom, force_vec)| {
                        let forces: CMatrix = force_vec.raw.into();
                        let phi: CMatrix = dot(&*pseudoinverse, &*forces).into();
                        let phi: M33 = -M3(phi.c_order_data().nest::<V3>().to_array());
                        (atom, phi)
                    })
                    .collect()
            };

            if let Some(_) = computed_rows.insert(representative, force_constants_row) {
                panic!("(BUG) computed same row of FCs twice!?");
            }
        } // for star
        Ok(computed_rows)
    }
// Computes the rows of the FC matrix belonging to symmetry star representatives.
Computes the rows of the FC matrix belonging to symmetry star representatives.
Computes the rows of the FC matrix belonging to symmetry star representatives .
fn compute_representative_rows(
        &self,
        star_data: &Indexed<StarI, [StarData]>,
        prim_data: &Indexed<PrimI, [PrimData]>,
    ) -> FailResult<BTreeMap<PrimI, BTreeMap<SuperI, M3<V3<f64>>>>> {
        let mut computed_rows: BTreeMap<PrimI, BTreeMap<SuperI, M33>> = Default::default();
        for (star, data) in star_data.iter_enumerated() {
            let StarData {
                representative,
                displacements: ref disp_indices,
            } = *data;
            // Expand the available data using symmetry to ensure we have enough
            // independent equations for pseudoinversion.
            //
            // Ignore symmetry operators that map the representative to another
            // primitive site. (after we solve for the representative's force
            // constants, the others within its star are related by symmetry)
            assert_eq!(star, prim_data[representative].star, "BUG!");
            let (
                row_displacements,
                row_forces,
            ) = self.build_all_equations_for_representative_row(
                representative,
                &disp_indices,
                &prim_data[representative].opers_from_rep,
            );
            use rsp2_linalg::{CMatrix, dot, left_pseudoinverse};
            // all forces we just computed use the same displacements,
            // so we only need to compute a single pseudoinverse
            let pseudoinverse: CMatrix = left_pseudoinverse((&row_displacements.raw[..]).into())?;
            let force_constants_row: BTreeMap<SuperI, M33> = {
                row_forces.into_iter()
                    // solve for the fcs
                    .map(|(atom, force_vec)| {
                        let forces: CMatrix = force_vec.raw.into();
                        let phi: CMatrix = dot(&*pseudoinverse, &*forces).into();
                        let phi: M33 = -M3(phi.c_order_data().nest::<V3>().to_array());
                        (atom, phi)
                    })
                    .collect()
            };
            if let Some(_) = computed_rows.insert(representative, force_constants_row) {
                panic!("(BUG) computed same row of FCs twice!?");
            }
        } // for star
        Ok(computed_rows)
    }
fn compute_representative_rows ( & self , star_data : & Indexed < StarI , [ StarData ] > , prim_data : & Indexed < PrimI , [ PrimData ] > , ) -> FailResult < BTreeMap < PrimI , BTreeMap < SuperI , M3 < V3 < f64 > > > > > { let mut computed_rows : BTreeMap < PrimI , BTreeMap < SuperI , M33 > > = Default :: default ( ) ; for ( star , data ) in star_data . iter_enumerated ( ) { let StarData { representative , displacements : ref disp_indices , } = * data ; // Expand the available data using symmetry to ensure we have enough // independent equations for pseudoinversion. // // Ignore symmetry operators that map the representative to another // primitive site. (after we solve for the representative's force // constants, the others within its star are related by symmetry) assert_eq ! ( star prim_data [ representative ] star " " ) ; let ( row_displacements , row_forces , ) = self . build_all_equations_for_representative_row ( representative , & disp_indices , & prim_data [ representative ] . opers_from_rep , ) ; use rsp2_linalg :: { CMatrix , dot , left_pseudoinverse } ; // all forces we just computed use the same displacements, // so we only need to compute a single pseudoinverse let pseudoinverse : CMatrix = left_pseudoinverse ( ( & row_displacements . raw [ .. ] ) . into ( ) ) ? ; let force_constants_row : BTreeMap < SuperI , M33 > = { row_forces . into_iter ( ) // solve for the fcs . map ( | ( atom , force_vec ) | { let forces : CMatrix = force_vec . raw . into ( ) ; let phi : CMatrix = dot ( & * pseudoinverse , & * forces ) . into ( ) ; let phi : M33 = - M3 ( phi . c_order_data ( ) . nest :: < V3 > ( ) . to_array ( ) ) ; ( atom , phi ) } ) . collect ( ) } ; if let Some ( _ ) = computed_rows . insert ( representative , force_constants_row ) { panic ! ( " " ) ; } } // for star Ok ( computed_rows ) }
Computes the rows of the FC matrix belonging to symmetry star representatives.
Computes the rows of the FC matrix belonging to symmetry star representatives .
&self
star_data
&Indexed<StarI, [StarData]>
prim_data
&Indexed<PrimI, [PrimData]>
&self
star_data
&Indexed<StarI, [StarData]>
prim_data
&Indexed<PrimI, [PrimData]>