From 2643be6dca684d5de0c42e6aff7c068701fb18c0 Mon Sep 17 00:00:00 2001 From: Eugene Rublenko <16805621+stand-by@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:21:51 -0500 Subject: [PATCH] Address comments --- fast_pauli/cpp/include/__summed_pauli_op.hpp | 14 ++++++++------ fast_pauli/cpp/src/fast_pauli.cpp | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/fast_pauli/cpp/include/__summed_pauli_op.hpp b/fast_pauli/cpp/include/__summed_pauli_op.hpp index b00693f..ef88eb2 100644 --- a/fast_pauli/cpp/include/__summed_pauli_op.hpp +++ b/fast_pauli/cpp/include/__summed_pauli_op.hpp @@ -620,15 +620,17 @@ template struct SummedPauliOp */ std::vector> split() const { - std::vector> op_coeffs(n_pauli_strings()); - std::vector> ops; - ops.reserve(n_operators()); + std::vector> ops(n_operators()); - for (size_t k = 0; k < n_operators(); k++) +#pragma omp parallel for schedule(static) + for (size_t k = 0; k < n_operators(); ++k) { - for (size_t i = 0; i < n_pauli_strings(); i++) + std::vector> op_coeffs(n_pauli_strings()); + + for (size_t i = 0; i < n_pauli_strings(); ++i) op_coeffs[i] = coeffs(i, k); - ops.push_back(PauliOp(op_coeffs, pauli_strings)); + + ops[k] = PauliOp(std::move(op_coeffs), this->pauli_strings); } return ops; diff --git a/fast_pauli/cpp/src/fast_pauli.cpp b/fast_pauli/cpp/src/fast_pauli.cpp index afe62ef..5c4fa40 100644 --- a/fast_pauli/cpp/src/fast_pauli.cpp +++ b/fast_pauli/cpp/src/fast_pauli.cpp @@ -1029,7 +1029,7 @@ np.ndarray )%") .def_prop_ro( "pauli_strings", [](fp::SummedPauliOp const &self) { return self.pauli_strings; }, - "List[PauliString]: Ordered list of PauliString objects in SummedPauliOp") + "List[PauliString]: The list of PauliString objects corresponding to coefficients in SummedPauliOp") .def_prop_ro( "pauli_strings_as_str", [](fp::SummedPauliOp const &self) { @@ -1038,7 +1038,7 @@ np.ndarray [](fp::PauliString const &ps) { return fmt::format("{}", ps); }); return strings; }, - "List[str]: Ordered list of Pauli Strings representations from SummedPauliOp") + "List[str]: The list of Pauli Strings representations corresponding to coefficients from SummedPauliOp") .def( "apply",