Skip to content

Commit

Permalink
remove comment
Browse files Browse the repository at this point in the history
  • Loading branch information
lss0208 committed Feb 5, 2024
1 parent f722fd7 commit f0345be
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 160 deletions.
85 changes: 0 additions & 85 deletions src/qfvm/instructions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,91 +168,6 @@ class Cif : public Instruction{
virtual vector<pos_t> cbits() const override { return cbits_; }
};

// class QuantumOperator {
// protected:
// string name_;
// vector<pos_t> positions_;
// vector<double> paras_;
// uint control_num_;
// uint targe_num_;
// bool diag_;
// bool real_;
// RowMatrixXcd mat_;
// vector<pos_t> qbits_;
// vector<pos_t> cbits_;
// vector<QuantumOperator> instructions_;
// uint condition_;

// public:
// // Constructor
// QuantumOperator();
// QuantumOperator(string name, vector<pos_t> const& qbits);
// QuantumOperator(string name, vector<pos_t> const& qbits,
// vector<pos_t> const& cbits);
// QuantumOperator(string name, vector<pos_t> const& cbits, const uint condition,
// vector<QuantumOperator> const& ins);
// QuantumOperator(string name, vector<double> paras,
// vector<pos_t> const& control_qubits,
// vector<pos_t> const& targe_qubits, RowMatrixXcd const& mat,
// bool diag = false, bool real = false);
// QuantumOperator(string name, vector<double> paras,
// vector<pos_t> const& positions, uint control_num,
// RowMatrixXcd const& mat, bool diag = false,
// bool real = false);

// // data accessor
// string name() const { return name_; }
// vector<double> paras() const { return paras_; }
// bool has_control() const { return control_num_ == 0 ? false : true; }
// bool is_real() const { return real_; }
// bool is_diag() const { return diag_; }
// RowMatrixXcd mat() const { return mat_; }
// uint control_num() const { return control_num_; }
// uint targe_num() const { return targe_num_; }
// uint condition() const { return condition_; }
// vector<pos_t> positions() { return positions_; }
// explicit operator bool() const { return !(name_ == "empty"); }
// vector<pos_t> qbits() { return qbits_; }
// vector<pos_t> cbits() { return cbits_; }
// vector<QuantumOperator> instructions() { return instructions_; }
// // Apply method
// virtual void apply_to_state(StateVector<double>& state){};
// };

// QuantumOperator::QuantumOperator() : name_("empty"){};

// QuantumOperator::QuantumOperator(string name, vector<pos_t> const& qbits)
// : name_(name), targe_num_(0), qbits_(qbits) {}

// QuantumOperator::QuantumOperator(string name, vector<pos_t> const& qbits,
// vector<pos_t> const& cbits)
// : name_(name), targe_num_(0), qbits_(qbits), cbits_(cbits) {}

// QuantumOperator::QuantumOperator(string name, vector<pos_t> const& cbits,
// const uint condition,
// vector<QuantumOperator> const& ins)
// : name_(name), targe_num_(0), cbits_(cbits), instructions_(ins),
// condition_(condition) {}

// QuantumOperator::QuantumOperator(string name, vector<double> paras,
// vector<pos_t> const& positions,
// uint control_num, RowMatrixXcd const& mat,
// bool diag, bool real)
// : name_(name), paras_(paras), positions_(positions),
// control_num_(control_num), targe_num_(positions.size() - control_num),
// diag_(diag), real_(real), mat_(mat) {}

// QuantumOperator::QuantumOperator(string name, vector<double> paras,
// vector<pos_t> const& control_qubits,
// vector<pos_t> const& targe_qubits,
// RowMatrixXcd const& mat, bool diag, bool real)
// : name_(name), paras_(paras), diag_(diag), real_(real), mat_(mat) {
// positions_ = control_qubits;
// positions_.insert(positions_.end(), targe_qubits.begin(), targe_qubits.end());
// control_num_ = control_qubits.size();
// targe_num_ = targe_qubits.size();
// }


// Construct C++ operators from pygates
std::unique_ptr<Instruction> from_pyops(py::object const& obj, bool get_full_mat=false, bool reverse=true) {
Expand Down
75 changes: 0 additions & 75 deletions src/qfvm/qfvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,81 +136,6 @@ simulate_circuit(py::object const& pycircuit,
}
}
}



// //original version
// for (uint i = 0; i < actual_shots; i++) {
// StateVector<double> state;
// if (data_size == 0) {
// simulate(circuit, state);
// } else {
// // deepcopy state
// vector<std::complex<double>> buffer_ptr(data_ptr, data_ptr + data_size);
// state =
// std::move(StateVector<double>(buffer_ptr.data(), buffer_ptr.size()));
// simulate(circuit, state);
// }
// if (!circuit.final_measure()) {
// // store reg
// vector<uint> tmpcreg = state.creg();
// uint outcome = 0;
// for (uint j = 0; j < tmpcreg.size(); j++) {
// if (cbit_measured.find(j) == cbit_measured.end())
// continue;
// outcome *= 2;
// outcome += tmpcreg[j];
// }
// if (outcount.find(outcome) != outcount.end())
// outcount[outcome]++;
// else
// outcount[outcome] = 1;
// }
// if (circuit.final_measure() || i == actual_shots - 1)
// global_state = std::move(state);
// }
// // sample outcome if final_measure is true
// if (circuit.final_measure() && !measures.empty()) {
// vector<uint> tmpcount(global_state.size(), 0);
// vector<double> probs = global_state.probabilities();
// std::random_device rd;
// std::mt19937 global_rng(rd());
// for (uint i = 0; i < shots; i++) {
// uint outcome = std::discrete_distribution<uint>(probs.begin(),
// probs.end())(global_rng);
// tmpcount[outcome]++;
// }
// // map to reg
// for (uint i = 0; i < global_state.size(); i++) {
// if (tmpcount[i] == 0)
// continue;
// vector<uint> tmpcreg(global_state.cbit_num(), 0);
// vector<uint> tmpout = int2vec(i, 2);
// if (tmpout.size() < global_state.num())
// tmpout.resize(global_state.num());
// for (auto& pair : measures) {
// tmpcreg[pair.second] = tmpout[pair.first];
// }
// uint outcome = 0;
// for (uint j = 0; j < tmpcreg.size(); j++) {
// if (cbit_measured.find(j) == cbit_measured.end())
// continue;
// outcome *= 2;
// outcome += tmpcreg[j];
// }
// if (outcount.find(outcome) != outcount.end())
// outcount[outcome] += tmpcount[i];
// else
// outcount[outcome] = tmpcount[i];
// }
// }
// // return
// if (data_size == 0)
// return std::make_pair(outcount,
// to_numpy(global_state.move_data_to_python()));
// else
// return std::make_pair(outcount, np_inputstate);

}

std::map<uint, uint> simulate_circuit_clifford(py::object const& pycircuit,
Expand Down

0 comments on commit f0345be

Please sign in to comment.