LinearAlgebra Examples - Waigo01/math_utils_lib GitHub Wiki

let a = Variable::new("A", value!(6, 1, 13, 8; 4, 3, 9, 10; 4, 0, 14, 8));
let b = Variable::new("B", value!(3, 0; 1, 1; 0, 6; 2.5, 2));
let res = quick_eval!("A*B", &mut Context::from_vars(vec![a, b]))?.to_vec();

assert_eq!(res[0], value!(39, 95; 40, 77; 32, 100));
let a = Variable::new("A", Value::Matrix(vec![vec![2.]]));

let res = quick_eval!("inv(A)", &mut Context::with_vars(vec![a]))?.to_vec();

assert_eq!(res[0], Value::Matrix(vec![vec![0.5]]));
let a = Variable::new("A", value!(3, 5, 8));
let b = Variable::new("B", value!(2, 0, 0; 0, 2, 0; 0, 0, 1));
let res = quick_eval!("B*A", &mut Context::from_vars(vec![a, b]))?.to_vec();

assert_eq!(res[0], value!(6, 10, 8));
let a = Variable::new("A", value!(1, 2, 3; 4, 5, 6; 7, 8, 9));
let res = quick_eval!("det(A)", &mut Context::with_vars(vec![a]))?.to_vec();

assert_eq!(res[0], value!(0));
let m = Variable::new("M", value!(0.7, 0.1, 0.3; 0.1, 0.5, 0.1; 0.2, 0.4, 0.6));

let res = quick_eval!("M^20", &mut Context::from_vars(vec![m]))?.round(3).to_vec();

assert_eq!(res[0], value!(0.444, 0.444, 0.444; 0.167, 0.167, 0.167; 0.389, 0.389, 0.389));
⚠️ **GitHub.com Fallback** ⚠️