2026 Volume 35 Issue 1
Article Contents

Kaitian Gao, Youlong Yang, Zhenye Du. Preparation of digital-encoded and analog-encoded quantum states corresponding to matrix operations[J]. Chinese Physics B, 2026, 35(1): 010202. doi: 10.1088/1674-1056/ade3ad
Citation: Kaitian Gao, Youlong Yang, Zhenye Du. Preparation of digital-encoded and analog-encoded quantum states corresponding to matrix operations[J]. Chinese Physics B, 2026, 35(1): 010202. doi: 10.1088/1674-1056/ade3ad

Preparation of digital-encoded and analog-encoded quantum states corresponding to matrix operations

  • Received Date: 21/04/2025
    Accepted Date: 10/06/2025
    Available Online: 01/01/2026
通讯作者: 陈斌, bchen63@163.com
  • 1. 

    沈阳化工大学材料科学与工程学院 沈阳 110142

  1. 本站搜索
  2. 百度学术搜索
  3. 万方数据库搜索
  4. CNKI搜索

Article Metrics

Article views(264) PDF downloads(2) Cited by(0)

Access History

Preparation of digital-encoded and analog-encoded quantum states corresponding to matrix operations

Abstract: Efficient implementation of fundamental matrix operations on quantum computers, such as matrix products and Hadamard operations, holds significant potential for accelerating machine learning algorithms. A critical prerequisite for quantum implementations is the effective encoding of classical data into quantum states. We propose two quantum computing frameworks for preparing the distinct encoded states corresponding to matrix operations, including the matrix product, matrix sum, matrix Hadamard product and division. Quantum algorithms based on the digital encoding computing framework are capable of implementing the matrix Hadamard operation with a time complexity of O(poly log(mn/ε)) and the matrix product with a time complexity of O(poly log(mnl/ε)), achieving an exponential speedup in contrast to the classical methods of O(mn) and O(mnl). Quantum algorithms based on the analog-encoding framework are capable of implementing the matrix Hadamard operation with a time complexity of O(k1mn⋅polylog(mn/ε)) and the matrix product with a time complexity of O(k2l⋅polylog(mnl/ε)), where k1 and k2 are coefficients correlated with the elements of the matrix, achieving a square speedup in contrast to the classical counterparts. As applications, we construct an oracle that can access the trace of a matrix within logarithmic time, and propose several algorithms to respectively estimate the trace of a matrix, the trace of the product of two matrices, and the trace inner product of two matrices within logarithmic time.

1.   Introduction
  • Quantum computing outperforms classical computing conspicuously in certain computing tasks. The core lies in ingeniously designing quantum algorithms by exploiting the fundamental laws of quantum mechanics to address computing issues. During the development course of quantum computing, a variety of remarkable quantum algorithms have been proposed, which help a series of classical algorithms achieve a speedup. Shor’s algorithm[1] for integer factorization, which provides an exponential speedup compared to classical methods, and Grover’s algorithm[2] for unstructured database search, which offers a quadratic speedup. Other quantum algorithms, such as those for solving linear systems,[3–5] estimating the singular value[6] or eigenvalue[7] of a matrix, realizing basic arithmetic operations,[8–11] and some other applications,[12–15] also provide a speed advantage over their classical counterparts.

    For quantum algorithms, one of the crucial aspects is the storage of classical information within quantum states. There exist two types of encodings for the storage of the information, namely digital-encoding and analog-encoding. The digital-encoding method encodes data into quantum strings in a binary fashion. Specifically, data {dj}j=1n are encoded as 1n∑j|j〉|dj(m)⋯dj(1)〉, which record briefly 1n∑j|j〉|dj〉, and dj={dj(k)}k=1m(dj(k)=0,1) represents the data bitstring. The digital-encoded state is often prepared via querying quantum random access memory (QRAM),[16–18] which is capable of storing and loading data in superposition and proves highly beneficial for certain types of quantum algorithms, such as database search,[2] quantum forking, and the like. It might be worth noting that in the context of QRAM, it is typically assumed that we already possess memory cells which store data in a form accessible from a quantum computer. Another encoding approach, namely analog-encoding, encodes data into the complex amplitudes of a quantum state. Specifically, the data {aj}j=1n is encoded in the form ∑jaj|j〉, where {aj}j=1n fulfills ∑i|ai|2=1. Numerous quantum algorithms sophisticatedly use two types of encodings. A renowned example is the HHL algorithm,[3] where the analog-encoded state is subjected to the quantum phase estimation algorithm to obtain the digital-encoded state of the eigenvalues of a matrix. Subsequently, the inverses of these eigenvalues are multiplied to the amplitudes through controlled rotations. Furthermore, in Ref. [19], the author examined the relationship between these two disparate encoding methods and formulates a methodology for quantum digital-to-analog conversion (QDAC).

    Matrix operations are of fundamental significance in the scientific domain, and the efficient implementation thereof is of crucial importance for diverse applications. In addition to the usual matrix product, a type of matrix operation known as element-wise, for instance, the Hadamard product, also play a significant role in the domain of science. Element-wise operation implies that each element of the resultant matrix only depends on the element at the corresponding position of the operated matrices. The Hadamard product, also known as the Schur product, is widely used in areas such as convolution of periodic functions, integral equations, partial differential equations, probability theory, and combinatorial theory. Despite its importance, the Hadamard product and other element-wise operations have received limited attention in the context of quantum computing. While numerous quantum algorithms have been developed for usual matrix operations,[20–24] there is a notable lack of research on quantum algorithms for elementwise matrix operations. This gap raises the question of whether it is possible to design efficient quantum algorithms for computing the Hadamard product and other element-wise operations.

    In this paper, we propose two quantum frameworks, which can respectively prepare the digital-encoded and analog-encoded states corresponding to matrix operations. Based on those two frameworks, we design two types of quantum algorithms, which are capable of implementing fundamental matrix operations, including the matrix product, the matrix sum, as well as element-wise operations, such as the matrix Hadamard product, division, and power, on quantum computers and output the result with the digital-encoded and analog-encoded states, respectively. Furthermore, we extend the main conclusions to complex matrices. As applications of the main theorems, we construct an oracle that is capable of accessing the trace of a matrix, and propose several algorithms to respectively estimate the trace of a matrix, the trace of product of two matrices, and the trace inner product of two matrices.

    The paper is organized as follows. In Section 2, several common symbols and useful quantum technologies are described. In Section 3, we propose the digital-encoding computing framework and design several quantum algorithms based on this framework to prepare the digital-encoded state corresponding to matrix operations, including the usual matrix product and element-wise operations. In Section 4, we propose the analog-encoding computing framework and design several quantum algorithms based on this framework to prepare the analog-encoded state corresponding to matrix operations. In Section 5, a comparative analysis between this study and prior works is conducted and presented. In Section 6, the main conclusions are further generalized to the scenario of complex matrices. Subsequently, in Section 7, a small-scale example along with several applications are provided, and the conclusion follows in Section 6.

