pub fn invert_lattice(lattice: &[[f64; 3]; 3]) -> Result<[[f64; 3]; 3]> {
    let minor00 = lattice[1][1] * lattice[2][2] - lattice[1][2] * lattice[2][1];
    let minor01 = lattice[1][0] * lattice[2][2] - lattice[1][2] * lattice[2][0];
    let minor02 = lattice[1][0] * lattice[2][1] - lattice[1][1] * lattice[2][0];
    let determinant = lattice[0][0] * minor00 - lattice[0][1] * minor01
                      + lattice[0][2] * minor02;
    if determinant.abs() < 1e-16 {
        bail!("Lattice doesn't span 3D space.")
    } else {
        Ok([[minor00 / determinant,
             (lattice[0][2] * lattice[2][1] - lattice[2][2] * lattice[0][1])
             / determinant,
             (lattice[0][1] * lattice[1][2] - lattice[1][1] * lattice[0][2])
             / determinant],
            [-minor01 / determinant,
             (lattice[0][0] * lattice[2][2] - lattice[2][0] * lattice[0][2])
             / determinant,
             (lattice[0][2] * lattice[1][0] - lattice[1][2] * lattice[0][0])
             / determinant],
            [minor02 / determinant,
             (lattice[0][1] * lattice[2][0] - lattice[2][1] * lattice[0][0])
             / determinant,
             (lattice[0][0] * lattice[1][1] - lattice[1][0] * lattice[0][1])
             / determinant]])
    }
}
/// calculates the inverse of a 3x3 lattice
calculates the inverse of a 3x3 lattice
calculates the inverse of a 3x3 lattice
pub fn invert_lattice(lattice: &[[f64; 3]; 3]) -> Result<[[f64; 3]; 3]> {
    let minor00 = lattice[1][1] * lattice[2][2] - lattice[1][2] * lattice[2][1];
    let minor01 = lattice[1][0] * lattice[2][2] - lattice[1][2] * lattice[2][0];
    let minor02 = lattice[1][0] * lattice[2][1] - lattice[1][1] * lattice[2][0];
    let determinant = lattice[0][0] * minor00 - lattice[0][1] * minor01
                      + lattice[0][2] * minor02;
    if determinant.abs() < 1e-16 {
        bail!("Lattice doesn't span 3D space.")
    } else {
        Ok([[minor00 / determinant,
             (lattice[0][2] * lattice[2][1] - lattice[2][2] * lattice[0][1])
             / determinant,
             (lattice[0][1] * lattice[1][2] - lattice[1][1] * lattice[0][2])
             / determinant],
            [-minor01 / determinant,
             (lattice[0][0] * lattice[2][2] - lattice[2][0] * lattice[0][2])
             / determinant,
             (lattice[0][2] * lattice[1][0] - lattice[1][2] * lattice[0][0])
             / determinant],
            [minor02 / determinant,
             (lattice[0][1] * lattice[2][0] - lattice[2][1] * lattice[0][0])
             / determinant,
             (lattice[0][0] * lattice[1][1] - lattice[1][0] * lattice[0][1])
             / determinant]])
    }
}
pub fn invert_lattice ( lattice : & [ [ f64 ; 3 ] ; 3 ] ) -> Result < [ [ f64 ; 3 ] ; 3 ] > { let minor00 = lattice [ 1 ] [ 1 ] * lattice [ 2 ] [ 2 ] - lattice [ 1 ] [ 2 ] * lattice [ 2 ] [ 1 ] ; let minor01 = lattice [ 1 ] [ 0 ] * lattice [ 2 ] [ 2 ] - lattice [ 1 ] [ 2 ] * lattice [ 2 ] [ 0 ] ; let minor02 = lattice [ 1 ] [ 0 ] * lattice [ 2 ] [ 1 ] - lattice [ 1 ] [ 1 ] * lattice [ 2 ] [ 0 ] ; let determinant = lattice [ 0 ] [ 0 ] * minor00 - lattice [ 0 ] [ 1 ] * minor01 + lattice [ 0 ] [ 2 ] * minor02 ; if determinant . abs ( ) < 1e-16 { bail ! ( " " ) } else { Ok ( [ [ minor00 / determinant , ( lattice [ 0 ] [ 2 ] * lattice [ 2 ] [ 1 ] - lattice [ 2 ] [ 2 ] * lattice [ 0 ] [ 1 ] ) / determinant , ( lattice [ 0 ] [ 1 ] * lattice [ 1 ] [ 2 ] - lattice [ 1 ] [ 1 ] * lattice [ 0 ] [ 2 ] ) / determinant ] , [ - minor01 / determinant , ( lattice [ 0 ] [ 0 ] * lattice [ 2 ] [ 2 ] - lattice [ 2 ] [ 0 ] * lattice [ 0 ] [ 2 ] ) / determinant , ( lattice [ 0 ] [ 2 ] * lattice [ 1 ] [ 0 ] - lattice [ 1 ] [ 2 ] * lattice [ 0 ] [ 0 ] ) / determinant ] , [ minor02 / determinant , ( lattice [ 0 ] [ 1 ] * lattice [ 2 ] [ 0 ] - lattice [ 2 ] [ 1 ] * lattice [ 0 ] [ 0 ] ) / determinant , ( lattice [ 0 ] [ 0 ] * lattice [ 1 ] [ 1 ] - lattice [ 1 ] [ 0 ] * lattice [ 0 ] [ 1 ] ) / determinant ] ] ) } }
calculates the inverse of a 3x3 lattice
calculates the inverse of a 3x3 lattice
lattice
&[[f64; 3]; 3]
lattice
&[[f64; 3]; 3]