diff --git a/exe/main.py b/exe/main.py index d40aa91..e8c76be 100644 --- a/exe/main.py +++ b/exe/main.py @@ -18,9 +18,17 @@ def main(): print(operator.to_json()) - states = StateVectorBatched(3, 3) + states = StateVectorBatched.Haar_random_state(2, 3) + prx = gate.ParamRX(0, 2.0, [1]) + pry = gate.ParamRY(1, 2.0, [2]) + params = { + "rx": [0.0, 0.1, 0.2], + "ry": [0.3, 0.4, 0.5] + } + circuit.add_param_gate(prx, "rx") + circuit.add_param_gate(pry, "ry") + circuit.update_quantum_state(states, params) print(states.to_json()) - if __name__ == "__main__": main() diff --git a/include/scaluq/circuit/circuit.hpp b/include/scaluq/circuit/circuit.hpp index 14b8596..653ded9 100644 --- a/include/scaluq/circuit/circuit.hpp +++ b/include/scaluq/circuit/circuit.hpp @@ -130,7 +130,8 @@ void bind_circuit_circuit_hpp(nb::module_& m) { nb::overload_cast&>(&Circuit::add_circuit), "Add all gates in specified circuit. Given gates are copied.") .def("update_quantum_state", - &Circuit::update_quantum_state, + static_cast::*)(StateVector&, const std::map&) + const>(&Circuit::update_quantum_state), "Apply gate to the StateVector. StateVector in args is directly updated. If the " "circuit contains parametric gate, you have to give real value of parameter as " "dict[str, float] in 2nd arg.") @@ -146,13 +147,11 @@ void bind_circuit_circuit_hpp(nb::module_& m) { "Apply gate to the StateVector. StateVector in args is directly updated. If the " "circuit contains parametric gate, you have to give real value of parameter as " "\"name=value\" format in kwargs.") - .def("update_quantum_state", - [](const Circuit& circuit, StateVector& state) { - circuit.update_quantum_state(state); - }) .def( "update_quantum_state", - &Circuit::update_quantum_state, + static_cast::*)(StateVectorBatched&, + const std::map>&) const>( + &Circuit::update_quantum_state), "Apply gate to the StateVectorBatched. StateVectorBatched in args is directly updated. " "If the circuit contains parametric gate, you have to give real value of parameter as " "dict[str, list[float]] in 2nd arg.") @@ -168,10 +167,6 @@ void bind_circuit_circuit_hpp(nb::module_& m) { "Apply gate to the StateVectorBatched. StateVectorBatched in args is directly updated. " "If the circuit contains parametric gate, you have to give real value of parameter as " "\"name=[value1, value2, ...]\" format in kwargs.") - .def("update_quantum_state", - [](const Circuit& circuit, StateVectorBatched& states) { - circuit.update_quantum_state(states); - }) .def("copy", &Circuit::copy, "Copy circuit. All the gates inside is copied.") .def("get_inverse", &Circuit::get_inverse,