48 py::class_<SimulatorType>(m,
"PyQNLPSimulator")
49 .def(py::init<const std::size_t &, const bool &>())
50 .def(
"getGateX", &SimulatorType::getGateX, py::return_value_policy::reference)
51 .def(
"getGateY", &SimulatorType::getGateY, py::return_value_policy::reference)
52 .def(
"getGateZ", &SimulatorType::getGateZ, py::return_value_policy::reference)
53 .def(
"getGateI", &SimulatorType::getGateI, py::return_value_policy::reference)
54 .def(
"getGateH", &SimulatorType::getGateH, py::return_value_policy::reference)
55 .def(
"applyGateX", &SimulatorType::applyGateX)
56 .def(
"applyGateY", &SimulatorType::applyGateY)
57 .def(
"applyGateZ", &SimulatorType::applyGateZ)
58 .def(
"applyGateH", &SimulatorType::applyGateH)
59 .def(
"applyGateI", &SimulatorType::applyGateH)
60 .def(
"applyGateSqrtX", &SimulatorType::applyGateSqrtX)
61 .def(
"applyGateRotX", &SimulatorType::applyGateRotX)
62 .def(
"applyGateRotY", &SimulatorType::applyGateRotY)
63 .def(
"applyGateRotZ", &SimulatorType::applyGateRotZ)
64 .def(
"applyGateCRotX", &SimulatorType::applyGateCRotX)
65 .def(
"applyGateCRotY", &SimulatorType::applyGateCRotY)
66 .def(
"applyGateCRotZ", &SimulatorType::applyGateCRotZ)
67 .def(
"applyGateU", &SimulatorType::applyGateU)
68 .def(
"applyGateCU", &SimulatorType::applyGateCU)
69 .def(
"applyGateSwap", &SimulatorType::applyGateSwap)
70 .def(
"applyGateSqrtSwap", &SimulatorType::applyGateSqrtSwap)
71 .def(
"applyGatePhaseShift", &SimulatorType::applyGatePhaseShift)
72 .def(
"applyGateCPhaseShift", &SimulatorType::applyGateCPhaseShift)
73 .def(
"applyGateCX", &SimulatorType::applyGateCX)
74 .def(
"applyGateCCX", &SimulatorType::applyGateCCX)
75 .def(
"applyGateCSwap", &SimulatorType::applyGateCSwap)
76 .def(
"getNumQubits", &SimulatorType::getNumQubits)
77 .def(
"applyQFT", &SimulatorType::applyQFT)
78 .def(
"applyIQFT", &SimulatorType::applyIQFT)
79 .def(
"applyDiffusion", &SimulatorType::applyDiffusion)
80 .def(
"encodeToRegister", &SimulatorType::encodeToRegister)
81 .def(
"encodeBinToSuperpos_unique", &SimulatorType::encodeBinToSuperpos_unique)
82 .def(
"applyHammingDistanceRotY", &SimulatorType::applyHammingDistanceRotY)
83 .def(
"applyMeasurement", &SimulatorType::applyMeasurement)
84 .def(
"applyMeasurementToRegister", &SimulatorType::applyMeasurementToRegister)
85 .def(
"collapseToBasisZ", &SimulatorType::collapseToBasisZ)
86 .def(
"initRegister", &SimulatorType::initRegister)
87 .def(
"printStates", &SimulatorType::PrintStates, py::call_guard<py::scoped_ostream_redirect,py::scoped_estream_redirect>())
88 .def(
"applyGateNCU", &SimulatorType::applyGateNCU_nonlinear)
89 .def(
"applyGateNCU", &SimulatorType::applyGateNCU_5CX_Opt)
90 .def(
"addUToCache", &SimulatorType::addUToCache_U)
91 .def(
"subReg", &SimulatorType::subReg)
92 .def(
"sumReg", &SimulatorType::sumReg)
93 .def(
"applyOracleU", &SimulatorType::applyOracle_U)
94 .def(
"applyOracleU", &SimulatorType::applyOracle_Opt)
95 .def(
"getGateCounts", &SimulatorType::getGateCounts)
96 .def(
"applyOraclePhase", &SimulatorType::applyOraclePhase)
97 .def(
"groupQubits", &SimulatorType::groupQubits)
98 .def(
"overlap", &SimulatorType::computeOverlap)
99 .def(
"applyHammingDistanceOverwrite", &SimulatorType::applyHammingDistanceOverwrite);
107 py::class_<DCM>(m,
"DCMatrix")
109 .def(py::init([](std::vector<std::complex<double>> &values) {
123 [](
const DCM &s, std::size_t i, std::size_t j) {
124 if (i >= 2 || j >= 2)
125 throw py::index_error();
128 .def(
"__mul__", [](
const DCM &s0,
const DCM &
s1) {
130 m(0,0) = s0(0,0)*
s1(0,0) + s0(0,1)*
s1(1,0);
131 m(0,1) = s0(0,0)*
s1(1,0) + s0(0,1)*
s1(1,1);
132 m(1,0) = s0(1,0)*
s1(0,0) + s0(1,1)*
s1(1,0);
133 m(1,1) = s0(1,0)*
s1(1,0) + s0(1,1)*
s1(1,1);
136 .def(
"__rmul__", [](
const DCM &s0, std::complex<double> d1) {
144 .def(
"__mul__", [](
const DCM &s0, std::complex<double> d1) {
152 .def(
"__radd__", [](
const DCM &s0, std::complex<double> d1) {
160 .def(
"__add__", [](
const DCM &s0,
const DCM &
s1) {
168 .def(
"__sub__", [](
const DCM &s0,
const DCM &
s1) {
176 .def(
"adjoint", [](
const DCM &s0) {
179 .def(
"conjugate", [](
const DCM &s0) {
181 m(0,0) = std::conj(m(0,0));
182 m(0,1) = std::conj(m(0,1));
183 m(1,0) = std::conj(m(1,0));
184 m(1,1) = std::conj(m(1,1));
187 .def(
"transpose", [](
const DCM &s0) {
194 .def(
"as_numpy",[](
DCM &s0){
195 py::array_t<std::complex<double>> arr({ 2, 2 });
196 py::buffer_info arr_buff = arr.request();
197 std::complex<double>* ptr = (std::complex<double>*) arr_buff.ptr;
qhipster::TinyMatrix< std::complex< double >, 2u, 2u, 32u > DCM
Mat2x2Type adjointMatrix(const Mat2x2Type &U)
Function to calculate the adjoint of an input matrix.