Skip to content

Commit

Permalink
[feature/SPO_apply] Small fixes, include <chrono> in the examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesETsmith committed Nov 1, 2024
1 parent 9322d78 commit 3d0c2bf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 8 additions & 7 deletions fast_pauli/cpp/examples/03_summed_pauli_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#include <algorithm>
#include <chrono>
#include <experimental/mdspan>
#include <random>

Expand All @@ -28,10 +29,10 @@ int main()
// User settings
//
size_t const n_operators = 1000;
size_t const n_qubits = 10;
size_t const n_qubits = 12;
size_t const weight = 2;
size_t const n_states = 1000;
using fp_type = double;
using fp_type = float;

//
// Setup the summed pauli operator
Expand Down Expand Up @@ -63,11 +64,11 @@ int main()
//
// Apply the states
//
auto start_seq = std::chrono::high_resolution_clock::now();
summed_op.apply_weighted(std::execution::seq, new_states, states, weights);
auto end_seq = std::chrono::high_resolution_clock::now();
fmt::println("Time taken for sequential execution: {} seconds",
std::chrono::duration_cast<std::chrono::seconds>(end_seq - start_seq).count());
// auto start_seq = std::chrono::high_resolution_clock::now();
// summed_op.apply_weighted(std::execution::seq, new_states, states, weights);
// auto end_seq = std::chrono::high_resolution_clock::now();
// fmt::println("Time taken for sequential execution: {} seconds",
// std::chrono::duration_cast<std::chrono::seconds>(end_seq - start_seq).count());

auto start_par = std::chrono::high_resolution_clock::now();
summed_op.apply_weighted(std::execution::par, new_states, states, weights);
Expand Down
6 changes: 3 additions & 3 deletions fast_pauli/cpp/include/__pauli_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ std::vector<PauliString> calcutate_pauli_strings(size_t const n_qubits, size_t c
size_t n_pauli_strings = nontrivial_paulis.size() * idx_combos.size();
std::vector<PauliString> result(n_pauli_strings);

fmt::println("n_qubits = {} weight = {} n_nontrivial_paulis = {} n_combos = {}", n_qubits, weight,
nontrivial_paulis.size(), idx_combos.size());
// fmt::println("n_qubits = {} weight = {} n_nontrivial_paulis = {} n_combos = {}", n_qubits, weight,
// nontrivial_paulis.size(), idx_combos.size());

// Iterate through all the nontrivial paulis and all the combinations
for (size_t i = 0; i < nontrivial_paulis.size(); ++i)
Expand Down Expand Up @@ -153,7 +153,7 @@ std::vector<PauliString> calculate_pauli_strings_max_weight(size_t n_qubits, siz
result.insert(result.end(), ps.begin(), ps.end());
}

fmt::println("n_qubits = {} weight = {} n_pauli_strings = {}", n_qubits, weight, result.size());
// fmt::println("n_qubits = {} weight = {} n_pauli_strings = {}", n_qubits, weight, result.size());
return result;
}

Expand Down

0 comments on commit 3d0c2bf

Please sign in to comment.