()
| 167 | } |
| 168 | |
| 169 | fn check_matrix() { |
| 170 | // py_matrix (api.rs:54-55) |
| 171 | let m = py_matrix(vec![ |
| 172 | vec![1.0_f64, 2.0, 3.0, 4.0], |
| 173 | vec![5.0, 6.0, 7.0, 8.0], |
| 174 | vec![9.0, 10.0, 11.0, 12.0], |
| 175 | ]); |
| 176 | print_kv("py_matrix 3x4 hash", hash_matrix(&m)); |
| 177 | // change_shape (matrix.rs:897, 905) |
| 178 | let m_col = m.change_shape(); |
| 179 | print_kv("change_shape Row->Col hash", hash_matrix(&m_col)); |
| 180 | let m_back = m_col.change_shape(); |
| 181 | print_kv("change_shape Col->Row hash", hash_matrix(&m_back)); |
| 182 | // diag (matrix.rs:1105) |
| 183 | let sq = ml_matrix("1 2 3; 4 5 6; 7 8 9"); |
| 184 | let d = sq.diag(); |
| 185 | print_kv("diag 3x3", hash_f64s(&d)); |
| 186 | // to_vec (matrix.rs:1184) |
| 187 | let v_of_v = sq.to_vec(); |
| 188 | let flat: Vec<f64> = v_of_v.into_iter().flatten().collect(); |
| 189 | print_kv("to_vec hash", hash_f64s(&flat)); |
| 190 | // col_reduce / row_reduce (matrix.rs:2863, 2874) |
| 191 | let cr = sq.col_reduce(|c| c.iter().sum::<f64>()); |
| 192 | let rr = sq.row_reduce(|c| c.iter().sum::<f64>()); |
| 193 | print_kv("col_reduce sum", hash_f64s(&cr)); |
| 194 | print_kv("row_reduce sum", hash_f64s(&rr)); |
| 195 | // is_symmetric (matrix.rs:3660, 3683) |
| 196 | let sym = ml_matrix("1 2 3; 2 5 6; 3 6 9"); |
| 197 | let nonsym = ml_matrix("1 2 3; 4 5 6; 7 8 9"); |
| 198 | print_kv("is_symmetric sym", sym.is_symmetric()); |
| 199 | print_kv("is_symmetric nonsym", nonsym.is_symmetric()); |
| 200 | // matrix.rs:764-765 - inspect; this site is inside `py_matrix` |
| 201 | // creation path already exercised above. Cover additionally with a |
| 202 | // non-square shape so both row/col loops fire. |
| 203 | let rect = py_matrix(vec![vec![1.0_f64, 2.0], vec![3.0, 4.0], vec![5.0, 6.0]]); |
| 204 | print_kv("py_matrix 3x2 hash", hash_matrix(&rect)); |
| 205 | } |
| 206 | |
| 207 | fn check_polynomial() { |
| 208 | let p = poly(vec![1.0, -2.0, 0.5, 3.0]); // 1 - 2x + 0.5x^2 + 3x^3 |
no test coverage detected