2.   Preliminary
  • Herein, we define several common symbols and summarize the useful results derived from previous studies.

    The set {1,2,…,n} is denoted by [n]. Let A∈ℝm×n be a matrix. For i ∈ [m], j ∈ [n], the i-th row of the matrix A is denoted by Ai:, and the j-th column of the matrix A is denoted by A: j. The element at the intersection of the i-th row and the j-th column of the matrix A is denoted by aij. The Frobenius norm of A is defined as ||A||F=∑i,jaij2, and the norm of Ai: is defined as ||Ai:||=∑jaij2.

    The usual matrix product C = AB is defined as cij=∑k=1naikbkl, where A∈ℝm×n,B∈ℝn×l. Unlike the usual matrix product, for two matrices A and B of the same dimension, there exists a type of matrix operation known as element-wise, such as the matrix sum C = A + B, which is defined as cij = aij + bij, since the results all rely on the elements at the corresponding positions of A and B. The matrix Hadamard product C = A ○ B is also an element-wise operation, and its definition is given by cij = aijbij. Furthermore, the matrix Hadamard power P = A○r is defined as pij=aijr, where r is any integer. The matrix Hadamard division D = A ○ B○−1 is defined as dij = aij/bij, where bij ≠ 0 for all i ∈ [m], j ∈ [n]. These element-wise operations are particularly useful in the studies of signal processing, machine learning, and quantum system simulation.

    Quantum random access memory (QRAM) is a memory element capable of storing data in quantum format, which has been extensively investigated in Refs. [16–18]. When a matrix A∈ℝm×n is stored in QRAM, the matrix element can be queried within a time of O(log(mn)) through an oracle

    Note that the oracle has the ability to query quantum superposition states. Therefore, querying the QRAM on uniform superposition state can generate the digital-encoded quantum state of A, 1mn∑i,j|i〉|j〉|aij〉, and the uniform superposition state can be achieved by applying the Hadamard gate to |0〉|0〉. An ancilla qubit is added and a rotation operation controlled by the memory content is applied on it, thereby achieving the following transformation:

    In the above equation, the ζij=(1−(aij/maxi,jaij)2) ensures correct normalization. By measuring the ancilla quabit being |0〉 and uncomputing the memory contents by the QRAM query, the analog-encoded quantum state of A, |A〉=1NA∑i,jaij|i〉|j〉, can be generate, where NA is the norm of |A〉. By employing the amplitude amplification discussed hereinafter, the time complexity of preparing the state |A〉 is O(mn).

    Another approach for preparing the analog-encoded quantum state of matrix A is to pre-store the information of A in a classical data structure known as quantum-accessible. This data structure regards each row of A, which we view as a vector in ℝn, as an array of 2n values and stores it in a full binary tree of n leaves. The individual amplitudes of the vector are stored in those leaves, and the sum of the squares of the amplitudes of the leaves rooted on this node is stored in each internal node. Apply a series of rotations controlled by the amplitudes stored in the internal nodes to the initial state |0 ··· 0〉 for the implementation of the preparation of the desired quantum state of A. The details can be obtained from Ref. [6]. We briefly summarize it as the following lemma.

    Lemma 1 (Ref. [6]) Suppose a matrix A∈ℝm×n is stored in the quantum-accessible data structure, there exists a quantum algorithm which has quantum access to the data structure and is capable of performing the following mappings:

    in time O(poly log(mn)).

    To prepare the analog-encoded quantum state of matrix A, the unitary UAVA can be applied to the initial state |0〉⌈ logm⌉ ⊗ |0〉⌈log n⌉, and thereby we can obtain

    We express this conclusion as the following lemma.

    Lemma 2 If a matrix A is stored in the quantum-accessible data structure, then the following state can be generated,

    in time O(poly log(mn)).

    We use amplitude amplification technique, quantum arithmetics and quantum comparator as subroutines, which are presented as the following lemmas.

    Lemma 3 (amplitude amplification[25]) Let U be a unitary operator that acts on M-qubit Hilbert space as U|0〉⊗M = α|ψ1〉|1〉 + β|ψ0〉|0〉, where |ψ1〉 and |ψ0〉 are arbitrary M − 1 qubit states. Then probability of obtaining |ψ1〉 |1〉 can be close to unity by O(1/|α|) application of U.

    Lemma 4 (quantum arithmetics[26]) Let a,b be the m-bit strings. There exists a quantum algorithm that performs transformation |a〉 |b〉 → |a〉 |a + b〉 or |a〉 |b〉 → |a〉 |ab〉 with O(poly(log(1/ε))) single- and two-qubit gates, where ε = 2−m.

    Lemma 5 (Ref. [19]) Let f(a) be some basic functions such as inverse, trigonometric function, square root, and inverse trigonometric function. We can perform a transformation |a〉|0〉→|a〉|f∼(a)〉 such as |f∼(a)−f(a)|≤ε, using O(poly(log(1/ε))) quantum arithmetics.

    Lemma 6 (quantum comparator[27]) Let a, b be the m-bit strings. The quantum comparator is used to compare two qubits |a〉 and |b〉 through the transformation |a, b, 0, 0〉 → |a, b, c1, c2〉, where c1 and c2 are two 1-qubit outputs utilized to record the comparison outcomes. If |c1, c2〉 = |1, 0〉, the results represent that a > b; if |c1, c2〉 = |0, 1〉, the results indicate that a < b; if |c1, c2〉 = |0, 0〉, the results imply that a = b.

