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+(1x2)|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+(1x2)|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 ϕ during the iteration of finding Φ

Parameters:
  • phi (float) – rotation angle ϕ

  • poly_p (Polynomial) – polynomial P(x)

  • poly_p_hat (Polynomial) – updated polynomial P^

  • poly_q_hat (Polynomial) – updated polynomial 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Φ(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Φ(x)

Return type:

ndarray

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

verify the final Φ

Parameters:
  • list_phi (ndarray) – array of ϕ’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Φ(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 A^ generation

Parameters:

poly_p (Polynomial) – polynomial P(x)

Returns:

polynomial A^(y)=1P(x)P(x), with y=x2

Return type:

Polynomial

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

function for A^ decomposition

Parameters:
  • A_hat (Polynomial) – polynomial A^(x)

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

Returns:

including the following elements - leading coefficient of A^ - list of roots of 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 A^

  • roots (List[float]) – filtered list of roots of 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 Φ that transfer a block encoding of x to a block encoding of P(x) by WΦ(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 ϕ’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Φ(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