mindquantum.simulator.inner_product

View Source On Gitee
mindquantum.simulator.inner_product(bra_simulator: Simulator, ket_simulator: Simulator)[source]

Calculate the inner product of two state that in the given simulator.

Parameters
  • bra_simulator (Simulator) – The simulator that serve as bra state.

  • ket_simulator (Simulator) – The simulator that serve as ket state.

Returns

numbers.Number, the inner product of two quantum state.

Examples

>>> from mindquantum.core.gates import RX, RY
>>> from mindquantum.simulator import inner_product, Simulator
>>> bra_simulator = Simulator('mqvector', 1)
>>> bra_simulator.apply_gate(RY(1.2).on(0))
>>> ket_simulator = Simulator('mqvector', 1)
>>> ket_simulator.apply_gate(RX(2.3).on(0))
>>> inner_product(bra_simulator, ket_simulator)
(0.33713923320500694-0.5153852888544989j)