3.   Digital-encoded state corresponding to matrix operations
  • In this section, we shall introduce several quantum algorithms that are capable of preparing the digital-encoded state corresponding to matrix Hadamard operations, as well as the usual matrix product.

    Firstly, we introduce the digital-encoding computing framework. This framework can be divided into four steps. The first step is to prepare the initial quantum state and use the Hadamard gate to make it a uniform superposition state. The second step is to obtain the information of the matrix elements by querying QRAM. The third step is to use quantum arithmetic to obtain the desired result. The last step is to erase and remove the redundant registers.

  • We firstly introduce the process of preparing the digital-encoded state corresponding to matrix Hadamard operations, which involve matrix Hadamard product, matrix Hadamard division, matrix sum, and matrix subtraction.

    Theorem 1 Let A,B∈ℝm×n be two matrices. Suppose A and B are stored in QRAM. There exists a quantum algorithm that prepares the following state:

    in time O(poly log(mn/ε)).

    Proof The proof is straightforward. First, we apply H⌈log m⌉ ⊗ H⌈log n⌉ to |0〉⌈log m⌉ ⊗ |0〉⌈log n⌉ to acquire the uniform superposition state 1mn∑i,j|i〉|j〉, and subsequently add two registers with k-qubit to respectively store the elements of A and B. Querying the QRAM twice on register 1 and 2 to obtain the transformation

    Finally, the product of aij and bij is computed by using of quantum arithmetics and stored in register B. Erase the register A via the QRAM and remove the register. Then we can get the state 1mn∑i,j|i〉|j〉|aijbij〉.

    Now we analyze the time complexity. The uniform superposition state can be prepared by using O(log(mn)) H gate. Querying QRAM twice incurs a time cost of O(poly log(mn)). The product of aij and bij can be calculated with quantum arithmetics using O(poly log(1/ε)) gate by Lemma 4, where ε = 2−k. Therefore, overall complexity for the algorithm is O(poly log(mn/ε)). Secondly, we analyze the space complexity. The number of qubits demanded for the address register is log(mn). In addition, the other two registers used to store the matrix element need 2k = log(1/ε2) qubits. Consequently, the total number of qubits required by this algorithm amounts to log(mn/ε2).

    If bij ≠ 0 for all i ∈ [m], j ∈ [n], we can implement the following transformation |bij〉|0〉→|bij〉|1bij〉 by Lemma 3. With the same approach as in Theorem 1, calculate the product of aij and 1/bij via quantum arithmetics and store the result in register A. After erasing and removing register B, the following theorem can be obtained.

    Theorem 2 Let A,B∈ℝm×n be two matrices, and each element of B is nonzero. Suppose A and B are stored in QRAM. There exists a quantum algorithm for preparing the following state:

    in time O(poly log(mn/ε)).

    Proof We analyze the time complexity. In contrast to Theorem 1, the theorem use quantum arithmetics twice respectively for calculating 1/bij and the product of aij and 1/bij. Consequently, the total time complexity is O(poly log(mn/ε)). Furthermore, with respect to space complexity, when compared with Theorem 1, this algorithm integrates an ancilla register to store the reciprocal of bij. Thus, the total number of qubits required by this quantum algorithm is log(mn/ε3).

    Similarly, querying the QRAM and applying quantum arithmetics, we can get the quantum matrix adder and subtractor with digital encoded state. We present it as a theorem. Due to the similarity in approach, the proof steps are omitted.

    Theorem 3 Let A, B∈ℝm×n be two matrices. Suppose A and B are stored in QRAM. There exists a quantum procedure that can prepares the states

    or

    in time O(poly log(mn/ε)).

    In conclusion, the complexity time of quantum algorithms, which are based on the digital-encoding computing framework, for calculating the matrix Hadamard operations is O(poly(log(mn), log(1/ε))). In contrast, the implementation of the matrix Hadamard operations via classical method requires time O(mn). Hence, the above quantum algorithms achieve an exponential speed increase compared to the classical counterparts.

  • The digital-encoded quantum state corresponding to the usual matrix product can be prepared through similar approaches.

    Theorem 4 Let A∈ℝm×l,B∈ℝl×n be two matrices. Suppose A and B are stored in QRAM. There exists a quantum algorithm for preparing the following state:

    in time O(poly log(mnl/ε)), where cij=∑k=1laikbkj.

    Proof Firstly, prepare four quantum registers and initialize them to

    Apply the Hadamard gate to create a uniform superposition over three registers 1, 2, and 3. And querying the QRAM twice on registers 1, 3 and 2, 3 generate the state

    Use the quantum arithmetics to calculate the product of aik and bkj and store the result in register B. By uncomputing the register A and removing it, we can get the following state:

    Prepare two copies of |ψ1〉. With the help of a quantum adder for superposition states,[11] the summation of all the numbers in the superposition state can be achieved. The specific description is as follows:

    where cij=∑k=1laikbkj. Applying the Hadamard gate to register 3, we can obtain the transformation 1l∑k=1l|k〉3|cij〉→|0〉3|cij〉. Removing the register 3, we have the state

    Now we analyze the time complexity. Preparing two copies of state |ψ1〉 incurs a time cost of O(poly log(mn/ε)), and the complexity of the quantum adder for superposition states is O(log(l)). Consequently, the overall time complexity for obtaining the state |AB〉 amounts to O(poly log(mnl/ε)). From the viewpoint of space complexity, preparing the |ψ1〉 state necessitates log(mnl/ε2) qubits. Moreover, the implementation of this algorithm demands two |ψ1〉 states. Consequently, the total number of qubits required to accomplish this algorithm is 2log(mnl/ε2). In contrast, when implementing the matrix operations through the classical method, the time complexity is O(mnl) and the space complexity is O(ml + ln + mn). Hence, when compare with classical algorithms, the above quantum algorithms manifest substantial advantages with respect to both space complexity and time complexity.

    We now discuss the error in the digital-encoding computing framework. Within this framework, the error originates from quantum arithmetic. In accordance with Lemma 4 and Lemma 5, the final error can be confined within the range of O(ε).

