pub fn from_lattice(lattice: &Lattice) -> Self {
        let reduced_lattice =
            Lattice::new(ReducedLattice::lll_lattice(lattice.to_cartesian));
        let to_cartesian = reduced_lattice.to_cartesian;
        let to_fractional = reduced_lattice.to_fractional;
        let distance_matrix = reduced_lattice.distance_matrix;
        let cartesian_shift_matrix = reduced_lattice.shift_matrix;
        let mut shift_matrix = Vec::with_capacity(26);
        for c_shift in cartesian_shift_matrix.iter().take(26) {
            shift_matrix.push({
                let mut shift_vec = Vec::<usize>::new();
                // There has to be a better way to round this
                let mut shift = utils::dot(*c_shift, lattice.to_fractional)
                    .iter()
                    .map(|x| ((x * 1E14).round() / 1E14) as isize)
                    .collect::<Vec<isize>>();
                let max_shift = shift.iter().map(|x| x.abs()).max().unwrap();
                for _ in 0..max_shift {
                    let mut out = [0isize; 3];
                    for k in 0..3 {
                        if shift[k].abs() > 1 {
                            out[k] = shift[k] / shift[k].abs();
                        } else {
                            out[k] = shift[k];
                        }
                        shift[k] -= out[k];
                    }
                    shift_vec.push((out[0] * 9 + out[1] * 3 + out[2] + 13)
                                   as usize);
                }
                shift_vec
            });
        }
        Self { shift_matrix,
               cartesian_shift_matrix,
               distance_matrix,
               to_cartesian,
               to_fractional }
    }
/// Creates a lll-reduced lattice from the cell lattice.
Creates a lll-reduced lattice from the cell lattice.
Creates a lll - reduced lattice from the cell lattice .
pub fn from_lattice(lattice: &Lattice) -> Self {
        let reduced_lattice =
            Lattice::new(ReducedLattice::lll_lattice(lattice.to_cartesian));
        let to_cartesian = reduced_lattice.to_cartesian;
        let to_fractional = reduced_lattice.to_fractional;
        let distance_matrix = reduced_lattice.distance_matrix;
        let cartesian_shift_matrix = reduced_lattice.shift_matrix;
        let mut shift_matrix = Vec::with_capacity(26);
        for c_shift in cartesian_shift_matrix.iter().take(26) {
            shift_matrix.push({
                let mut shift_vec = Vec::<usize>::new();
                // There has to be a better way to round this
                let mut shift = utils::dot(*c_shift, lattice.to_fractional)
                    .iter()
                    .map(|x| ((x * 1E14).round() / 1E14) as isize)
                    .collect::<Vec<isize>>();
                let max_shift = shift.iter().map(|x| x.abs()).max().unwrap();
                for _ in 0..max_shift {
                    let mut out = [0isize; 3];
                    for k in 0..3 {
                        if shift[k].abs() > 1 {
                            out[k] = shift[k] / shift[k].abs();
                        } else {
                            out[k] = shift[k];
                        }
                        shift[k] -= out[k];
                    }
                    shift_vec.push((out[0] * 9 + out[1] * 3 + out[2] + 13)
                                   as usize);
                }
                shift_vec
            });
        }
        Self { shift_matrix,
               cartesian_shift_matrix,
               distance_matrix,
               to_cartesian,
               to_fractional }
    }
pub fn from_lattice ( lattice : & Lattice ) -> Self { let reduced_lattice = Lattice :: new ( ReducedLattice :: lll_lattice ( lattice . to_cartesian ) ) ; let to_cartesian = reduced_lattice . to_cartesian ; let to_fractional = reduced_lattice . to_fractional ; let distance_matrix = reduced_lattice . distance_matrix ; let cartesian_shift_matrix = reduced_lattice . shift_matrix ; let mut shift_matrix = Vec :: with_capacity ( 26 ) ; for c_shift in cartesian_shift_matrix . iter ( ) . take ( 26 ) { shift_matrix . push ( { let mut shift_vec = Vec :: < usize > :: new ( ) ; // There has to be a better way to round this let mut shift = utils :: dot ( * c_shift , lattice . to_fractional ) . iter ( ) . map ( | x | ( ( x * 1E14 ) . round ( ) / 1E14 ) as isize ) . collect :: < Vec < isize > > ( ) ; let max_shift = shift . iter ( ) . map ( | x | x . abs ( ) ) . max ( ) . unwrap ( ) ; for _ in 0 .. max_shift { let mut out = [ 0isize ; 3 ] ; for k in 0 .. 3 { if shift [ k ] . abs ( ) > 1 { out [ k ] = shift [ k ] / shift [ k ] . abs ( ) ; } else { out [ k ] = shift [ k ] ; } shift [ k ] -= out [ k ] ; } shift_vec . push ( ( out [ 0 ] * 9 + out [ 1 ] * 3 + out [ 2 ] + 13 ) as usize ) ; } shift_vec } ) ; } Self { shift_matrix , cartesian_shift_matrix , distance_matrix , to_cartesian , to_fractional } }
Creates a lll-reduced lattice from the cell lattice.
Creates a lll - reduced lattice from the cell lattice .
lattice
&Lattice
lattice
&Lattice