Skip to content

Commit

Permalink
manually format codes that were not covered in black and clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
hhorii committed Mar 10, 2023
1 parent 1dafc1b commit b272aea
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/controllers/aer_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ Result Controller::execute(std::vector<Circuit> &circuits,
const int NUM_RESULTS = result.results.size();
// following looks very similar but we have to separate them to avoid omp
// nested loops that causes performance degradation (DO NOT use if statement
//in #pragma omp)
// in #pragma omp)
if (parallel_experiments_ == 1) {
for (int j = 0; j < NUM_RESULTS; ++j) {
set_parallelization_circuit(circuits[j], noise_model, methods[j]);
Expand Down
1 change: 1 addition & 0 deletions src/framework/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef _aer_framework_config_hpp_
#define _aer_framework_config_hpp_

#include "json.hpp"
#include "types.hpp"
#include <optional>
#include <string>
Expand Down
10 changes: 6 additions & 4 deletions src/open_pulse/eval_hamiltonian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#ifndef _EVAL_HAMILTONIAN_HPP
#define _EVAL_HAMILTONIAN_HPP

#include "framework/types.hpp"
#include "iterators.hpp"
#include "misc/warnings.hpp"
#include <complex>
#include <string>
Expand Down Expand Up @@ -42,10 +44,10 @@ struct hash<ParserValues> {
} // namespace std

// TODO: Document
complex_t evaluate_hamiltonian_expression(
AER::complex_t evaluate_hamiltonian_expression(
const std::string &expr_string, const std::vector<double> &vars,
const std::vector<std::string> &vars_names,
const std::unordered_map<std::string, complex_t> &chan_values) {
const std::unordered_map<std::string, AER::complex_t> &chan_values) {

static std::unordered_map<std::string, std::unique_ptr<ParserValues>>
parser_expr;
Expand Down Expand Up @@ -75,7 +77,7 @@ complex_t evaluate_hamiltonian_expression(
// std::cout << "Getting parser " << std::hex << parser << "\n";

auto maybe_update_value = [parser](const std::string &var_name,
const complex_t &var_value) {
const AER::complex_t &var_value) {
if (parser->var_values.find(var_name) == parser->var_values.end()) {
parser->var_values.emplace(var_name,
std::make_unique<mup::Value>(var_value));
Expand All @@ -93,7 +95,7 @@ complex_t evaluate_hamiltonian_expression(

for (const auto &idx_var : enumerate(vars)) {
size_t index = idx_var.first;
auto var_value = static_cast<complex_t>(idx_var.second);
auto var_value = static_cast<AER::complex_t>(idx_var.second);
maybe_update_value(vars_names[index], var_value);
}

Expand Down
10 changes: 5 additions & 5 deletions src/simulators/matrix_product_state/matrix_product_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,14 @@ const stringmap_t<Gates>
{"rx", Gates::rx}, // Pauli-X rotation gate
{"ry", Gates::ry}, // Pauli-Y rotation gate
{"rz", Gates::rz}, // Pauli-Z rotation gate
// Waltz Gates
/* Waltz Gates */
{"p", Gates::u1}, // zero-X90 pulse waltz gate
{"u1", Gates::u1}, // zero-X90 pulse waltz gate
{"u2", Gates::u2}, // single-X90 pulse waltz gate
{"u3", Gates::u3}, // two X90 pulse waltz gate
{"u", Gates::u3}, // two X90 pulse waltz gate
{"U", Gates::u3}, // two X90 pulse waltz gate
// Two-qubit gates
/* Two-qubit gates */
{"CX", Gates::cx}, // Controlled-X gate (CNOT)
{"cx", Gates::cx}, // Controlled-X gate (CNOT)
{"cy", Gates::cy}, // Controlled-Y gate
Expand All @@ -294,10 +294,10 @@ const stringmap_t<Gates>
{"ryy", Gates::ryy}, // Pauli-YY rotation gate
{"rzz", Gates::rzz}, // Pauli-ZZ rotation gate
{"rzx", Gates::rzx}, // Pauli-ZX rotation gate
// Three-qubit gates
/* Three-qubit gates */
{"ccx", Gates::ccx}, // Controlled-CX gate (Toffoli)
{"cswap", Gates::cswap},
// Pauli
/* Pauli */
{"pauli", Gates::pauli}});

//=========================================================================
Expand Down Expand Up @@ -813,4 +813,4 @@ std::pair<uint_t, double> State::sample_measure_with_prob(const reg_t &qubits,
//-------------------------------------------------------------------------
} // end namespace AER
//-------------------------------------------------------------------------
#endif
#endif
21 changes: 11 additions & 10 deletions src/simulators/matrix_product_state/matrix_product_state_tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,11 @@ void MPS_Tensor::contract_2_dimensions(const MPS_Tensor &left_gamma,
(omp_threads > 1)) \
num_threads(omp_threads)
#endif
for (int_t l_row = 0; l_row < left_rows; l_row++)
for (int_t r_col = 0; r_col < right_columns; r_col++)
for (int_t l_row = 0; l_row < left_rows; l_row++) {
for (int_t r_col = 0; r_col < right_columns; r_col++) {
result(l_row, r_col) = 0;
}
}

#ifdef _WIN32
#pragma omp parallel for if ((omp_limit > MATRIX_OMP_THRESHOLD) && \
Expand All @@ -568,24 +570,23 @@ void MPS_Tensor::contract_2_dimensions(const MPS_Tensor &left_gamma,
(omp_threads > 1)) \
num_threads(omp_threads)
#endif
for (int_t l_row = 0; l_row < left_rows; l_row++)
for (int_t l_row = 0; l_row < left_rows; l_row++) {
for (int_t r_col = 0; r_col < right_columns; r_col++) {

for (int_t size = 0; size < left_size; size++)
for (int_t index = 0; index < left_columns; index++) {
result(l_row, r_col) += left_gamma.data_[size](l_row, index) *
right_gamma.data_[size](index, r_col);
}
}
}
}
//---------------------------------------------------------------
// function name: Decompose
// Description: Decompose a tensor into two Gamma tensors and the Lambda between
// them. Usually used after applying a 2-qubit
// gate. Parameters: MPS_Tensor &temp - the tensor to decompose.
// MPS_Tensor &left_gamma, &right_gamma , rvector_t &lambda
//-
// tensors for the result.
// Description: Decompose a tensor into two Gamma tensors and the
// Lambda between them. Usually used after applying a 2-qubit gate.
// Parameters: MPS_Tensor &temp - the tensor to decompose.
// MPS_Tensor &left_gamma, &right_gamma
// rvector_t &lambda - tensors for the result.
// Returns: none.
//---------------------------------------------------------------
double MPS_Tensor::Decompose(MPS_Tensor &temp, MPS_Tensor &left_gamma,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ namespace Chunk {
template <typename data_t>
class cuStateVecChunkContainer : public DeviceChunkContainer<data_t> {
protected:
custatevecHandle_t
custatevec_handle_; // cuStatevec handle for this chunk container
custatevecHandle_t custatevec_handle_; // cuStatevec handle
// for this chunk container
uint_t custatevec_chunk_total_qubits_; // total qubits of statevector passed
// to ApplyMatrix
uint_t custatevec_chunk_count_; // number of counts for all chunks
uint_t custatevec_chunk_count_; // number of counts for all chunks

custatevecDeviceMemHandler_t custatevec_mem_handler_;
cudaMemPool_t memory_pool_;
Expand Down
10 changes: 5 additions & 5 deletions src/simulators/statevector/statevector_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,18 +347,18 @@ const stringmap_t<Gates> State<statevec_t>::gateset_(
{"p", Gates::mcp}, // Parameterized phase gate
{"sx", Gates::mcsx}, // Sqrt(X) gate
{"sxdg", Gates::mcsxdg}, // Inverse Sqrt(X) gate
// 1-qubit rotation Gates
/* 1-qubit rotation Gates */
{"r", Gates::mcr}, // R rotation gate
{"rx", Gates::mcrx}, // Pauli-X rotation gate
{"ry", Gates::mcry}, // Pauli-Y rotation gate
{"rz", Gates::mcrz}, // Pauli-Z rotation gate
// Waltz Gates
/* Waltz Gates */
{"u1", Gates::mcp}, // zero-X90 pulse waltz gate
{"u2", Gates::mcu2}, // single-X90 pulse waltz gate
{"u3", Gates::mcu3}, // two X90 pulse waltz gate
{"u", Gates::mcu3}, // two X90 pulse waltz gate
{"U", Gates::mcu3}, // two X90 pulse waltz gate
// 2-qubit gates
/* 2-qubit gates */
{"CX", Gates::mcx}, // Controlled-X gate (CNOT)
{"cx", Gates::mcx}, // Controlled-X gate (CNOT)
{"cy", Gates::mcy}, // Controlled-Y gate
Expand All @@ -377,10 +377,10 @@ const stringmap_t<Gates> State<statevec_t>::gateset_(
{"csx", Gates::mcsx}, // Controlled-Sqrt(X) gate
{"csxdg", Gates::mcsxdg}, // Controlled-Sqrt(X)dg gate
{"ecr", Gates::ecr}, // ECR Gate
// 3-qubit gates
/* 3-qubit gates */
{"ccx", Gates::mcx}, // Controlled-CX gate (Toffoli)
{"cswap", Gates::mcswap}, // Controlled SWAP gate (Fredkin)
// Multi-qubit controlled gates
/* Multi-qubit controlled gates */
{"mcx", Gates::mcx}, // Multi-controlled-X gate
{"mcy", Gates::mcy}, // Multi-controlled-Y gate
{"mcz", Gates::mcz}, // Multi-controlled-Z gate
Expand Down
2 changes: 1 addition & 1 deletion src/simulators/tensor_network/tensor_net.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class TensorNet {
int32_t mode_index_; // index of modes
std::vector<std::shared_ptr<Tensor<data_t>>> tensors_; // list of tensors
std::vector<std::shared_ptr<Tensor<data_t>>> qubits_; // tail tensor for
// qubits
// qubits
std::vector<std::shared_ptr<Tensor<data_t>>>
qubits_sp_; // tail tensor for super qubits
std::vector<int32_t> modes_qubits_; // tail mode index for qubits
Expand Down
10 changes: 5 additions & 5 deletions src/simulators/tensor_network/tensor_net_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,18 +330,18 @@ const stringmap_t<Gates> State<tensor_net_t>::gateset_(
{"p", Gates::mcp}, // Parameterized phase gate
{"sx", Gates::mcsx}, // Sqrt(X) gate
{"sxdg", Gates::mcsxdg}, // Inverse Sqrt(X) gate
// 1-qubit rotation Gates
/* 1-qubit rotation Gates */
{"r", Gates::mcr}, // R rotation gate
{"rx", Gates::mcrx}, // Pauli-X rotation gate
{"ry", Gates::mcry}, // Pauli-Y rotation gate
{"rz", Gates::mcrz}, // Pauli-Z rotation gate
// Waltz Gates
/* Waltz Gates */
{"u1", Gates::mcp}, // zero-X90 pulse waltz gate
{"u2", Gates::mcu2}, // single-X90 pulse waltz gate
{"u3", Gates::mcu3}, // two X90 pulse waltz gate
{"u", Gates::mcu3}, // two X90 pulse waltz gate
{"U", Gates::mcu3}, // two X90 pulse waltz gate
// 2-qubit gates
/* 2-qubit gates */
{"CX", Gates::mcx}, // Controlled-X gate (CNOT)
{"cx", Gates::mcx}, // Controlled-X gate (CNOT)
{"cy", Gates::mcy}, // Controlled-Y gate
Expand All @@ -360,10 +360,10 @@ const stringmap_t<Gates> State<tensor_net_t>::gateset_(
{"csx", Gates::mcsx}, // Controlled-Sqrt(X) gate
{"csxdg", Gates::mcsxdg}, // Controlled-Sqrt(X)dg gate
{"ecr", Gates::ecr}, // ECR Gate
// 3-qubit gates
/* 3-qubit gates */
{"ccx", Gates::mcx}, // Controlled-CX gate (Toffoli)
{"cswap", Gates::mcswap}, // Controlled SWAP gate (Fredkin)
// Multi-qubit controlled gates
/* Multi-qubit controlled gates */
{"mcx", Gates::mcx}, // Multi-controlled-X gate
{"mcy", Gates::mcy}, // Multi-controlled-Y gate
{"mcz", Gates::mcz}, // Multi-controlled-Z gate
Expand Down

0 comments on commit b272aea

Please sign in to comment.