ginkgo
ginkgo copied to clipboard
Improve reordering interface
As observed in https://github.com/ginkgo-project/ginkgo/discussions/939, our reordering interface is easy to accidentally misuse.
Part of the issue is that Permutation violates the LinOp assumptions in some situations. A permutation matrix is square and, applied from the left (as LinOp::apply is intended), it permutes the rows of the input matrix. At the same time, Permutation allows column partitions and symmetric partitions with the same apply interface, even though they would be more correctly represented by a right_apply and conjugate_apply or however we want to call a Similarity Transformation, because with the plain LinOp interface, column permutations of non-square matrices are not possible at all, and symmetric permutations are not possible dimension-wise.
Related issue: #346
This is somewhat relevant here: the operation S1-1 A S2-1 S2 x = S1-1 b is needed for "batched scaled" batch solvers. Usually, the left matrix would be applied to both the matrix and the RHS vector, and could be done together. Therefore, for now I introduced a free function two_sided_system_transform(exec, left_op, right_op, mat, vec) to do this operation. I guess there might be a better name for it.
This was only partially closed by the aforementioned PR, the issues with the Permutation class and the overuse of apply for non-vector related operations remain (also related to #1169)
Fixed by #1415