paddle_quantum.qpp.qpp.utils

paddle_quantum.qpp.utils.qpp_cir(list_theta, list_phi, U)

Construct a quantum phase processor of QPP by list_theta and list_phi.

Parameters:
  • list_theta (ndarray | Tensor) – angles for \(R_Y\) gates.

  • list_phi (ndarray | Tensor) – angles for \(R_Z\) gates.

  • U (ndarray | Tensor | float) – unitary or scalar input.

Returns:

a multi-qubit version of trigonometric QSP.

Return type:

Circuit

paddle_quantum.qpp.utils.simulation_cir(fn, U, approx=True, deg=50, length=3.141592653589793, step_size=3.1415926535897935e-05, tol=1e-30)

Return a QPP circuit approximating fn.

Parameters:
  • fn (Callable[[ndarray], ndarray]) – function to be approximated.

  • U (ndarray | Tensor | float) – unitary input.

  • deg (int | None) – degree of approximation, defaults to be \(50\).

  • approx (bool | None) – whether approximately find the angle of circuits, defaults to be True

  • length (float | None) – half of approximation width, defaults to be \(\pi\).

  • step_size (float | None) – sampling frequency of data points, defaults to be \(0.00001 \pi\).

  • tol (float | None) – error tolerance, defaults to be \(10^{-30}\).

Returns:

//arxiv.org/abs/2209.14278.

Return type:

a QPP circuit approximating fn in Theorem 6 of paper https

paddle_quantum.qpp.utils.qps(U, initial_state)

Algorithm for quantum phase search, see Algorithm 1 and 2 of paper https://arxiv.org/abs/2209.14278.

Parameters:
  • U (ndarray | Tensor) – target unitary

  • initial_state (ndarray | Tensor | State) – the input quantum state

Returns:

  • an eigenphase of U

  • its corresponding eigenstate that has overlap with the initial state

Return type:

contains the following two elements

paddle_quantum.qpp.utils.qubitize(block_enc, num_block_qubits)

Qubitize the block encoding to keep subspace invariant using one more ancilla qubit, see paper http://arxiv.org/abs/1610.06546 for more details.

Parameters:
  • block_enc (ndarray | Tensor) – the target block encoding.

  • num_block_qubits (int) – number of ancilla qubits used in block encoding.

Returns:

the qubitized version for block_enc.

Return type:

Tensor

paddle_quantum.qpp.utils.purification_block_enc(num_qubits, num_block_qubits)

Randomly generate a \((n + m)\)-qubit qubitized block encoding of a \(n\)-qubit density matrix.

Parameters:
  • num_qubits (int) – number of qubits \(n\).

  • num_block_qubits (int) – number of ancilla qubits \(m > n\) used in block encoding.

Returns:

a \(2^{n + m} \times 2^{n + m}\) unitary matrix that its upper-left block is a density matrix.

Return type:

Tensor