paddle_quantum.qsvt.qsp

paddle_quantum.qsvt.qsp.signal_unitary(signal_x)

signal unitary \(W(x)\) in paper https://arxiv.org/abs/1806.01838

Parameters:

signal_x (float) – variable x in [-1, 1]

Returns:

matrix W(x = x)

Return type:

ndarray

paddle_quantum.qsvt.qsp.poly_parity_verification(poly_p, k, error=1e-06)

verify whether \(P\) has parity-(k mod 2), i.e., the second condition of theorem 3 holds

Parameters:
  • poly_p (Polynomial) – polynomial \(P(x)\)

  • k (int) – parameter that determine parity

  • error (float) – tolerated error, defaults to 1e-6

Returns:

determine whether \(P\) has parity-(k mod 2)

Return type:

bool

paddle_quantum.qsvt.qsp.normalization_verification(poly_p, poly_q, trials=10, error=0.01)

verify whether polynomials \(P(x)\) and \(Q(x)\) satisfy the normalization condition \(|P|^2 + (1 - x^2)|Q|^2 = 1\), i.e., the third condition of Theorem 3.

Parameters:
  • poly_p (Polynomial) – polynomial \(P(x)\)

  • poly_q (Polynomial) – polynomial \(Q(x)\)

  • trials (int) – number of tests, defaults to 10

  • error (float) – tolerated error, defaults to 1e-2

Returns:

determine whether \(|P|^2 + (1 - x^2)|Q|^2 = 1\)

Return type:

bool

paddle_quantum.qsvt.qsp.angle_phi_verification(phi, poly_p, poly_p_hat, poly_q_hat, trials=10, error=0.01)

verify \(\phi\) during the iteration of finding \(\Phi\)

Parameters:
  • phi (float) – rotation angle \(\phi\)

  • poly_p (Polynomial) – polynomial \(P(x)\)

  • poly_p_hat (Polynomial) – updated polynomial \(\hat{P}\)

  • poly_q_hat (Polynomial) – updated polynomial \(\hat{Q}\)

  • trials (int) – number of tests, defaults to 10

  • error (float) – tolerated error, defaults to 0.01

Returns:

//arxiv.org/abs/1806.01838 holds

Return type:

determine whether the equation (6) in paper https

paddle_quantum.qsvt.qsp.processing_unitary(list_matrices, signal_x)

processing unitary \(W_\Phi(x)\), see equation 1 in paper https://arxiv.org/abs/1806.01838

Parameters:
  • list_matrices (List[ndarray]) – array of phi’s matrices

  • signal_x (float) – input signal x in [-1, 1]

Returns:

matrix \(W_\Phi(x)\)

Return type:

ndarray

paddle_quantum.qsvt.qsp.Phi_verification(list_phi, poly_p, trials=100, error=1e-06)

verify the final \(\Phi\)

Parameters:
  • list_phi (ndarray) – array of \(\phi\)’s

  • poly_p (Polynomial) – polynomial \(P(x)\)

  • trials (int) – number of tests, defaults to 100

  • error (float) – tolerated error, defaults to 1e-6

Returns:

determine whether \(W_\Phi(x)\) is a block encoding of \(P(x)\)

Return type:

bool

paddle_quantum.qsvt.qsp.update_polynomial(poly_p, poly_q, phi)

update \(P, Q\) by given phi according to proof in theorem 3

Parameters:
  • poly_p (Polynomial) – polynomial \(P(x)\)

  • poly_q (Polynomial) – polynomial \(Q(x)\)

  • phi (float) – derived \(phi\)

Returns:

updated \(P(x), Q(x)\)

Return type:

Tuple[Polynomial, Polynomial]

paddle_quantum.qsvt.qsp.alg_find_Phi(poly_p, poly_q, length)

The algorithm of finding phi’s by theorem 3

Parameters:
  • poly_p (Polynomial) – polynomial \(P(x)\)

  • poly_q (Polynomial) – polynomial \(Q(x)\)

  • length (int) – length of returned array

Returns:

array of phi’s

Return type:

ndarray

paddle_quantum.qsvt.qsp.poly_A_hat_generation(poly_p)

function for \(\hat{A}\) generation

Parameters:

poly_p (Polynomial) – polynomial \(P(x)\)

Returns:

polynomial \(\hat{A}(y) = 1 - P(x)P^*(x)\), with \(y = x^2\)

Return type:

Polynomial

paddle_quantum.qsvt.qsp.poly_A_hat_decomposition(A_hat, error=0.001)

function for \(\hat{A}\) decomposition

Parameters:
  • A_hat (Polynomial) – polynomial \(\hat{A}(x)\)

  • error (float) – tolerated error, defaults to 0.001

Returns:

including the following elements - leading coefficient of \(\hat{A}\) - list of roots of \(\hat{A}\) such that there exist no two roots that are complex conjugates

Return type:

Tuple

paddle_quantum.qsvt.qsp.poly_Q_generation(leading_coef, roots, parity)

function for polynomial \(Q\) generation

Parameters:
  • leading_coef (float) – leading coefficient of \(\hat{A}\)

  • roots (List[float]) – filtered list of roots of \(\hat{A}\)

  • parity (int) – parity that affects decomposition

Returns:

polynomial \(Q\)

Return type:

Polynomial

paddle_quantum.qsvt.qsp.alg_find_Q(poly_p, k)

The algorithm of finding \(Q\) by theorem 4 in paper https://arxiv.org/abs/1806.01838

Parameters:
  • poly_p (Polynomial) – polynomial \(P(x)\)

  • k (int) – length of returned array

Returns:

polynomial \(Q(x)\)

Return type:

Polynomial

paddle_quantum.qsvt.qsp.quantum_signal_processing(poly_p, length=None)

Compute \(\Phi\) that transfer a block encoding of x to a block encoding of \(P(x)\) by \(W_\Phi(x)\)

Parameters:
  • poly_p (Polynomial) – polynomial \(P(x)\)

  • length (int | None) – length of returned array, defaults to None to be the degree of \(P(x)\)

Returns:

array of \(\phi\)’s

Return type:

ndarray

paddle_quantum.qsvt.qsp.reflection_based_quantum_signal_processing(P)

Reflection-based quantum signal processing, compute Phi that transfer a block encoding of x to a block encoding of \(P(x)\) with \(R_\Phi(x)\). Refer to Corollary 8 in the paper.

Parameters:

P (Polynomial) – polynomial \(P(x)\)

Returns:

array of \(phi\)’s

Return type:

ndarray

class paddle_quantum.qsvt.qsp.ScalarQSP(poly_p, length=None)

Bases: object

block_encoding(signal_x)

generate a block encoding of \(P(x)\) by quantum circuit

Parameters:

x – input parameter

Returns:

a quantum circuit of unitary that is the block encoding of \(P(x)\)

Return type:

Circuit

block_encoding_matrix(signal_x)

generate a block encoding of \(P(x)\) for verification

Parameters:

x – input parameter

Returns:

a block encoding unitary of \(P(x)\)

Return type:

Tensor