4.   Analog-encoded state corresponding to matrix operations
  • In this section, we shall introduce several quantum algorithms that are capable of preparing the analog-encoded state corresponding to matrix operations.

    There are two approaches to prepare the analog-encoded quantum state. Firstly,we introduce the first kind of analog-encoding computing framework. This framework can be summarized as two steps. The first step is to add an ancilla qubit after the corresponding digital-encoded state and to apply a rotation operation controlled by the memory content of the digital-encoded state on the ancilla qubit, as shown in Eq. (2). The second step is to measure the ancilla qubit and uncompute the memory contents by the QRAM query. With this framework, we have the following theorems.

    Theorem 5 Let A, B∈ℝm×n be two matrices. Suppose A and B are stored in QRAM. The following is true.

    (i) There exists a quantum algorithm capable of preparing the state |A○B〉′=1||A○B||F∑i=1m∑j=1naijbij|i〉|j〉, with the time complexity O(mnmaxi,j{aijbij}||A○B||F⋅polylog(mnε)).

    (ii) There exists a quantum algorithm capable of preparing the state

    with the time complexity O(mnmaxi,j{aij/bij}||A○B○−1||F⋅polylog(mnε)).

    (iii) There exists a quantum algorithm capable of preparing the state |A±B〉′=1||A±B||F∑i=1m∑j=1n(aij±bij)|i〉|j〉, with the time complexity O(mnmaxi,j{aij±bij}||A±B||F⋅polylog(mnε)).

    Proof We merely prove (i), and the proof procedures of the remainder are analogous to it. By Lemma 1, we can get the digital-encoded state corresponding to matrix Hamadard product. Add an ancilla register with a 1-qubit and apply a controlled rotation gate on the qubit, the following transformation can be obtained:

    where the γij ensures correct normalization. By measuring the ancilla qubit being |0〉 and uncomputing the memory contents by the QRAM query, we can get the quantum state |A ○ B〉′.

    Now we analyze the time complexity. Preparing the digital-encoded state |A ○ B〉 incurs a time cost of O(poly log(mn/ε)). The success probability of measuring the ancilla qubit to |0〉 in the end is Ω(||A○B||F2mnmaxi,j2{aijbij}). By using the amplitude amplification, only O(mnmaxi,j{aijbij}||A○B||F) iterations are sufficient to achieve a constant success probability of preselection process. Consequently, the overall time complexity for obtaining the state |A ○ B〉′ amounts to O(mnmaxi,j{aijbij}||A○B||F⋅polylog(mnε)).

    Similarly, based on this framework, the analog-encoded quantum state corresponding to the usual matrix product can be prepared through the following theorem.

    Theorem 6 Let A∈ℝm×l,B∈ℝl×n be two matrices. Suppose A and B are stored in QRAM. There exists a quantum algorithm for preparing the state |AB〉′=1||AB||F∑i=1m∑j=1ncij|i〉|j〉 within a time of O(mnmaxi,j{cij}||AB||F⋅polylog(mnlε)), where cij=∑k=1laikbkj.

    Since the first kind of analog-encoded computing framework only adds an ancilla register of 1-qubit after the digital encoding state (which has been discussed in detail in the previous section), the ancilla qubit can be neglected. Therefore, its space complexity is the same as that of the digital-encoding computing framework. Secondly, the error of this framework stems from the precision of storing calculation results in the digital-encoded state. Considering that the digital-encoding computing framework is capable of controlling the precision within O(ε), the error generated by this framework can likewise be constrained within O(ε). In addition, the above quantum algorithms, which are based on first kind of analog-encoding computing framework, for calculating the matrix product and matrix Hadamard operations attain a quadratic speed increase in comparison with the classical counterparts.

    The second kind of analog-encoding computing framework can be summarized in four steps. The first one is to prepare the initial quantum state. The second one is to query the quantum-accessible data structure for obtaining the information of matrices. The third one is to use a quantum comparator to select the desired elements of matrices. The final step is to measure the ancilla register to acquire the analog-encoded state.

    Based on the framework, we propose two quantum algorithms that are capable of preparing the analog-encoded state corresponding to the matrix Hadamard product and division, respectively.

    Theorem 7 Let A, B∈ℝm×n be two matrices. Assume that A and B are stored in a quantum-accessible data structure. There exists a quantum procedure that prepares the state |A○B〉′=1||A○B||F∑i=1m∑j=1naijbij|i〉|j〉 within a time of O(maxi,j{|aij|}maxi,j{|bij|}mini,j{|aijbij|}mn⋅polylog(mn)).

    Proof The steps of the algorithm are divided into four, which are elaborated as follows.

    (i) Prepare five quantum registers: registers 1 and 2 record the row index i and the column index j of matrix A, registers 3 and 4 record the row index k and the column index l of matrix B, and register r with an ancilla qubit for storing the comparator outcomes of i, j and k, l. Prepare the five registers in the state

    (ii) By Lemma 2, we can prepare the analog-encoded quantum state of matrix A and B via the unitary UAVA and UBVB, respectively. Perform the unitary (UAVA)1,2⊗(UBVB)3,4⊗Ir on the |ψ0〉. Then we have the state

    where |A〉=1||A||F∑i,jaij|i〉|j〉 and |B〉=1||B||F∑k,lbij|k〉|l〉.

    (iii) This step aims to pick out the elements at the corresponding positions of A and B with the help of the quantum comparator, and its specific description is as follows:

    If the resulting state |c1, c2, c3, c4〉 is |0,0,0,0〉, it implies that i = k and j = l. Then apply a CNOT gate on the register r controlled by |c1, c2, c3, c4〉. We obtain

    where the function f(i,k,j,l) is defined as 1 when i = k and j = l, and 0 otherwise. Equation (19) can be expressed as

    (iv) Measure the register r to be |1〉. We have the state

    Applying the controlled-NOT gate to the registers 3 and 4 before removing them, we obtain the final state

    Now we analyze the time complexity. On step (ii), the quantum state |ψ1〉 can be obtained using O(poly log(mn)) by Lemma 1. On step (iii), the quantum comparator use O(log(mn)) gates by Lemma 6. Therefore, overall complexity for steps 2, 3 is O(poly log(mn)). The success probability of step (iv) is ||A○B||F2||A||F2||B||F2, and this value is at least Ω(mini,j2{|aijbij|}maxi,j2{|aij|}maxi,j2{|bij|}mn). By amplitude amplification, only O(mnmaxi,j{|aij|}maxi,j{|bij|}mini,j{|aijbij|}) repetitions are sufficient to achieve a constant success probability of preselection process. Therefore, the total time complexity of the algorithm is O(maxi,j{|aij|}maxi,j{|bij|}mini,j{|aijbij|}mn⋅polylog(mn)). Now we analyze the space complexity. It is not difficult to find that only 2log(mn) + 5 qubits are required to complete the task. From this, it can be seen that its space complexity is O(log(mn)). Hence, in comparison with classical algorithms, the above algorithms are capable of attaining a quadratic acceleration effect while conserving exponential space.

    It should be evident that the above minimum value mini,j{|aijbij|} is the minimum among the non-zero elements of A ○ B. In the event that no such elements exist, then the outcome is a zero matrix, and this is not applicable to this quanutm algorithm.

    It should be emphasized that in above theorem, we designed the quantum algorithms for the operations between two matrices. Then, for the case of operations of multiple matrices, it can be regarded as the operations between these matrices two by two in sequence. Thus, according to Theorem 7, the preparation of the digital-encoded state and the analog-encoded state corresponding to the Hadamard product of r matrices can be achieved. As a special case of this, if the r matrices are the same matrix, then we can achieve the preparation the digital-encoded state and the analog-encoded state corresponding to the Hadamard power of the matrix. However, how to perform synchronous operations on r matrices to give full play to the maximum potential of quantum computers is our future research direction.

    Theorem 8 Let A, B∈ℝm×n be two matrixes, where bij ≠ 0 for all i ∈ [m], j ∈ [n]. Suppose A are stored in a quantum-accessible data structure and B are stored in QRAM. There exists a quantum procedure that prepares the state |A○B○−1〉′=1||A○B○−1||F∑i=1m∑j=1naijbij|i〉|j〉 within a time of O(maxi,j{|bij|}mini,j{|bij|}⋅polylog(mnε)).

    Proof Without loss of generality, it is typically assumed that bij ≤ 1. In case there exists i ∈ [m], j ∈ [n] such that bij ≥ 1, each element of B will be divided by the maximum value among them. The steps of the algorithm are divided into four, which are elaborated as follows.

    (i) Prepare five quantum registers: registers 1 and 2 record the row index i and the column index j of matrix A, register 3 records store the element bij of B, and register r with an ancilla qubit for storing 1/bij. Prepare the five registers in the state

    (ii) Perform the unitary (UAVA)1,2⊗I3,r on the |ψ0〉. Then we have the state

    (iii) Querying the QRAM on registers 1, 2, and 3 generate the following state:

    (iv) Let a controlled rotation Ry as follows:

    where γ is a constant. By applying the controlled rotation Ry, which is controlled by register 3, to the register r, we obtain the state

    (v) Erase the register 3 using the QRAM and measure the register r to be |1〉, we have

    Now we analyze the time complexity. The overall complexity for steps (i), (ii), (iii), and (iv) is O(poly log(mn/ε)). The success probability of step (v) is determined by the amplitude square γ/bij, and the value at least Ω(mini,j2{|bij|}maxi,j2{|bij|}). Hence, by virtue of the amplitude amplification, only O(maxi,j{|bij|}mini,j{|bij|}) repetitions are sufficient to achieve a constant success probability of preselection process. In conclusion, the total time complexity of the algorithm is O(maxi,j{|bij|}mini,j{|bij|}⋅polylog(mn/ε)). In contrast, the implementation of the matrix Hadamard division via classical method requires time O(mn). Hence, the above quantum algorithms achieve an exponential speed increase compared to the classical counterparts. Now we analyze the space complexity. It is not arduous to discover that merely log(mn/ε) + 5 qubits are requisite to accomplish the task. Evidently, this indicates that its space complexity is O(log(mn/ε)).

    For A∈ℝm×l and B∈ℝl×n, the matrix product AB also can be expressed as a sum of outer products, given by AB=∑k∈[l]ak⊗bk, where ak presents the k-th columns of A and bk presents the k-th rows of B. The authors in Ref. [28] presented a method for preparing the analog-encoded state corresponding to the matrix product of A and B, assuming that the matrix is stored in QRAM and applying controlled rotation gates to obtain the desired state. Here, we provide a method based on the quantum-accessible data structure for preparing the analog-encoded state, which only requires storing the matrix in classical data rather than in a quantum state.

    Theorem 9 Let A∈ℝm×l,B∈ℝl×n be two matrices. Assume that A and B are stored in a quantum-accessible data structure. There exists a quantum procedure that prepares the state

    within a time of O(maxi,j{|aij|}maxi,j{|bij|}mini,k,l{|aikbkl|}l⋅polylog(mnl)).

    Proof Similar to the steps (i), (ii) of Theorem 7, the state |A〉1,2|B〉3,4|0〉r can be obtained, where |A〉=1||A||F∑i,kaik|i〉|k〉 and |B〉=1||B||F∑k′,lbk′j|k′〉|j〉. Picking out the elements aik of A and bkj of B with the help of the quantum comparator, we obtain |ψ〉 = |A〉1,2|B〉3,4|f(k,k′)〉r, where the function f(k,k′) is defined as 1 when k = k′, and 0 otherwise. Measuring the register r to be |1〉, we can get the final state.

    The time complexity of obtaining |ψ〉 is O(poly log(mnl)). By virtue of the amplitude amplification, O(maxi,j{|aij|}maxi,j{|bij|}mini,k,l{|aikbkl|}l) repetitions are sufficient to achieve a constant success probability of preselection process. In conclusion, the total time complexity of the algorithm is O(maxi,j{|aij|}maxi,j{|bij|}mini,k,l{|aikbkl|}l⋅polylog(mnl)). Meanwhile, the space complexity of the algorithm is O(log(mnl)).

    However, it is imperative to clearly elucidate that for the quantum algorithm based on the analog-encoding computational framework, the probability of measurement success depend on ||f(A,B)||F/(||A||F||B||F). Here, f(A,B) denotes the operation of the matrix. For example, the matrix product means that f(A,B) = AB, and Hadamard matrix product means that f(A,B) = A ○ B. When the proportion of ||f(A,B)||F within ||A||F||B||F is exceedingly small (or ||f(A,B)||F approaches the zero matrix), it becomes nearly infeasible for us to effectively obtain the desired results. Consequently, to guarantee the seamless operation of the algorithm, it is typically requisite that the ratio of ||f(A,B)||F to ||A||F||B||F should not be overly small, which undoubtedly imposes certain stipulations on the matrix under consideration. Furthermore, this quantum algorithm exhibits a strong reliance on the amplitude amplification algorithm to enhance the measurement success rate. However, this dependence will inevitably incur additional overheads, thereby increasing the depth of the quantum circuit and the consumption of quantum resources.

    The error of the quantum algorithms based on the second kind of analog-encoding computing framework originates from the quantum-accessible data structure. As in Ref. [6], this data structure is capable of controlling the storage precision within O(ε). Consequently, the error of the quantum algorithms based on the framework is likewise O(ε). From a numerical standpoint, whether the digital-encoding computing framework or analog-encoding computing framework, matrix operations demonstrate backward stability during the calculation procedure. Specifically, there exist minor discrepancies between the computed results and the true values. However, the forward error can be relatively substantial, including round-off errors and gate operation errors. Furthermore, the quantum hardware utilized for the implementation of quantum gates will, to a certain extent, exert an influence on the overall precision.

