From 9f32502ca4a2b8c2e8b39e91f929c3c86d491f17 Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Thu, 22 Aug 2024 12:02:44 +0900 Subject: [PATCH] lint --- src/noise/noise_model.hpp | 23 ++++++++++------------ src/simulators/circuit_executor.hpp | 23 ++++++++++------------ src/simulators/parallel_state_executor.hpp | 5 +++-- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/noise/noise_model.hpp b/src/noise/noise_model.hpp index 870b028439..1fccba785c 100644 --- a/src/noise/noise_model.hpp +++ b/src/noise/noise_model.hpp @@ -286,8 +286,7 @@ Circuit NoiseModel::sample_noise(const Circuit &circ, RngEngine &rng, return sample_noise_circuit(circ, rng, method, sample_at_runtime); } -void NoiseModel::set_config(const Circuit &circ, const Method method) const -{ +void NoiseModel::set_config(const Circuit &circ, const Method method) const { // Qubit mapping reg_t mapping; if (circ.remapped_qubits) @@ -395,7 +394,8 @@ Circuit NoiseModel::sample_noise_circuit(const Circuit &circ, RngEngine &rng, default: if (noise_active) { NoiseOps noisy_op = - sample_noise_op(op, rng, method, mapping, sample_at_runtime, (circ.num_bind_params > 0)); + sample_noise_op(op, rng, method, mapping, sample_at_runtime, + (circ.num_bind_params > 0)); noisy_circ.ops.insert(noisy_circ.ops.end(), noisy_op.begin(), noisy_op.end()); } @@ -412,14 +412,12 @@ Circuit NoiseModel::sample_noise_circuit(const Circuit &circ, RngEngine &rng, return noisy_circ; } -NoiseModel::NoiseOps NoiseModel::sample_noise_op(const Operations::Op &op, - RngEngine &rng, - const Method method, - const reg_t &mapping, - bool sample_at_runtime, - bool param_bind) const { - auto noise_ops = - sample_noise_helper(op, rng, method, mapping, sample_at_runtime, param_bind); +NoiseModel::NoiseOps +NoiseModel::sample_noise_op(const Operations::Op &op, RngEngine &rng, + const Method method, const reg_t &mapping, + bool sample_at_runtime, bool param_bind) const { + auto noise_ops = sample_noise_helper(op, rng, method, mapping, + sample_at_runtime, param_bind); // If original op is conditional, make all the noise operations also // conditional @@ -565,8 +563,7 @@ void NoiseModel::add_nonlocal_quantum_error( NoiseModel::NoiseOps NoiseModel::sample_noise_helper(const Operations::Op &op, RngEngine &rng, const Method method, const reg_t &mapping, - bool sample_at_runtime, - bool param_bind) const { + bool sample_at_runtime, bool param_bind) const { // Return operator set NoiseOps noise_before; NoiseOps noise_after; diff --git a/src/simulators/circuit_executor.hpp b/src/simulators/circuit_executor.hpp index 92618f4c62..ddfee144c1 100644 --- a/src/simulators/circuit_executor.hpp +++ b/src/simulators/circuit_executor.hpp @@ -803,9 +803,9 @@ void Executor::run_circuit_with_sampling(Circuit &circ, state.initialize_creg(circ.num_memory, circ.num_registers); if (circ.num_bind_params > 1) { - run_circuit_with_parameter_binding(state, circ.ops.cbegin(), - circ.ops.cbegin() + first_meas, - result, rng, iparam, nullptr, false, final_ops); + run_circuit_with_parameter_binding( + state, circ.ops.cbegin(), circ.ops.cbegin() + first_meas, result, + rng, iparam, nullptr, false, final_ops); } else { state.apply_ops(circ.ops.cbegin(), circ.ops.cbegin() + first_meas, result, rng, final_ops); @@ -848,11 +848,10 @@ void Executor::run_circuit_shots( int max_matrix_qubits = 1; if (sample_noise) { - if(circ.num_bind_params > 1){ + if (circ.num_bind_params > 1) { noise.set_config(circ, Noise::NoiseModel::Method::circuit); } - } - else { + } else { Noise::NoiseModel dummy_noise; state_t dummy_state; ExperimentResult fusion_result; @@ -935,8 +934,8 @@ void Executor::run_circuit_shots( if (circ.num_bind_params > 1) { run_circuit_with_parameter_binding(state, circ.ops.cbegin(), - circ.ops.cend(), result, rng, - iparam, &noise, sample_noise, true); + circ.ops.cend(), result, rng, iparam, + &noise, sample_noise, true); } else { if (sample_noise) { state.apply_ops(circ_opt.ops.cbegin(), circ_opt.ops.cend(), result, @@ -1013,14 +1012,12 @@ void Executor::run_circuit_with_parameter_binding( // run with parameter bind if (op->has_bind_params) { top = Operations::bind_parameter(*op, iparam, num_bind_params_); - } - else{ + } else { top = *op; } - if(sample_noise){ + if (sample_noise) { ops = noise->sample_noise_at_runtime(top, rng); - } - else{ + } else { ops.push_back(top); } state.apply_ops(ops.cbegin(), ops.cend(), result, rng, diff --git a/src/simulators/parallel_state_executor.hpp b/src/simulators/parallel_state_executor.hpp index d375e4859c..61658ae149 100644 --- a/src/simulators/parallel_state_executor.hpp +++ b/src/simulators/parallel_state_executor.hpp @@ -924,8 +924,9 @@ void ParallelStateExecutor::apply_cache_blocking_ops( // fecth chunk in cache if (Base::states_[iChunk].qreg().fetch_chunk()) { if (Base::num_bind_params_ > 1) { - Base::run_circuit_with_parameter_binding( - Base::states_[iChunk], first, last, result, rng, iparam, nullptr, false, false); + Base::run_circuit_with_parameter_binding(Base::states_[iChunk], first, + last, result, rng, iparam, + nullptr, false, false); } else { Base::states_[iChunk].apply_ops(first, last, result, rng, false); }