NDTensors.jl
NDTensors.jl copied to clipboard
Use new `setstorage` and `setdata` to decrease code duplication across storage types
New generic functions setstorage
and setdata
were introduced in #72. These can be used to decrease code duplication across storage types. Here is a running list of examples where they could be used:
- [ ]
similar(S::TensorStorage, ElT = Float64) = setdata(S, similar(data(S), ElT))
- [x]
(S::TensorStorage * x::Number) = setdata(S, x*data(S))
Good point. I just implemented the scalar multiplication case as a generic TensorStorage routine across all data types in PR #72. The case of similar may be a bit more complicated because there are two subtypes of DiagBlockSparse which handle the similar operation differently, so I didn’t want to rush through that one for #72.