ITensor / NDTensors.jl

A Julia package for n-dimensional sparse tensors.
Apache License 2.0
27 stars 7 forks source link

Start adding Empty type #1

Closed mtfishman closed 4 years ago

mtfishman commented 4 years ago

This introduces a generic Empty{ElT, StoreT} storage type that is itself parametrized by a storage type StoreT. When an element of a Tensor with an Empty storage type is set, it returns a Tensor with a storage type StoreT. For example:

T = Tensor(Empty(), (2, 2))  # Empty() makes an Empty{Float64, Dense{Float64, ...}} storage
R = setindex!!(T, 2.3, 1, 1) # Returns a Dense Tensor R with all zeros except the 1,1 element
R[1, 1] == 2.3
R[1, 2] == 0.0

Additionally, a Tensor with an Empty storage type can be added to another Tensor, as a trivial additive identity (it returns a copy). This functionality has not been added yet.