52 template <
class T = Eigen::VectorXcd>
Alias(
const T &statevector)
54 size_t numNonZeroStates = 0;
55 bool contiguousStates =
true;
57 for (Eigen::Index state = 0; state < static_cast<Eigen::Index>(statevector.size()); ++state)
59 const double stateProb = std::norm(statevector[state]);
60 if (stateProb < std::numeric_limits<double>::epsilon())
63 contiguousStates = contiguousStates &&
static_cast<size_t>(state) == numNonZeroStates;
73 if (!contiguousStates)
74 statesTable.reserve(numNonZeroStates);
79 for (Eigen::Index state = 0; state < static_cast<Eigen::Index>(statevector.size()); ++state)
81 const double stateProb = std::norm(statevector[state]);
82 if (stateProb < std::numeric_limits<double>::epsilon())
85 add(row++, stateProb * numNonZeroStates);
86 if (!contiguousStates)
87 statesTable.push_back(state);
99 statesTable.reserve(amplitudesMap.size());
102 for (const auto &entry : amplitudesMap)
104 add(row++, (std::norm(entry.second) / total) * amplitudesMap.size());
105 statesTable.push_back(entry.first.getWords()[0]);