Skip to content

Commit

Permalink
Merge pull request #384 from emstoudenmire/qn_randomITensor
Browse files Browse the repository at this point in the history
Add error checks for zero blocks in randomITensor QN version
  • Loading branch information
emstoudenmire committed Feb 8, 2021
2 parents fb83fde + d494752 commit 477aaed
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions itensor/itensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,7 @@ randomITensor(QN q, IndexSet const& is)
ITensor T;
auto dat = QDenseReal{is,q};
T = ITensor(std::move(is),std::move(dat));
if(nnz(T) == 0) Error("Requested QN for random ITensor resulted in zero allowed blocks (QN not satisfiable by any settings of the indices)");
T.generate(detail::quickran);
return T;
}
Expand All @@ -1594,6 +1595,7 @@ randomITensorC(QN q, IndexSet const& is)
ITensor T;
auto dat = QDenseCplx{is,q};
T = ITensor(std::move(is),std::move(dat));
if(nnz(T) == 0) Error("Requested QN for random ITensor resulted in zero allowed blocks (QN not satisfiable by any settings of the indices)");
T.generate(detail::quickranCplx);
return T;
}
Expand Down

0 comments on commit 477aaed

Please sign in to comment.