(m: &mut ComplexMatrix)
| 2668 | /// LU via Gaussian Elimination with Partial Pivoting |
| 2669 | #[allow(dead_code)] |
| 2670 | fn gepp(m: &mut ComplexMatrix) -> Vec<usize> { |
| 2671 | let mut r = vec![0usize; m.col - 1]; |
| 2672 | for k in 0..(m.col - 1) { |
| 2673 | // Find the pivot row |
| 2674 | let r_k = m |
| 2675 | .col(k) |
| 2676 | .into_iter() |
| 2677 | .skip(k) |
| 2678 | .enumerate() |
| 2679 | .max_by(|x1, x2| x1.1.norm().partial_cmp(&x2.1.norm()).unwrap()) |
| 2680 | .unwrap() |
| 2681 | .0 |
| 2682 | + k; |
| 2683 | r[k] = r_k; |
| 2684 | |
| 2685 | // Interchange the rows r_k and k |
| 2686 | for j in k..m.col { |
| 2687 | unsafe { |
| 2688 | std::ptr::swap(&mut m[(k, j)], &mut m[(r_k, j)]); |
| 2689 | println!("Swap! k:{}, r_k:{}", k, r_k); |
| 2690 | } |
| 2691 | } |
| 2692 | // Form the multipliers |
| 2693 | for i in k + 1..m.col { |
| 2694 | m[(i, k)] = -m[(i, k)] / m[(k, k)]; |
| 2695 | } |
| 2696 | // Update the entries |
| 2697 | for i in k + 1..m.col { |
| 2698 | for j in k + 1..m.col { |
| 2699 | let local_m = m[(i, k)] * m[(k, j)]; |
| 2700 | m[(i, j)] += local_m; |
| 2701 | } |
| 2702 | } |
| 2703 | } |
| 2704 | r |
| 2705 | } |
| 2706 | |
| 2707 | /// LU via Gauss Elimination with Complete Pivoting |
| 2708 | fn gecp(m: &mut ComplexMatrix) -> (Vec<usize>, Vec<usize>) { |
nothing calls this directly
no test coverage detected