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

Iteration over sites for OrbitalSliceArray #322

Open
pablosanjose opened this issue Nov 20, 2024 · 1 comment
Open

Iteration over sites for OrbitalSliceArray #322

pablosanjose opened this issue Nov 20, 2024 · 1 comment

Comments

@pablosanjose
Copy link
Owner

pablosanjose commented Nov 20, 2024

OrbitalSliceArrays are flat AbstractArrays{<:Number}, so iteration occurs over orbitals, not sites. We can also index them using a[sites(...)...] or view(a, sites[...]...) to get orbital blocks corresponding to stored sites, but often what we need is to simply iterate over all stored sites, and get all the blocks one after the other. We can currently do Quantica.cellsites(orbaxes(a)[1]) to get an iterator of CellSite indices that can be used to index a, but these are not exported.

Proposal

  • sites(a::OrbitalSliceArrays, i) should be equivalent to Quantica.cellsites(orbaxes(a)[i])
  • sites(a::OrbitalSliceArrays) should be a CartesianIndices iterator over all indices
@pablosanjose
Copy link
Owner Author

I had forgotten we have an exported siteindexdict(orbaxes(a)[1]) that gives a dictionary over CellIndices and flat indices.

It can be argued that sites means site positions in Quantica, so the above proposal would not be consistent. A more idiomatic interface would be o = orbaxes(a, 1) to be iterable, returning flat index ranges, i.e. the values of siteindexdict(o). Then we could do

for js in orbaxes(m, 2), is in orbaxes(m, 1)
  v = view(m, is, js)
  #do something with v
end

Note that orbaxes(a, n) = orbaxes(a)[n] would also need to be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant