From d4947525e4c90289735801c26c4e5ca4a8d8aa33 Mon Sep 17 00:00:00 2001 From: Miles Stoudenmire Date: Mon, 8 Feb 2021 12:04:53 -0500 Subject: [PATCH] Add error checks for zero blocks in randomITensor QN version --- itensor/itensor.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/itensor/itensor.cc b/itensor/itensor.cc index fd4240c32..175529796 100644 --- a/itensor/itensor.cc +++ b/itensor/itensor.cc @@ -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; } @@ -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; }