13inline void Bits(
const std::vector<bool> &bits,
size_t width)
15 if (bits.size() != width)
16 throw std::invalid_argument(
"MPO bit vector must match the register width");
19inline void Pauli(
const std::string &pauli,
size_t width)
21 if (pauli.size() != width || pauli.find_first_not_of(
"IXYZ") != std::string::npos)
22 throw std::invalid_argument(
"Pauli string must have one I/X/Y/Z per qubit");
27 std::vector<int> result;
30 if (q >= width || q >
static_cast<size_t>(std::numeric_limits<int>::max()))
31 throw std::out_of_range(
"Target qubit is out of range");
32 if (std::find(result.begin(), result.end(),
static_cast<int>(q)) != result.end())
33 throw std::invalid_argument(
"Target qubits must be distinct");
34 result.push_back(
static_cast<int>(q));
41 if (qubits.empty() || qubits.size() > 2 || matrix.rows() != (Eigen::Index{1} << qubits.size()) || matrix.cols() != matrix.rows() || !matrix.allFinite())
42 throw std::invalid_argument(
"Operator must be a finite 2x2 or 4x4 matrix matching its targets");
43 return Qubits(qubits, width);
std::vector< int > Qubits(const Types::qubits_vector &qubits, size_t width)
std::vector< int > Operator(const Types::qubits_vector &qubits, const Eigen::MatrixXcd &matrix, size_t width)
void Bits(const std::vector< bool > &bits, size_t width)
void Pauli(const std::string &pauli, size_t width)
std::vector< qubit_t > qubits_vector
The type of a vector of qubits.