5.   Comparison with previous work
  • Here we conduct a comparison between our work and previous research. In prior research, regarding the quantum algorithm for the matrix Hadamard operation, the corresponding research findings are notably scarce. In light of the fact that numerous quantum algorithms for matrix multiplication have already been documented in the extant literature, this paper will solely conduct a comparison between the quantum algorithm proposed for matrix product and the existing algorithms.

    In Ref. [21], the authors put forward a quantum matrix multiplier, and the output result outputs in the digital-encoded state. The time complexity of the matrix multiplier is O(mn log(l)),[21] where m, l, and n denote the dimensions of the matrices. Analogously, in the Theorem 4 of this paper, the digital-encoded quantum state corresponding to the matrix product also can be prepared. Here, the time complexity of our algorithm is O(poly log(mnl/ε)). In comparison, our algorithm has achieved exponential improvements in terms of m and n.

    The authors in Ref. [20] proposed an efficient quantum subroutine for matrix multiplication, which computes a state vector that encodes the elements of the product of two matrices. Specifically, this quantum algorithm outputs an analog-encoded quantum state that encompasses the element information of matrix C (i.e., the matrix resulting from multiplication), while simultaneously being intermixed with the information of other redundant elements. And the overall depth of the quantum circuit becomes of order O(poly log(max {m,n}l/ε)). In comparison with the aforementioned conclusions, the method (Theorem 9) we put forward for preparing the analog-encoded quantum states corresponding to matrix product can output a more pure quantum state without any additional redundant states, all the while maintaining the same depth of the quantum circuit. Similarly, the authors in Ref. [29] accomplished the computation of matrix products through the utilization of Toffoli-type gates and 1-qubit gates. During this procedure, the depth of the protocol scales logarithmically with the dimension of the matrices being considered. Nevertheless, this approach necessitates an additional O(l) auxiliary qubits. Conversely, the quantum algorithm we put forward demands only O(1) auxiliary qubits.

