| 93 | } |
| 94 | |
| 95 | void convertPivot(int *pivot, int out_sz, size_t pivot_dim) { |
| 96 | std::vector<int> p(out_sz); |
| 97 | iota(begin(p), end(p), 0); |
| 98 | |
| 99 | for (int j = 0; j < static_cast<int>(pivot_dim); j++) { |
| 100 | // 1 indexed in pivot |
| 101 | std::swap(p[j], p[pivot[j] - 1]); |
| 102 | } |
| 103 | |
| 104 | copy(begin(p), end(p), pivot); |
| 105 | } |
| 106 | |
| 107 | template<typename T> |
| 108 | void lu(Array<T> &lower, Array<T> &upper, Array<int> &pivot, |