Open mtfishman opened 3 years ago
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.
New generic functions
setstorage
andsetdata
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))
(S::TensorStorage * x::Number) = setdata(S, x*data(S))