6.   Some extensions and relevant works
  • In the realm of quantum mechanics, the state space of an isolated physical system is a complex vector space with inner product. Against this background, the extension of the algorithms to the case of complex matrices has the potential to further broaden the scope of application of this algorithm within the quantum computing environment.

    Let A∈ℂm×n be a complex matrix. Then A can be represented as A = AR + iAI, where i denotes the imaginary unit, and AR and AI are matrices composed of the real part and the imaginary part of the complex matrix A, respectively. Let aij represent the elements situated in the i-th row and j-th column of matrix A. Denote the real part of aij as aijR and the imaginary part as aijI. In other words, aijR and aijI are the elements in the i-th row and j-th column of matrix AR and AI, respectively.

  • Let A, B∈ℂm×n be two complex matrix. Suppose that AR, AI, BR, and BI have been pre-stored in the QRAM. Note that A + B = (AR + BR) + i(AI + BI). Consequently, the sum of complex matrices can be indirectly accomplished by computing the sum of real matrices. In accordance with Theorem 5 (step iii), unitary operators UR and UI can be constructed. These two unitary operators are capable of achieving the following transformations respectively:

    where l = log(mn), C=mn⋅maxi,j{(aijR+bijR),(aijI+bijI)}, and |GR〉 and |GI〉 are garbage state, which are not of our concern.

    Let a (l + 2)-qubit unitary W = |0〉⟨0| ⊗ UR + |1〉⟨1| ⊗ UI. According to Lemma 52 of Ref. [30], the unitary W∼=(H⊗I⊗(l+1))W(SH⊗I⊗(l+1)) is capable of achieving the following transformation:

    It was noted that (UR+iUI)|0〉⊗(l+1)=1C∑i,j[(aijR+bijR)+i(aijI+bijI)]|i〉|j〉|0〉+|G〉|1〉. Therefore, we have

    where |Garbage〉 is a (unnormalized) state and (|0〉⟨0|⊗I⊗l ⊗ |0〉⟨0|)|Garbage〉 = 0. Upon measuring both the first and the last qubit to be in the |0〉 state, the system evolves in the state |A+B〉=1||A+B||F∑i,j(aij+bij)|i〉|j〉. Employing the same methodology, it is feasible to accomplish the preparation of the analog state according to the subtraction of complex matrices.

  • For complex matrix A,B∈ℂm×n, the Hadamard product of A and B can be expressed as A ○ B = (AR ○ BR − AI ○ BI) + i (AI ○ BR + AR ○ BI). Given that the matrices AR, AI, BR, and BI have been previously stored in the QRAM, we can obtain the following transformation:

    In light of the concepts presented in Theorem 1 and Theorem 3, we derive the quantum states 1mn∑i,j|i〉|j〉|aijRbijR−aijIbijI〉. By leveraging the first kind of analog-encoding computing framework, it is feasible to construct a unitary operator U0 capable of effectuating the following transformation:

    Employing a similar approach, we also construct a unitary operator U1 that is capable of implementing the following transformation:

    Here, l = log(mn), C=mn⋅maxi,j{(aijRbijR−aijIbijI), (aijIbijR+aijRbijI)}, and |G0〉,|G1〉 are garbage state.

    Let W = |0〉⟨ 0| ⊗ U0 + |1〉⟨ 1| ⊗ U1. Subsequently, when the unitary operator W∼ is applied to the state |0〉⊗ (l+2) (analogously to Eqs. (31) and (32), the final state |A○B〉=1||A○B||F∑i,jaijbij|i〉|j〉 can be obtained. This is achieved by measuring both the first and the last qubit to be in the state |0〉.

  • Let A∈ℂm×l, B∈ℂl×n be two complex matrix. It should be noted that AB = (ARBR − AIBI) + i (AIBR + ARBI), where it is assumed that AR, AI, BR, and BI are stored in QRAM. Devise a quantum algorithm for performing complex matrix multiplication. The approach is analogous to that presented in Subsection 6.2. Specifically, initially, provide the construction procedures of unitary operators U0 and U1. Subsequently, apply the unitary operator W∼ to the initial state |0 ··· 0〉. Upon measurement, the desired outcome can be achieved. In light of this, in this section, we solely expound on the construction method of the unitary operator U0, and the remainder will not be further elaborated.

    Starting from the initial state |0 ··· 0〉, the state

    can be achieved. By employing the method detailed in Theorem 4, the quantum state

    can be deduced from Eq. (36), with cijR=∑k1=1lai,k1Rbk1jR and cijI=∑k2=1lai,k2Ibk2jI. Subsequently, the subsequent result, 1mn∑i,j|i〉|j〉|cijR−cijI〉, is derived by applying quantum arithmetic (Lemma 4). By using the first kind of analog-encoding computing framework, it is feasible to construct the unitary operator U0, where

7.   Examples and applications
  • Within this section, a series of small-scale examples and captivating applications will be presented to elucidate the quantum frameworks.

  • Concerning the digital-encoding computing framework and analog-encoding computing framework put forward in this paper, Theorem 1 and Theorem 7 (matrix Hadamard product) are highly representative. Given this, we solely design small-scale examples for these two theorems. The aim is to demonstrate that the framework we have proposed possesses a certain level of feasibility. Let

    be two 2 × 2 matrices. We will elaborate in detail, respectively, on the procedures for preparing the digital-encoded state and analog-encoded state corresponding to the Hadamard product of matrices A and B.

    (i) Preparing the digital-encoded state

    Let us prepare three registers and initialize them in the state |ϕ0〉=|0〉1⊗2|0〉A⊗3|0〉B⊗6. Specifically, register 1 is designated for storing address information, register A is employed to store the elements of matrix A, and register B is utilized to store the elements of matrix B. Given that the calculation result is to be stored in register B, it is imperative to ensure that register B possesses an adequate number of qubits to store the calculation result with sufficient precision. By implementing the Hadamard gate H⊗2 on register 1, we are able to acquire

    Since we have already assumed that matrices A and B are pre-stored in the QRAM, we can obtain each element of matrices A and B by accessing the QRAM, resulting in the following quantum state:

    Subsequently, apply the quantum arithmetic (Lemma 4) to register A and register B to execute the multiplication operation of two real numbers. For instance, the state transformation |4〉|9〉 → |4〉|36〉 is achieved. Regarding the specific implementation procedure and the corresponding quantum circuit, please refer to Ref. [26] for detailed information. Ultimately, the final quantum state

    is achieved by once again conducting the erasure operation on register A with the utilization of QRAM.

    (ii) Preparing the analog-encoded state

    The rotation operators about the y^ axes is defined by the following equation:

    Two single-qubit VA and UA are defined as follows:

    where θ1=2arccos(0.2), θ2=2arccos(0.20.2), and θ3=2arccos(0.8). When the unitary operator UAVA is applied to the quantum state |0〉⊗2, the quantum state

    can be successfully prepared. Similarly, when the angles in Eqs. (43) and (44) are set to θ1=2arccos(0.9), θ2=2arccos(0.90.9), and θ3=2arccos(0.90.1), the unitary operator UBVB for preparing the state

    can be derived.

    Consequently, it is feasible to prepare the following quantum state |A〉a|B〉b|0〉r starting from the initial state |0〉a⊗2|0〉b⊗2|0〉r. Herein, the registers a and b are respectively designated to store the address information of matrix A and matrix B. Meanwhile, register r serves as an ancilla and consists of one qubit. By applying the quantum comparator (Lemma 6) to the state |A〉a|B〉b|0〉r, we obtain the following state:

    where |G〉 is the garbage state and α=1924100≈0.43864, β=1−α2. The approximate quantum state of |ϕ〉 is taken as |ϕ∼〉=sinθ|A○B〉|1〉+cosθ|G〉|0〉, where sinθ = 0.43864. Denote the amplitude amplification operator as Q = US0U†Sr. Here, S0 is defined as S0 = I − 2|0〉⟨ 0|, Sr is given by Sr = XrZrXr, and U is a unitary operator such that U|0〉 = |ϕ〉. It is now evident that upon applying the operator Q once to the state |ϕ∼〉, resulting state is

    where sin(3θ) ≈ 0.97833. Measuring the ancilla qubit to be |1〉r, the system becomes |A∘B⟩∼. Then the probability of measuring the ancilla qubit to be 1 is P1 = 95.712%, and the fidelity is F=⟨A∘B∼|A∘B⟩=0.9999.

  • The trace of a matrix A∈ℝn×n is defined as Tr(A)=∑i=1naii. Now, we shall construct an oracle for querying trace of A, this is,

    Let I be a unit matrix. It is noted that

    Suppose that A and I are stored in QRAM. By Theorem 1, the quantum state 1n∑i=1n|i〉|i〉|aii〉 can be prepared in time O(poly log(n/ε)). Apply Hadamada gate on the first register and remove the register, we obtain the state |ψ1〉=1n∑i=1n|i〉|aii〉. Prepare two copies of |ψ1〉. With the help of a quantum adder for superposition states,[11] the summation of all the numbers in the superposition state can be achieved. Therefore, we have

    Apply Hadamada gate on the first register and remove the register, we can achieve the transformation |0〉 → |Tr(A)〉 in time O(poly log(n/ε)).

  • Suppose that A and I are stored in the quantum-access data structure. By Theorem 7, the following quantum state can be prepared in time O(poly log(n)):

    Applying the CNOT gate on the diagonal index registers 1–4, which implement the transformation as |i〉|i〉|i〉|i〉 → |i〉|0〉|0〉|0〉, then we can obtain the state

    where |v〉=∑i=1naij|i〉1|0〉2,3,4 is a non-normalization state. Subsequently, we prepare the second state |ϕ〉=1n|u〉|1〉r, where |u〉=∑i=1n|i〉1′|0〉2′,3′,4′ can be prepared from the initial state |0〉1′2′,3′,4′ by using Hadamard gates only acting on register 1. It should be noted that the number of qubits of registers 1–4 is equivalent to that of registers 1′–4′. It is obvious that

    Therefore, in order to estimate Tr(A), we can employ the SWAP test with the input state |ψ〉 and |ϕ〉. The value of Tr(A) can be estimated with an accuracy of ε by repeating the Swap test O(1/ε2) times. As we have observed, the preparation of the states |ψ〉 and |ϕ〉 incurs a time cost time of O(poly log(n)). Hence, the time complexity of the above algorithm is O(poly log(n)/ε2).

    The above algorithm has the following two advantages:

    (i) When estimating the trace of a matrix with a classical algorithm, although it can be accomplished in logarithmic time by using a parallel algorithm, it is necessary to query the matrix n times to obtain the diagonal elements of A. However, the above quantum algorithm for estimating the trace a the matrix, while ensuring accomplishment within logarithmic time, merely demands O(1) accesses to the matrix. Moreover, the storage space required for storing matrix information in this quantum algorithm is O(ω log2(n)), where ω represents the number of non-zero entries of A. Compared with the storage space required by the classical algorithm, which is O(n2), an exponential saving in storage space has been achieved.

    (ii) A quantum method of estimation trace of a Hermitian matrix, which is based on Chebyshev polynomial approach, was proposed by Nghiem et al. in 2023. This method is capable of computing the trace of a complex matrix, yet its precondition is that the matrix be a Hermitian matrix. Our algorithm can merely calculate the trace of a real matrix, but it has no additional requirements for the matrix.

  • The trace of product of two matrices A∈ℝn×m and B∈ℝm×n is defined as Tr(C)=∑i=1n∑j=1maijbji, where C = AB. Suppose that the matrices A and B are stored in the quantum-access data structure. Now we describe our quantum algorithm for estimating the trace of product of two matrices.

    Firstly, we modify step (iii) in Theorem 7 and use the quantum comparator to select aij and bji. The description of this procedure is presented as follows:

    If the resulting state |c1, c2, c3, c4〉 is |0,0,0,0〉, it implies that i = l and j = k. Then apply a CNOT gate on the register r controlled by |c1, c2, c3, c4〉. Therefore, using the same method as in Subsection 7.3, we can prepare two input states in a time of O(poly log(n)) as follows:

    where |v〉=∑i,jaijbji|i〉|j〉|0〉|0〉 and |u〉=∑i′,j′|i′〉1′|j′〉2′|0〉3′,4′ are non-normalization states. The obvious expression is

    Hence, in order to estimate Tr(C) with an accuracy ε, we can using the SWAP test with the input state |ψ′〉 and |ϕ′〉, and the overall time complexity of the above algorithm is O(poly log(n)/ε2).

  • Trace inner product is a significant notion in matrix analysis and linear algebra. It is extensively utilized in numerous fields and holds crucial research significance. In machine learning algorithms like support vector machines (SVM), trace products can be employed to define kernel functions. Kernel functions map low-dimensional data into high-dimensional spaces for better tasks such as classification and regression. In matrix data analysis methods such as principal component analysis (PCA) and independent component analysis (ICA), the trace product assists in calculating the eigenvalues and eigenvectors of the matrix, thereby achieving data reduction and feature extraction, facilitating machine learning models to better understand the data structure, and enhancing the learning efficiency and accuracy.

    The trace inner product of two matrices is defined as

    where A, B ∈ Rm×n. Suppose that the matrices A and B are stored in the quantum-access data structure. By Theorem 7, we can preparing the following states in time O(poly log(n)),

    where |v〉=∑i,jaijbij|i〉|j〉|0〉|0〉 is a non-normalization state. Moreover, preparing the second state |ϕ′′〉=1nm|u〉|1〉r, where |u〉=∑i′,j′|i′〉|j′〉|0〉|0〉 is a non-normalization state. Therefore, by using the SWAP test with the input state |ψ″〉 and |ϕ″〉, it is possible to estimate Tr(ATB), more precisely Tr(ATB)nm||A||F||B||F, with an accuracy of ε within a time of O(poly log(mn)/ε2).

    It is worthy of note that, analogous to other quantum algorithms, the output outcomes of our algorithm are all proportional to the true value. In numerous cases, the relative values or proportional correlations of the true value are already adequate to fulfill the requirements.

8.   Conclusion
  • Inspired by recent advancements in quantum algorithms, we proposed two quantum frameworks, which can respectively prepare the digital-encoded and analog-encoded states corresponding to matrix operations. These two frameworks are capable of implementing fundamental matrix operations on quantum computers, including the matrix product, the matrix sum, as well as element-wise operations, such as the matrix Hadamard product, division, and power. The digital-encoding computing framework is founded on QRAM and encodes the operation outcomes in binary form into quantum-strings. The core routines of this framework lie in obtaining the quantum information of the matrix through accessing QRAM and applying quantum arithmetic to acquire the calculation result. The quantum algorithm utilized for implementing matrix operations within this framework shows exponential speedups compared with the classical counterpart. The analog-encoding computing framework encodes the computing results into the amplitudes of quantum states, and there exist two implementation approaches for it. The first one is founded on QRAM. The analog-encoded state is acquired by implementing a controlled rotation gate on the digital-encoded state and measuring the ancilla qubit. Another approach is more dependent on quantum-accessible data structures. The core routines involve accessing the data structure, subsequently employing the quantum comparator to select the corresponding elements, and ultimately measuring the ancilla qubit to obtain the analog-encoded state. Regardless of the adopted implementation method, the quantum algorithms employed for implementing matrix operations within this framework have achieved a quadratic speedup compared with their classical counterparts. Furthermore, within the digital-encoding computing framework, we construct an oracle that is capable of accessing the trace of a matrix. Additionally, based on the analog-encoding computing framework, we propose several algorithms to respectively estimate the trace of a matrix, the trace of product of two matrices, and the trace inner product of two matrices.

    However, we should mention that, under the current circumstances, no quantum hardware exists that can support the storage and access of data in a superposition state within polynomial logarithmic time. Furthermore, the viability of such quantum hardware remains a contentious issue. This is highly likely to act as a limiting factor in the near-term implementation of the quantum algorithms we have designed. Moreover, the main focus of this thesis lies in the theoretical design of quantum algorithms, but we do not delve into practical implementation issues. But, with the advancement and performance enhancement of quantum computing hardware, we intend to carry out relevant experimental verification work in future research.

    Nevertheless, regarding the fundamental problem of realizing basic matrix operations and preparing the corresponding quantum states in a quantum environment, we hope that this research work can function as a subroutine and contribute positively to other quantum algorithms or future related applications.

Reference (30)

Catalog

    /

    DownLoad:  Full-Size Img  PowerPoint
    Return
    Return