-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the semantics of storage[type] #23270
Comments
One potential hiccup with the return-uninitialized-instance semantics is immutable storage types. |
Triage call suggests that
and have it work, even for AbstractArrays that the person implementing the factorization doesn't know about (and similarly have matrix methods work fine, even when the people implementing custom AbstractArray types don't know about them). The precise naming and semantics of |
@JeffBezanson notes the similarity to promotion in scalar arithmetic. |
Examples from base (linalg/triangular.jl and linalg/symmetric.jl) of the particular meaning of +(A::UnitUpperTriangular, B::UnitLowerTriangular) = full(A) + full(B)
(*)(A::Tridiagonal, B::UpperTriangular) = A_mul_B!(full(A), B)
svdfact(A::AbstractTriangular) = svdfact(full(A))
A_mul_B!(C::AbstractMatrix, A::Tridiagonal, B::AbstractTriangular) = A_mul_B!(C, A, full(B)) |
Indeed, perhaps this just needs a promotion-like mechanism for array types. I worry that "de-exiticize me by one 'notch'" would be pretty brittle and error prone. It seems like the kind of think that would mostly work and then not in many corner cases and just be an endless source of bugs and problems in generic code. The promotion mechanism is quite precise and Just Works™ once you have the right general promotion rules. |
One of
full
's meanings is: Given a matrix wrapped in a structured view type, for example aUnitLowerTriangular{Float64,SparseMatrixCSC{Float64,Int64}}
L
, return an instance of the storage type backingL
, in this case aSparseMatrixCSC{Float64,Int64}
, that is element-wise equal toL
.As with other meanings of
full
, till recently the plan has been to deprecate this meaning in favor of aconvert
call, in this caseconvert(storagetype(L), L)
(with introduction of astoragetype
function). But on a recent triage call,@JeffBezanson
suggested that astoragetype
-like function return an instance rather than a type.Deciding the semantics of the
storage[type]
function is this issue's purpose. Shouldstorage[type]
return a type? Shouldstorage[type]
return an instance? If the latter, shouldstorage[type]
return an instance populated with the contents of the originalAbstractArray
? Or shouldstorage[type]
instead return an uninitialized instance (likesimilar
), with the above meaning offull
then speltcopy!(storage(L), L)
? Best!(Ref. past discussions in #17066, #17082, #17079, and #18850, and a recent mention in #23263.)
The text was updated successfully, but these errors were encountered: