mindquantum.core.operators.ground_state_of_sum_zz

View Source On Gitee
mindquantum.core.operators.ground_state_of_sum_zz(ops: QubitOperator, sim='mqvector')[source]

Find the ground state energy of qubit operator that only has pauli \(Z\) term.

Parameters
  • ops (QubitOperator) – qubit operator that only has pauli \(Z\) term.

  • sim (str) – use which simulator to do calculation. Currently, we support 'mqvector' and 'mqvector_gpu'. Default: 'mqvector'.

Returns

float, the ground state energy of given qubit operator.

Examples

>>> from mindquantum.core.operators import ground_state_of_sum_zz, QubitOperator
>>> h = QubitOperator('Z0 Z1', 1.0) + QubitOperator('Z0 Z2', -1.5)
>>> ground_state_of_sum_zz(h)
-2.5
>>> import numpy as np
>>> np.min(np.diag(h.matrix().toarray()))
(-2.5+0j)