Disclosure of Invention
The invention aims to provide a quantum comparison method and a device for matrix eigenvalues, which solve the defects in the prior art, can realize the application of a quantum algorithm to matrix eigenvalue comparison estimation, fully exert the advantages of quantum calculation, fill the important blank of the linear system quantum calculation direction, and have important open significance and practical application value.
One embodiment of the present application provides a quantum comparison method for matrix eigenvalues, the method comprising:
obtaining a characteristic value quantum state carrying characteristic value information of a target data matrix and a preset value of a specific parameter, wherein the characteristic value quantum state corresponds to n comparison quantum bits for comparing with the preset value;
acquiring at least n auxiliary qubits and 1 result qubit for outputting a comparison result;
and determining a quantum logic gate of a quantum comparison circuit to be constructed according to the preset value, constructing and operating the quantum comparison circuit for comparing the characteristic value quantum state with the preset value by combining n bits of the comparison quantum bit, n bits of the auxiliary quantum bit and 1 bit of the result quantum bit, and outputting a result quantum state representing a comparison result.
Optionally, the target data matrix is an hermitian matrix, and before the obtaining the eigenvalue quantum state carrying the eigenvalue information of the target data matrix, the method further includes:
and (3) obtaining a quantum state containing the hermitian, constructing and operating a corresponding quantum phase estimation QPE circuit, and evolving the quantum state of the hermitian into a characteristic value quantum state carrying characteristic value information of the hermitian.
Optionally, the hermitian matrix is a hermitian matrix corresponding to the transaction data matrix, and the obtaining the quantum state including the hermitian matrix includes:
and carrying out normalization processing on the maximum singular value of the transaction data matrix, and preparing a quantum state containing a hermite matrix corresponding to the transaction data matrix after normalization processing, wherein the maximum eigenvalue of the hermite matrix is equal to the maximum singular value 1 of the transaction data matrix after normalization processing.
Optionally, the specific parameter is a reference condition number k i Is the reciprocal of the preset value ofThe initial value of i is 0, and the method further comprises:
if the result quantum state indicates that the characteristic value exists in the characteristic value quantum state and is smaller than the preset value, adding 1 to the i, and returning to the step of executing the quantum logic gate of the quantum comparison circuit to be constructed according to the preset value until the output result quantum state indicates that the characteristic value does not exist in the characteristic value quantum state and is smaller than the preset value;
and determining the approximate estimation of the minimum eigenvalue in the eigenvalue quantum state according to the current preset value.
Optionally, the method further comprises:
calculating the condition number of the hermite according to the approximate estimation of the maximum eigenvalue and the minimum eigenvalue of the hermite;
and searching for a coordinating pair in the transaction data matrix according to the size of the condition number.
Optionally, the determining the quantum logic gate of the quantum comparison circuit to be constructed according to the preset value includes:
and calculating the binary complement corresponding to the preset value, and determining a quantum logic gate of the corresponding bit according to each bit of the binary complement, wherein when the bit is 0, the corresponding quantum logic gate is a Toffoli gate, and when the bit is 1, the corresponding quantum logic gate is a logic OR gate.
Optionally, the constructing and operating a quantum comparison circuit for comparing the characteristic value quantum state with the preset value, and outputting a result quantum state representing a comparison result, including:
acquiring a preset quantum logic gate, and adding the quantum logic gate and the preset quantum logic gate which are determined corresponding to the preset value to corresponding quantum bits to obtain a quantum comparison circuit for comparing the characteristic value quantum state with the preset value;
and operating the quantum comparison circuit, and outputting a result quantum state representing a comparison result.
Yet another embodiment of the present application provides a quantum comparison device for matrix eigenvalues, the device comprising:
the data acquisition module is used for acquiring a characteristic value quantum state carrying characteristic value information of a target data matrix and a preset value of a specific parameter, wherein the characteristic value quantum state corresponds to n comparison quantum bits for comparing with the preset value;
the bit acquisition module is used for acquiring at least n auxiliary quantum bits and 1 result quantum bit for outputting a comparison result;
and the construction output module is used for determining a quantum logic gate of a quantum comparison circuit to be constructed according to the preset value, constructing and operating the quantum comparison circuit for comparing the characteristic value quantum state with the preset value by combining the n-bit comparison quantum bit, the n-bit auxiliary quantum bit and the 1-bit result quantum bit, and outputting a result quantum state representing a comparison result.
A further embodiment of the present application provides a storage medium having a computer program stored therein, wherein the computer program is arranged to perform the method of any of the above when run.
Yet another embodiment of the present application provides an electronic device comprising a memory having a computer program stored therein and a processor configured to run the computer program to perform the method of any of the above.
Compared with the prior art, the quantum comparison method for the matrix eigenvalue firstly obtains the eigenvalue quantum state carrying the eigenvalue information of the target data matrix and the preset value of the specific parameter, wherein the eigenvalue quantum state corresponds to n comparison quantum bits for comparison with the preset value; acquiring at least n auxiliary qubits and 1 result qubit for outputting a comparison result; and determining a quantum logic gate of a quantum comparison circuit to be constructed according to a preset value, constructing and operating the quantum comparison circuit for comparing the characteristic value quantum state with the preset value by combining n-bit comparison quantum bits, n-bit auxiliary quantum bits and 1-bit result quantum bits, and outputting a result quantum state representing a comparison result. The characteristic value quantum state is compared with the preset value, so that the application of a quantum algorithm to matrix characteristic value estimation is realized, the advantage of quantum calculation is fully exerted, the important blank of the linear system quantum calculation direction is filled, and the method has important open significance and practical application value.
Detailed Description
The embodiments described below by referring to the drawings are illustrative only and are not to be construed as limiting the invention.
The embodiment of the invention firstly provides a quantum comparison method of matrix eigenvalues, which can be applied to electronic equipment such as computer terminals, in particular to common computers, quantum computers and the like.
The following describes the operation of the computer terminal in detail by taking it as an example. Fig. 1 is a hardware block diagram of a computer terminal according to a quantum comparison method for matrix eigenvalues provided in an embodiment of the present invention. As shown in fig. 1, the computer terminal may include one or more (only one is shown in fig. 1) processors 102 (the processor 102 may include, but is not limited to, a microprocessor MCU or a processing device such as a programmable logic device FPGA) and a memory 104 for storing data, and optionally, a transmission device 106 for communication functions and an input-output device 108. It will be appreciated by those skilled in the art that the configuration shown in fig. 1 is merely illustrative and is not intended to limit the configuration of the computer terminal described above. For example, the computer terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store software programs and modules of application software, such as program instructions/modules corresponding to the quantum comparison method of matrix eigenvalues in the embodiment of the present application, and the processor 102 executes the software programs and modules stored in the memory 104, thereby executing various functional applications and data processing, that is, implementing the method described above. Memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory remotely located relative to the processor 102, which may be connected to the computer terminal via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission means 106 is arranged to receive or transmit data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC) that can connect to other network devices through a base station to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module for communicating with the internet wirelessly.
It should be noted that a real quantum computer is a hybrid structure, which includes two major parts: part of the computers are classical computers and are responsible for performing classical computation and control; the other part is quantum equipment, which is responsible for running quantum programs so as to realize quantum computation. The quantum program is a series of instruction sequences written by a quantum language such as the qlunes language and capable of running on a quantum computer, so that the support of quantum logic gate operation is realized, and finally, quantum computing is realized. Specifically, the quantum program is a series of instruction sequences for operating the quantum logic gate according to a certain time sequence.
In practical applications, quantum computing simulations are often required to verify quantum algorithms, quantum applications, etc., due to the development of quantum device hardware. Quantum computing simulation is a process of realizing simulated operation of a quantum program corresponding to a specific problem by means of a virtual architecture (namely a quantum virtual machine) built by resources of a common computer. In general, it is necessary to construct a quantum program corresponding to a specific problem. The quantum program, namely the program for representing the quantum bit and the evolution thereof written in the classical language, wherein the quantum bit, the quantum logic gate and the like related to quantum computation are all represented by corresponding classical codes.
Quantum circuits, which are one embodiment of quantum programs, also weigh sub-logic circuits, are the most commonly used general quantum computing models, representing circuits that operate on qubits under an abstract concept, the composition of which includes qubits, circuits (timelines), and various quantum logic gates, and finally the results often need to be read out by quantum measurement operations.
Unlike conventional circuits, which are connected by metal lines to carry voltage or current signals, in a quantum circuit, the circuit can be seen as being connected by time, i.e., the state of the qubit naturally evolves over time, as indicated by the hamiltonian operator, during which it is operated until a logic gate is encountered.
One quantum program is corresponding to one total quantum circuit, and the quantum program refers to the total quantum circuit, wherein the total number of quantum bits in the total quantum circuit is the same as the total number of quantum bits of the quantum program. It can be understood that: one quantum program may consist of a quantum circuit, a measurement operation for the quantum bits in the quantum circuit, a register to hold the measurement results, and a control flow node (jump instruction), and one quantum circuit may contain several tens to hundreds or even thousands of quantum logic gate operations. The execution process of the quantum program is a process of executing all quantum logic gates according to a certain time sequence. Note that the timing is the time sequence in which a single quantum logic gate is executed.
It should be noted that in classical computation, the most basic unit is a bit, and the most basic control mode is a logic gate, and the purpose of the control circuit can be achieved by a combination of logic gates. Similarly, the way in which the qubits are handled is a quantum logic gate. Quantum logic gates are used, which are the basis for forming quantum circuits, and include single-bit quantum logic gates, such as Hadamard gates (H gates, ada Ma Men), bery-X gates (X gates), bery-Y gates (Y gates), bery-Z gates (Z gates), RX gates, RY gates, RZ gates, and the like; two or more bit quantum logic gates, such as CNOT gates, CR gates, CZ gates, iSWAP gates, toffoli gates, and the like. Quantum logic gates are typically represented using unitary matrices, which are not only in matrix form, but also an operation and transformation. The effect of a general quantum logic gate on a quantum state is calculated by multiplying the unitary matrix by the matrix corresponding to the right vector of the quantum state.
Referring to fig. 2, fig. 2 is a flow chart of a quantum comparison method for matrix eigenvalues according to an embodiment of the present invention, which may include the following steps:
s201, obtaining a characteristic value quantum state carrying characteristic value information of a target data matrix and a preset value of a specific parameter, wherein the characteristic value quantum state corresponds to n bits of comparison quantum bits for comparison with the preset value;
the specific parameters are preset parameters for comparing with the characteristic value quantum states, and specific preset values of the parameters can be determined according to actual application and requirements. The characteristic value quantum state corresponds to n bits of comparison quantum bits for comparison with the preset value, namely the characteristic value quantum state is prepared on n bits of quantum bits, namely the quantum state of the n bits of quantum bits, and the n bits of quantum bits can be called as comparison quantum bits for convenience of distinguishing. It should be noted that, not only the characteristic value quantum state, the quantum state carrying the value information of other data, but also the quantum state can be compared with the preset value.
For example, in one scenario of a financial transaction application, the target data matrix may be an hermitian matrix, such as a hermitian matrix corresponding to a transaction data matrix, and the transaction data matrix may contain a plurality of financial transaction data.
The financial transaction data may specifically be transaction data of a high frequency transaction (HFT, high Frequency Trading), for example: discrete point-in-time price vectors for multiple stocks, and so forth. There may be a synergistic relationship between partial price vectors whose linear combination has certain properties that do not change over time. For example, the linear combined total price of certain stock price vectors may be fixed to be a constant (typically subject to a certain distribution).
In practical applications, for example, before obtaining the eigenvalue quantum state carrying the eigenvalue information of the hermitian matrix, a quantum state containing the hermitian matrix may be obtained, a corresponding quantum phase estimation QPE line is constructed and operated, and the quantum state of the hermitian matrix is evolved into the eigenvalue quantum state carrying the eigenvalue information of the hermitian matrix.
Specifically, the transaction data matrix can be subjected to normalization processing of the maximum singular value, and quantum states containing the hermitian matrix corresponding to the transaction data matrix after normalization processing are prepared, so that the following implementation is realized: the quantum states containing the hermitian matrix are obtained and the maximum eigenvalue of the hermitian matrix is made equal to the maximum singular value 1 of the normalized transaction data matrix. The maximum eigenvalue referred to in this application is the maximum value of the absolute value of the eigenvalue, and the minimum eigenvalue is the minimum value of the absolute value of the eigenvalue.
For the transaction data matrix X, further to facilitate subsequent practical applications such as calculation of condition numbers, the transaction data matrix X may be subjected to normalization processing based on the maximum singular values as:where max lambda (X) is the maximum singular value of the transaction data matrix X. Then, the matrix can be constructed by the existing quantum wires +.>Corresponding Hermitian matrix>Namely, preparing a quantum state containing the hermitian matrix A. At this time, the maximum eigenvalue of hermitian A is equal to matrix +.>Maximum singular value +.>
In practical applications, max λ (X) may be estimated based on the following conclusions of the matrix di-norms and F (Frobenius, freude Luo Beini us), specifically: transaction data matrix X Frobenius Fan Shuji is II X II F 2 norms of II X 2 The dimension is p, and the following conclusion is drawn:
thus, the first and second substrates are bonded together, frobenius norms XII can be used F Estimate and add II X II F As the maximum singular value upper bound max lambda (X) of the available X, the 2-norm solution difficulty is greater and may not be considered.
Due to the absolute value of the eigenvalue of the hermite matrix A and the matrix after normalizationHas the same singular value, can reflect the property of transaction data and condition number, and can be mapped and determined by the coordination pair of the hermitian matrix AAnd further determines the synergistic pair of the transaction data matrix X. And, in order to adapt the requirements of the sub-transformation to the matrix form (the form of hermitian is required), the subsequent processing of the transaction data matrix X may be replaced by hermitian a.
Specifically, the preparation of the eigenvalue quantum state carrying the eigenvalue information of hermitian matrix can be realized by constructing and operating the corresponding quantum phase estimation QPE line.
Among them, QPE (Quantum Phase Estimation ) is an important application of quantum fourier transform QFT, which is important in that it is the basis of many quantum algorithms, such as HHL algorithm, etc. The QPE quantum circuit mainly comprises: h door operation module, C-U j The operation (controlled U operator operation) module and the quantum inverse Fourier transform module, the solved essential problem is the eigenvalue estimation of the matrix, namely, the eigenvalue of the matrix is solved by the given matrix. The quantum state of hermite A can be converted into a eigenvalue quantum state containing each eigenvalue of hermite A through a QPE quantum line (in the quantum field, the quantum state is a superposition state, so that all eigenvalue information can be carried). In practical application, the conversion of the characteristic value quantum state is reasonably feasible by constructing other existing or improved quantum circuits, and the application is not limited to the conversion.
S202, obtaining at least n auxiliary qubits and 1 result qubit for outputting a comparison result;
specifically, since the eigenvalue quantum state corresponds to n-bit comparison quantum bits, n-bit auxiliary quantum bits input by a user and 1-bit result quantum bits for outputting a comparison result can be obtained.
Wherein, the n-bit auxiliary qubit can be used as a carry qubit. The method adopts a classical binary subtraction concept to carry out size comparison, and carries the quantum bit so as to be used for storing the carry of each bit corresponding to the characteristic value quantum state and each bit of the complement of the preset value. And finally, outputting a comparison result through the result qubit.
S203, a quantum logic gate of a quantum comparison circuit to be constructed is determined according to the preset value, and a quantum comparison circuit for comparing the characteristic value quantum state with the preset value is constructed and operated by combining n bits of the comparison quantum bit, n bits of the auxiliary quantum bit and 1 bit of the result quantum bit, so that a result quantum state representing a comparison result is output.
Specifically, a binary complement corresponding to the preset value may be calculated, and according to each bit of the binary complement, a quantum logic gate of the corresponding bit is determined, where when the bit is 0, the corresponding quantum logic gate is a Toffoli gate, and when the bit is 1, the corresponding quantum logic gate is a logic or gate.
It should be noted that, only when the first bit of the two's complement is 0, the corresponding quantum-free logic gate operates; when the first bit of the two's complement is 1, the corresponding CNOT gate operates. In a specific implementation, the logic OR gate (OR gate) may be constructed by a Toffoli gate and an X gate, and other quantum logic gates equivalent to Toffoli gates and logic OR gates are reasonably possible.
Specifically, a preset quantum logic gate can be obtained, the quantum logic gate and the preset quantum logic gate which are determined by corresponding to a preset value are added to corresponding quantum bits, and a quantum comparison circuit (the quantum comparison circuit is also a quantum circuit) for comparing the characteristic value quantum state with the preset value is obtained; and operating a quantum comparison circuit, and outputting a result quantum state representing a comparison result.
Fig. 3 is a schematic diagram of a quantum comparison circuit. Wherein i is 1 、i 2 …i n Representing the comparison qubit, a 1 、a 2 …a n Represents an auxiliary qubit, c represents a resulting qubit, t 1]、t[2]……t[n]Bit 1 (lowest) and bit … … (highest) of the two's complement representing the preset value. If t 1]=1, the corresponding determined quantum logic gate is defined by i 1 Bit control a 1 Bit CNOT gate, if t 1]=0, corresponding to determining no quantum logic gate; if t 2]=0, corresponding to the value defined by i 2 Bits, a 1 Bit control a 2 Bittoffoli gate, if t 2]=1, corresponding to the value defined by i 2 Bits, a 1 Bit control a 2 Bit logical OR gate, the rest of the same theory t 2]… … up to t [ n ]]=0, corresponding to the value defined by i n Bits, a n-1 Bit (a in the figure) n-1 Not shown) control a n Bittoffoli gate, if t [ n ]]=1, corresponding to the value defined by i n Bits, a n-1 Bit control a n A logic OR gate of the bits, the last quantum logic gate being formed by a n The bit controls a CNOT gate (namely a preset quantum logic gate) of c bits, and is used for outputting a result quantum state of the comparison result. The number n of the required qubits is related to the number of bits of the quantum state of the characteristic value and the magnitude of the preset value to be compared, and can be set according to specific requirements. In addition, as shown in fig. 4, one configuration manner of the logic or gate may be shown, in which the left side line includes 3X gates, 1 Toffoli gate, and 2X gates in sequence.
It will be appreciated by those skilled in the art that in classical computers, the basic unit of information is a bit, one bit having two states, 0 and 1, the most common physical implementation being to represent both states by the level of high and low. In quantum computing, the basic unit of information is a qubit, and one qubit also has two states of 0 and 1, which is marked as |0>And |1>But it can be in an overlapped state of two states of 0 and 1, and can be expressed asWherein a and b are represented by |0>State, |1>Complex numbers of state amplitudes (probability magnitudes), which are not possessed by classical bits. After measurement, the state of the qubit collapses to a definite state (eigenstate, here |0>State, |1>State), wherein the probability of collapsing to |0> is |a| 2 The probability of collapsing to |1> is |b| 2 ,|a| 2 +|b| 2 =1, | > is the dirac symbol.
Taking the foregoing as an example, the output c-bit result quantum state is an overlapped state, and can be obtained by measurement, when the |0> state is measured, the preset value is larger, and when the |1> state is measured, the opposite is indicated. However, the measurement can only measure the state |0> or the state |1> collapsed with a certain probability, and for this purpose, a plurality of measurements can be performed, and the number of measurements can be determined according to actual requirements. Theoretically, through multiple measurements, if the |0> state is measured through the multiple measurements, the preset value is considered to be larger than all value information in the characteristic value quantum state; if the |1> state is measured by multiple measurements, the preset value is considered to be smaller than or equal to all value information in the characteristic value quantum state; if there are multiple measurements of both the |0> and |1> states, the preset value is considered to be greater than some of the eigenvalue quantum states and less than others of the eigenvalue quantum states.
Assume that the eigenvalue quantum state isThe preset value is 4, and the two's complement is 100, so that the following can be obtained: n=3, t [1 ]]=0、t[2]=0、t[3]=1, the corresponding quantum comparison circuit comprises: 3 bit comparison qubit, 3 bit auxiliary qubit, 1 bit result qubit, further comprising in order: one is represented by i 2 Bit sum a 1 Bit control a 2 Bittoffoli gate, one by i 3 Bit sum a 2 Bit control a 3 Logical OR gate of bits, one of which is represented by a 3 Bits control a c-bit CNOT gate. Operating the corresponding quantum comparison circuit to obtain a c-bit result quantum state ofAssuming that 100 measurements are made, the number of times that |0> and |1> are measured is approximately half of each other, indicating that the preset value 4 is both greater than and less than the characteristic value quantum state, i.e., the comparison result is in a superposition state of greater than and less than.
Specifically, taking the application scenario as an example, the specific parameter is the reference condition number k i Is the reciprocal of the preset valuei is a non-negative integer. If the characteristic value of the characteristic value quantum state represented by the result quantum state is smaller than the preset value, adding 1 to i, and returning to execute the step of determining the quantum logic gate of the quantum comparison circuit to be constructed according to the preset value until the output result quantum state represents that the characteristic value quantum state does not exist and is smallUntil the preset value is reached; and determining the approximate estimation of the minimum eigenvalue in the eigenvalue quantum state according to the current preset value.
Exemplary, reference condition number k is constructed i Inverse, i.e. preset valueInitializing i=0; constructing and operating a quantum comparison circuit corresponding to the current preset value, if the measured result quantum state is |0>A state representing the presence of a certain characteristic value +.>Otherwise, ending; (since the maximum eigenvalue of the hermite matrix is normalized to 1, k is the first time compared 0 =1, resulting quantum state must be |0>State of the material
The resulting quantum state is |0>Adding 1 to i in state, updating the preset value of the reference condition number, and returning to execute the step of determining the quantum logic gate of the quantum comparison circuit to be constructed according to the preset value until the measured result quantum state is |1>And a state representing that no eigenvalue exists in the eigenvalue quantum state and is smaller than the reciprocal of the reference condition number. Suppose at this point the reference condition number increases to 2 m The method can obtain: 2 -m ≤minλ A <2 -m+1 I.e. the minimum eigenvalue min lambda of hermite matrix a A The estimated interval is [2 -m ,2 -m+1 ) Wherein m is a positive integer.
Specifically, in practical application, the condition number of the hermitian matrix can be calculated according to the approximate estimation of the maximum eigenvalue and the minimum eigenvalue of the hermitian matrix; and searching for a coordinating pair in the transaction data matrix according to the size of the condition number.
For example, the quotient of the maximum eigenvalue of the hermite matrix and the approximately estimated minimum eigenvalue may be determined as the condition number of the hermite matrix and as the condition number of the transaction data matrix.
In statistics, multiple collinearity refers to the case where some of the explanatory variables in the multiple regression model have a highly linear relationship. In order to detect and measure the degree of multiple co-linearity, condition numbers κ were introduced in the field of numerical analysis. For matrix X:
i.e. the ratio of the maximum singular value to the minimum singular value of X, in this application the quotient of the maximum value of the eigenvalue absolute value of the corresponding hermitian matrix a and the minimum value of the eigenvalue absolute value. The greater the condition number of the matrix, the more severe the degree of multiple collinearity. Multiple linearities can be detected by searching a large condition number system where the system is more likely to have synergistic pairs. Based on this, the collaborative pair existence problem corresponding to the statistical arbitrage (paired transaction) problem can be weakened into an estimation problem of the condition number size.
Taking the above example, the maximum eigenvalue of hermite matrix A is normalized to 1, and the minimum eigenvalue is estimated to be [2 ] -m ,2 -m+1 ) Obtaining a condition number estimation section of (2 m-1 ,2 m ]It is simply understood that any condition number within the interval may be taken as a particular value of the estimated condition number.
In practical application, the minimum eigenvalue of the hermitian matrix a may be processed into a preset fixed value, and the maximum eigenvalue upper bound of the hermitian matrix a is iteratively approximated by eigenvalue estimation, so as to obtain an estimation interval of the maximum eigenvalue, and further estimate the corresponding condition number.
Specifically, the cooperative pair refers to financial transaction data having a cooperative relationship. If the condition number is greater than the preset condition number, a coordination check may be performed to determine if a coordination pair exists; if it is determined that the cooperative pair exists, searching the cooperative pair in the hermite matrix; and obtaining the coordination pair in the target data matrix through mapping according to the coordination pair in the hermite matrix.
Specifically, in one implementation, if the estimated condition number is greater than or equal to the preset condition number, performing a coordination check to determine whether a coordination pair exists; if it is determined that the cooperative pair exists, searching the cooperative pair in the hermite matrix; and obtaining the coordination pairs in the transaction data matrix through mapping according to the coordination pairs in the hermite matrix. If the condition number is less than the preset condition number, or the coordination test fails, indicating that the transaction data matrix does not find a coordination pair.
Wherein the preset condition number may be set based on specific problem context and requirements. In practice, if the condition number of the matrix is too small, then it is considered that there are no synergistic pairs, otherwise it is considered that there is a high probability that there are synergistic pairs.
In the case where the condition number is equal to or greater than the preset condition number, that is, it is considered that there is a high possibility that there is a cooperative pair, a cooperative check may be performed at this time, for example, by using a quantum residual sequence generation algorithm or the like, to determine whether there is a cooperative pair really. The coordination test is passed, the existence of coordination pairs is indicated, then, a specific coordination pair can be found for the hermite matrix by adopting a method of quantum linear regression to judge the stability of a residual sequence and the like, and then, financial transaction data with coordination relations in the original transaction data matrix, such as a stock price vector, is obtained through mapping. The method for judging the stability of the residual sequence by using the quantum residual sequence generation algorithm and the quantum linear regression is the prior art, and the invention is not repeated here.
In the process, the problem can be simplified, namely, assuming that not only the stock price vectors are cooperated, but also the linear combination of the stock price vectors is constant, the residual sequence can be obtained by carrying out linear regression on the stock price vectors forming the matrix A, so that the stability of the residual sequence is judged, and the linear regression corresponding to the stable residual sequence is the stock price vector with the cooperated relation.
In the application scene of financial transaction, the parallel computing advantage of the quantum algorithm is exerted by weakening the cooperative pair existence problem corresponding to the statistical arbitrage (paired transaction) problem into the condition number size estimation problem, the computing complexity is reduced, the important pre-selection problem of the cooperative pair problem, namely condition number estimation, is rapidly solved, and the important data support advantage is provided for the statistical arbitrage; by realizing the application of the quantum algorithm in the field of financial transaction, the coordination pair with coordination relation in the financial transaction data can be searched, thereby meeting the requirement of high-frequency transaction, filling the blank of related technology, and having important open meaning and practical application value. It should be noted that the scenario of the financial transaction is merely an example, and is not meant to limit the present invention.
Therefore, the invention realizes the comparison of the characteristic value quantum state and the preset value, and further realizes the application of the quantum algorithm to matrix characteristic value estimation, thereby fully playing the advantages of quantum calculation, filling the important blank of the linear system quantum calculation direction, and having important open meaning and practical application value.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a quantum comparison device for matrix eigenvalues according to an embodiment of the present invention, corresponding to the flow shown in fig. 2, the device includes:
the data obtaining module 501 is configured to obtain a eigenvalue quantum state carrying eigenvalue information of a target data matrix, and a preset value of a specific parameter, where the eigenvalue quantum state corresponds to n comparison quantum bits used for comparing with the preset value;
a bit acquisition module 502, configured to acquire at least n auxiliary qubits and 1 result qubit for outputting a comparison result;
and the construction output module 503 is configured to determine a quantum logic gate of a quantum comparison circuit to be constructed according to the preset value, and construct and operate a quantum comparison circuit for comparing the characteristic value quantum state with the preset value by combining n bits of the comparison quantum bit, n bits of the auxiliary quantum bit and 1 bit of the result quantum bit, so as to output a result quantum state representing a comparison result.
Specifically, the target data matrix is an hermitian matrix, and before the data obtaining module, the method further includes:
and the construction evolution module is used for obtaining a quantum state containing the hermitian matrix, constructing and running a corresponding quantum phase estimation QPE circuit, and evolving the quantum state of the hermitian matrix into a characteristic value quantum state carrying characteristic value information of the hermitian matrix.
Specifically, the hermite matrix is a hermite matrix corresponding to the transaction data matrix, and the construction evolution module is specifically configured to:
and carrying out normalization processing on the maximum singular value of the transaction data matrix, and preparing a quantum state containing a hermite matrix corresponding to the transaction data matrix after normalization processing, wherein the maximum eigenvalue of the hermite matrix is equal to the maximum singular value 1 of the transaction data matrix after normalization processing.
Specifically, the specific parameter is the reference condition number k i Is the reciprocal of the preset value ofThe initial value of i is 0, and the device further comprises:
the execution module is used for adding 1 to the i when the result quantum state indicates that the characteristic value in the characteristic value quantum state is smaller than the preset value, and returning to the step of executing the quantum logic gate of the quantum comparison circuit to be constructed according to the preset value until the output result quantum state indicates that the characteristic value in the characteristic value quantum state is not smaller than the preset value;
and the determining module is used for determining the approximate estimation of the minimum characteristic value in the characteristic value quantum state according to the current preset value.
Specifically, the device further comprises:
the calculation module is used for calculating the condition number of the hermite matrix according to the approximate estimation of the maximum eigenvalue and the minimum eigenvalue of the hermite matrix;
and the searching module is used for searching the coordination pairs in the transaction data matrix according to the size of the condition number.
Specifically, the construction output module is specifically configured to:
and calculating the binary complement corresponding to the preset value, and determining a quantum logic gate of the corresponding bit according to each bit of the binary complement, wherein when the bit is 0, the corresponding quantum logic gate is a Toffoli gate, and when the bit is 1, the corresponding quantum logic gate is a logic OR gate.
Specifically, the construction output module is specifically configured to:
acquiring a preset quantum logic gate, and adding the quantum logic gate and the preset quantum logic gate which are determined corresponding to the preset value to corresponding quantum bits to obtain a quantum comparison circuit for comparing the characteristic value quantum state with the preset value;
and operating the quantum comparison circuit, and outputting a result quantum state representing a comparison result.
Therefore, the invention realizes the comparison of the characteristic value quantum state and the preset value, and further realizes the application of the quantum algorithm to matrix characteristic value estimation, thereby fully playing the advantages of quantum calculation, filling the important blank of the linear system quantum calculation direction, and having important open meaning and practical application value.
The embodiment of the invention also provides a storage medium, in which a computer program is stored, wherein the computer program is configured to perform the steps of any of the method embodiments described above when run.
Specifically, in the present embodiment, the above-described storage medium may be configured to store a computer program for executing the steps of:
s1, obtaining a characteristic value quantum state carrying characteristic value information of a target data matrix and a preset value of a specific parameter, wherein the characteristic value quantum state corresponds to n bits of comparison quantum bits for comparison with the preset value;
s2, obtaining at least n auxiliary qubits and 1 result qubit for outputting a comparison result;
s3, determining a quantum logic gate of a quantum comparison circuit to be constructed according to the preset value, constructing and operating the quantum comparison circuit for comparing the characteristic value quantum state with the preset value by combining n bits of the comparison quantum bit, n bits of the auxiliary quantum bit and 1 bit of the result quantum bit, and outputting a result quantum state representing a comparison result.
Specifically, in the present embodiment, the storage medium may include, but is not limited to: a usb disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing a computer program.
An embodiment of the invention also provides an electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to run the computer program to perform the steps of any of the method embodiments described above.
Specifically, the electronic apparatus may further include a transmission device and an input/output device, where the transmission device is connected to the processor, and the input/output device is connected to the processor.
Specifically, in the present embodiment, the above-described processor may be configured to execute the following steps by a computer program:
s1, obtaining a characteristic value quantum state carrying characteristic value information of a target data matrix and a preset value of a specific parameter, wherein the characteristic value quantum state corresponds to n bits of comparison quantum bits for comparison with the preset value;
s2, obtaining at least n auxiliary qubits and 1 result qubit for outputting a comparison result;
s3, determining a quantum logic gate of a quantum comparison circuit to be constructed according to the preset value, constructing and operating the quantum comparison circuit for comparing the characteristic value quantum state with the preset value by combining n bits of the comparison quantum bit, n bits of the auxiliary quantum bit and 1 bit of the result quantum bit, and outputting a result quantum state representing a comparison result.
While the foregoing is directed to embodiments of the present invention, other and further embodiments of the invention may be devised without departing from the basic scope thereof, and the scope thereof is determined by the claims that follow.