mindquantum.io.random_hiqasm

View Source On Gitee
mindquantum.io.random_hiqasm(n_qubits, gate_num, version='0.1', seed=42)[source]

Generate random HiQASM supported circuit.

Parameters
  • n_qubits (int) – Total number of qubit in this quantum circuit.

  • gate_num (int) – Total number of gate in this quantum circuit.

  • version (str) – version of HIQASM. Default: '0.1'.

  • seed (int) – The random seed to generate this random quantum circuit. Default: 42.

Returns

str, quantum circuit in HIQASM format.

Examples

>>> from mindquantum.io import random_hiqasm
>>> from mindquantum.io import HiQASM
>>> HiQASM_str = random_hiqasm(2, 5)
>>> HiQASM = HiQASM()
>>> circuit = HiQASM.from_string(HiQASM_str)
>>> circuit
      ┏━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━┓ ┍━━━━━━┑
q0: ──┨ RZ(-2.5134) ┠─┨ RZ(-3.0123) ┠─┨ RX(0.7382) ┠─┤ M k0 ├─────────
      ┗━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━┛ ┗━━━━━━┳━━━━━┛ ┕━━━━━━┙
      ┏━━━┓                                  ┃       ┏━━━┓ ┍━━━━━━┑
q1: ──┨ S ┠──────────────────────────────────■───────┨ Z ┠─┤ M k1 ├───
      ┗━━━┛                                          ┗━━━┛ ┕━━━━━━┙