Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The definition of
copy_oftype
has been changed in #40831. Subsequently, it was proposed to rename the new function tocopymutable_oftype
. This PR adds back the originalcopy_oftype
methods and renames the current ones intocopymutable_oftype
.The difficulty with this functionality is that it is supposed to do two things at once: (a) copy and (b) potentially change the eltype. If the eltype needs to be changed, it is clear that we need to create a copy. It is not immediatly clear though what type of copy: should some algebraic structure (
*diagonal
ity) be preserved, should some wrapped object (think of ranges) be structurally preserved, etc. Even in the case when the eltype doesn't have to be changed, the same questions occur: should the result (or some wrapped structure) be necessarily mutable or not. One value in bringing back the oldcopy_oftype
is that in the latter case (eltype(A) == T
) it runs bycopy
, which is an exported function and may very well be overloaded for custom array types. Generically, though,copy
does nothing butcopymutable
, which in turn is nothing butcopyto!(similar(A), A)
, wheresimilar(A)
is generically expanded tosimilar(A, eltype(A))
, and hencecopy_oftype
does the same as (the new)copymutable_oftype
. As forLinearAlgebra
internally, I believe we really want those "copies" to be mutable, so we don't usecopy_oftype
at all. One could argue why have it in LinearAlgebra then, but there was some action required due to the change in the definition ofcopy_oftype
. I'm putting this up mainly for discussion. If this finds support, this should be backportable to v1.8, because this is a complete renaming of any occurence ofcopy_oftype
and returns previously existing methods by their previous name.