Skip to content
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

Some new Empty ITensor constructors #352

Closed
mtfishman opened this issue May 11, 2020 · 2 comments
Closed

Some new Empty ITensor constructors #352

mtfishman opened this issue May 11, 2020 · 2 comments
Assignees
Labels
api Issues related to the interface enhancement New feature or request
Milestone

Comments

@mtfishman
Copy link
Member

This is a proposal to use ITensor{N}() as an alternative syntax for constructing an ITensor with Empty storage and N indices. This could also be written as emptyITensor(Val{N}) or emptyITensor(Order{N}) to make it clearer that an Empty storage is being created (where struct Order{N} end could be a type we introduce like Val that is used as a compile-time order of a tensor).

For example, ITensor{Any}() could be another way to write emptyITensor(Any). Also, ITensor{3}() could be a syntax for making an ITensor with Empty storage of order 3 with unspecified indices. This could be useful for doing in-place operations where you don't want to specify the indices:

A = ITensor{2}() # ITensor with Empty storage and 2 unspecified indices
i = Index(2)
A[i => 1, i' => 2] = 2.5   # This makes an ITensor with indices (i, i')

and:

A = ITensor{3}()
i = Index(2)
for _ in 1:5
  A .+= randomITensor(i,i',i'')
end

(Note this builds off of PR #348).

@mtfishman mtfishman self-assigned this May 11, 2020
@emstoudenmire
Copy link
Collaborator

Yes, I think good to have these. It’s nice we can strike a balance between having to specify the exact indices of an empty ITensor versus having to just use ITensor{Any}() for every situation where they aren’t known ahead of time.

@mtfishman mtfishman added api Issues related to the interface enhancement New feature or request labels Oct 8, 2020
@mtfishman mtfishman added this to the v0.3 milestone Oct 8, 2020
@mtfishman
Copy link
Member Author

Closed by #641.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the interface enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants