Skip to content

Commit

Permalink
empty check with proper function
Browse files Browse the repository at this point in the history
  • Loading branch information
M-J-Hochreiter committed Jan 16, 2025
1 parent 036f68a commit b91836f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/algorithms/StatePreparation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ template <typename T>
return identity;
}

[[nodiscard]] auto matrixVectorProd(const Matrix& matrix,
std::vector<double> vector)
-> std::vector<double> {
[[nodiscard]] auto
matrixVectorProd(const Matrix& matrix,
std::vector<double> vector) -> std::vector<double> {
std::vector<double> result;
for (const auto& matrixVec : matrix) {
double sum{0};
Expand Down Expand Up @@ -195,8 +195,8 @@ rotationsToDisentangle(std::vector<std::complex<double>> amplitudes)

// creates circuit that takes desired vector to zero
[[nodiscard]] auto
gatesToUncompute(std::vector<std::complex<double>> amplitudes, size_t numQubits)
-> QuantumComputation {
gatesToUncompute(std::vector<std::complex<double>> amplitudes,
size_t numQubits) -> QuantumComputation {
QuantumComputation disentangler{numQubits};
for (size_t i = 0; i < numQubits; ++i) {
// rotations to disentangle LSB
Expand Down Expand Up @@ -268,7 +268,7 @@ auto createStatePreparationCircuit(
}

// check if the number of elements in the vector is a power of two
if (amplitudes.size() == 0 ||
if (amplitudes.empty() ||
(amplitudes.size() & (amplitudes.size() - 1)) != 0) {
throw std::invalid_argument{
"Using State Preparation with vector size that is not a power of 2"};
Expand Down

0 comments on commit b91836f

Please sign in to comment.