A function.
true if applying function to diagonal, false (default) otherwise.
Transpose matrix in place.
import mir.ndslice.allocation: slice; import mir.ndslice.topology: iota, universal; import mir.ndslice.dynamic: transposed; import mir.utility: swap; auto m = iota(4, 4).slice; m.eachUploPair!swap; assert(m == iota(4, 4).universal.transposed);
Reflect Upper matrix part to lower part.
import mir.ndslice.allocation: slice; import mir.ndslice.topology: iota, universal; import mir.ndslice.dynamic: transposed; import mir.utility: swap; // 0 1 2 // 3 4 5 // 6 7 8 auto m = iota(3, 3).slice; m.eachUploPair!((u, ref l) { l = u; }); assert(m == [ [0, 1, 2], [1, 4, 5], [2, 5, 8]]);
Fill lower triangle and diagonal with zeroes.
import mir.ndslice.allocation: slice; import mir.ndslice.topology: iota; // 1 2 3 // 4 5 6 // 7 8 9 auto m = iota([3, 3], 1).slice; m.eachUploPair!((u, ref l) { l = 0; }, true); assert(m == [ [0, 2, 3], [0, 0, 6], [0, 0, 0]]);
The call eachUploPair!(fun)(matrix) evaluates fun for each pair (matrix[j, i], matrix[i, j]), for i <= j (default) or i < j (if includeDiagonal is false).