diff --git a/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/GateFunctorsParam.hpp b/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/GateFunctorsParam.hpp index 06939e83c6..a6f5486d4c 100644 --- a/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/GateFunctorsParam.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/GateFunctorsParam.hpp @@ -22,8 +22,9 @@ /// @cond DEV namespace { using namespace Pennylane::Util; -using namespace Pennylane::LightningKokkos::Util; // one using Kokkos::Experimental::swap; +using Pennylane::LightningKokkos::Util::one; +using Pennylane::LightningKokkos::Util::wires2Parity; using std::size_t; } // namespace /// @endcond diff --git a/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/tests/CMakeLists.txt b/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/tests/CMakeLists.txt index 067c89b0d5..51ea141c06 100644 --- a/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/tests/CMakeLists.txt +++ b/pennylane_lightning/core/src/simulators/lightning_kokkos/gates/tests/CMakeLists.txt @@ -20,6 +20,7 @@ target_link_libraries(lightning_kokkos_gates_tests INTERFACE Catch2::Catch2 lightning_kokkos_measurements lightning_kokkos_observables lightning_kokkos + lightning_kokkos_utils ) ProcessTestOptions(lightning_kokkos_gates_tests) diff --git a/pennylane_lightning/core/src/simulators/lightning_kokkos/measurements/ExpValFunctors.hpp b/pennylane_lightning/core/src/simulators/lightning_kokkos/measurements/ExpValFunctors.hpp index a151f0184f..3327929caa 100644 --- a/pennylane_lightning/core/src/simulators/lightning_kokkos/measurements/ExpValFunctors.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_kokkos/measurements/ExpValFunctors.hpp @@ -20,7 +20,8 @@ /// @cond DEV namespace { using namespace Pennylane::Util; -using namespace Pennylane::LightningKokkos::Util; // one +using Pennylane::LightningKokkos::Util::one; +using Pennylane::LightningKokkos::Util::wires2Parity; } // namespace /// @endcond diff --git a/pennylane_lightning/core/src/simulators/lightning_kokkos/utils/BitUtilKokkos.hpp b/pennylane_lightning/core/src/simulators/lightning_kokkos/utils/BitUtilKokkos.hpp index be2f88a937..1721c1cb3e 100644 --- a/pennylane_lightning/core/src/simulators/lightning_kokkos/utils/BitUtilKokkos.hpp +++ b/pennylane_lightning/core/src/simulators/lightning_kokkos/utils/BitUtilKokkos.hpp @@ -30,25 +30,26 @@ using KokkosIntVector = Kokkos::View; namespace Pennylane::LightningKokkos::Util { -inline constexpr std::size_t one{1}; +constexpr std::size_t one{1}; /** - * @brief Faster log2 when the value is a power of 2. + * @brief Compute the parities and shifts for multi-qubit operations. * - * @param val Size of the state vector. Expected to be a power of 2. - * @return size_t Log2(val), or the state vector's number of qubits. + * @param num_qubits Number of qubits in the state vector. + * @param wires List of target wires. + * @return std::pair Parities and shifts for + * multi-qubit operations. */ -std::pair -wires2Parity(const std::size_t num_qubits, - const std::vector &wires_) { - constexpr std::size_t one{1}; +inline auto wires2Parity(const std::size_t num_qubits, + const std::vector &wires) + -> std::pair { KokkosIntVector parity; KokkosIntVector rev_wire_shifts; - std::vector rev_wires_(wires_.size()); - std::vector rev_wire_shifts_(wires_.size()); - for (std::size_t k = 0; k < wires_.size(); k++) { - rev_wires_[k] = (num_qubits - 1) - wires_[(wires_.size() - 1) - k]; + std::vector rev_wires_(wires.size()); + std::vector rev_wire_shifts_(wires.size()); + for (std::size_t k = 0; k < wires.size(); k++) { + rev_wires_[k] = (num_qubits - 1) - wires[(wires.size() - 1) - k]; rev_wire_shifts_[k] = (one << rev_wires_[k]); } const std::vector parity_ = revWireParity(rev_wires_);