Skip to content
This repository was archived by the owner on Mar 23, 2025. It is now read-only.
This repository was archived by the owner on Mar 23, 2025. It is now read-only.

Use nonzeros as an alternative name for data #46

@mtfishman

Description

@mtfishman

Right now, a view of the vector storage of a Tensor can be obtained with the function data. We could consider adopting the Julia SparseArrays function name nonzeros for this purpose (https://docs.julialang.org/en/v1/stdlib/SparseArrays/#SparseArrays.nonzeros), which returns a view of the structural nonzeros of a sparse array.

This is helpful for iteration, any time the iteration is only supposed to work on the elements that are already nonzero.

The line for what data should be touched is a bit blurry from the ITensor perspective. For example, for a QN ITensor, what is supposed to be meant by A .+= 2? It could be interpreted in 3 ways:

  1. Modifying only the structurally nonzero elements.
  2. Modifying any element consistent with the flux (with a reminder that even determining which blocks are consistent with the flux can be slow in the limit of many blocks).
  3. Modifying every element of the ITensor (which would be inconsistent with the flux in general, so would necessitate making the storage dense).

(1) is probably the most common, but likely it is best to make it explicit using nonzeros(A) .+= 2, and possibly it is best to disallow A .+= 2 unless a use case is found where the operations are meant to act on something besides the current structurally nonzero elements.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions