NDTensors.jl icon indicating copy to clipboard operation
NDTensors.jl copied to clipboard

Use new `setstorage` and `setdata` to decrease code duplication across storage types

Open mtfishman opened this issue 3 years ago • 1 comments

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))

mtfishman avatar Apr 06 '21 20:04 mtfishman

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.

emstoudenmire avatar Apr 06 '21 22:04 emstoudenmire