fn mat_solve(a: &[f64], b: &[f64], n: usize, m: usize) -> Vec<f64>
Solve A x = b via Gauss-Jordan (A is n x n, b is n x m, returns x as n x m).