Description
openedon Jun 5, 2016
Example methods are here for Triangular, or here for Diagonal where these follow the BLAS trmm
convention of mutating whichever argument is not the type in question. So A_mul_B!(A, B)
might mutate A, or it might mutate B, depending on their types. This is the case for several other combinations of input types as well, and I think it's bad for generic programming. Ref collapsed discussion right below #16615 (comment), and #16577 and #16562.
If we can't apply a consistent rule here, "always mutates the second argument" (or, if we apply it consistently everywhere, the first?), then we shouldn't define this method. Better to favor the more explicit A_mul_B!(C, A, B)
method where the output is a separate argument. Some combinations of types can allow one of A_mul_B!(A, A, B)
or A_mul_B!(B, A, B)
to work, but writing code that does that will be inherently non-generic. The individual methods of A_mul_B!
should be responsible for checking whether the inputs are ===
(and possibly more complicated forms of alias checks if we have more view types in common use) and only allowing the specific combinations that are expected to work.
This issue is still present for all the in-place multiplication methods even if #6837 renames all 7 (or 9 if you count possible combinations we don't define right now, ref #5332) variants to methods of mul!
. I think this is an explicitly post-0.5 cleanup to make though since we don't have time to deal with it right now.