Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
KowerKoint committed Sep 3, 2024
1 parent b8490d9 commit 3c5bfd0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 6 additions & 3 deletions scaluq/operator/apply_pauli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ void apply_pauli(std::uint64_t control_mask,
if (bit_flip_mask == 0) {
Kokkos::parallel_for(
state_vector.dim() >> std::popcount(control_mask), KOKKOS_LAMBDA(std::uint64_t i) {
std::uint64_t state_idx = insert_zero_at_mask_positions(i, control_mask) | control_mask;
std::uint64_t state_idx =
insert_zero_at_mask_positions(i, control_mask) | control_mask;
if (Kokkos::popcount(state_idx & phase_flip_mask) & 1) {
state_vector._raw[state_idx] *= -coef;
} else {
Expand Down Expand Up @@ -57,7 +58,8 @@ void apply_pauli_rotation(std::uint64_t control_mask,
const Complex cval_pls = cosval + Complex(0, 1) * sinval;
Kokkos::parallel_for(
state_vector.dim() >> std::popcount(control_mask), KOKKOS_LAMBDA(std::uint64_t i) {
std::uint64_t state_idx = insert_zero_at_mask_positions(i, control_mask) | control_mask;
std::uint64_t state_idx =
insert_zero_at_mask_positions(i, control_mask) | control_mask;
if (Kokkos::popcount(state_idx & phase_flip_mask) & 1) {
state_vector._raw[state_idx] *= cval_min;
} else {
Expand All @@ -69,7 +71,8 @@ void apply_pauli_rotation(std::uint64_t control_mask,
} else {
std::uint64_t pivot = sizeof(std::uint64_t) * 8 - std::countl_zero(bit_flip_mask) - 1;
Kokkos::parallel_for(
state_vector.dim() >> (std::popcount(control_mask) + 1), KOKKOS_LAMBDA(std::uint64_t i) {
state_vector.dim() >> (std::popcount(control_mask) + 1),
KOKKOS_LAMBDA(std::uint64_t i) {
std::uint64_t basis_0 =
internal::insert_zero_at_mask_positions(i, control_mask | 1ULL << pivot) |
control_mask;
Expand Down
7 changes: 5 additions & 2 deletions scaluq/operator/pauli_operator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class PauliOperator {
void add_single_pauli(std::uint64_t target_qubit, std::uint64_t pauli_id);
Complex get_coef() const { return _coef; }
void set_coef(Complex c) { _coef = c; }
const std::vector<std::uint64_t>& get_target_qubit_list() const { return _target_qubit_list; }
const std::vector<std::uint64_t>& get_target_qubit_list() const {
return _target_qubit_list;
}
const std::vector<std::uint64_t>& get_pauli_id_list() const { return _pauli_id_list; }
std::tuple<std::uint64_t, std::uint64_t> get_XZ_mask_representation() const {
return {_bit_flip_mask, _phase_flip_mask};
Expand Down Expand Up @@ -63,7 +65,8 @@ class PauliOperator {
[[nodiscard]] inline const std::vector<std::uint64_t>& get_pauli_id_list() const {
return _ptr->get_pauli_id_list();
}
[[nodiscard]] inline std::tuple<std::uint64_t, std::uint64_t> get_XZ_mask_representation() const {
[[nodiscard]] inline std::tuple<std::uint64_t, std::uint64_t> get_XZ_mask_representation()
const {
return _ptr->get_XZ_mask_representation();
}
[[nodiscard]] std::string get_pauli_string() const;
Expand Down

0 comments on commit 3c5bfd0

Please sign in to comment.