Skip to content

Should QDense constructor error if zero blocks? #383

@emstoudenmire

Description

@emstoudenmire

The QDense storage constructor taking an IndexSet and a QN sometimes results in a storage with zero blocks, in the case that the requested QN is not compatible with any settings of the indices. This is ok, but the current behavior is that the constructor just makes no blocks (empty list of blocks) and goes on. As a result, calling flux on the resulting ITensor gives QN() which is interpreted as a zero QN. Then calling something like T.generate inside of a function like randomITensor now will generate blocks corresponding to a zero-flux ITensor. So the final QN ends up different from the one requested.

Where should we throw an error to prevent this? Is it reasonable for the QDense constructor to error? It's probably an easy change, but we just need to be sure of the right design.

Example to reproduce:

auto sites = SpinHalf(4,{"ConserveQNs=",true});
auto T = randomITensor(QN({"Sz",1}),sites(1),sites(2),sites(3),sites(4));
Print(flux(T) != QN({"Sz",1}));
Print(flux(T) == QN({"Sz",0}));

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions