Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 625 Bytes

invert-matrix.zh.md

File metadata and controls

26 lines (20 loc) · 625 Bytes

反转矩阵

[![nalgebra-badge]][nalgebra] [![cat-science-badge]][cat-science]

使用nalgebra::Matrix3创建 3x3 矩阵,如果可能的话,将其反转。

extern crate nalgebra;

use nalgebra::Matrix3;

fn main() {
    let m1 = Matrix3::new(2.0, 1.0, 1.0, 3.0, 2.0, 1.0, 2.0, 1.0, 2.0);
    println!("m1 = {}", m1);
    match m1.try_inverse() {
        Some(inv) => {
            println!("The inverse of m1 is: {}", inv);
        }
        None => {
            println!("m1 is not invertible!");
        }
    }
}