Symmetric matrix triangularization method and device, computer equipment and storage medium
Through reflection transformation and parallel computing technology of symmetric matrix, the problem of low matrix triangulation efficiency in the existing technology is solved, and triangulation decomposition and calculation efficiency improvement of any order are achieved.
Patent Information
- Application Number
- CN202411225618.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2024-12-17
AI Technical Summary
The existing matrix triangulation technology has rounding errors in the calculation process, and the engineering implementation is complex, making it difficult to support matrix triangulation of any order, resulting in inefficient calculations.
Through the reflection transformation of symmetric matrix, the column vector is calculated using the preset transformation matrix array vector and the preset process for parallel operation, the target matrix is divided into multiple target vectors, and parallel calculation is performed in a multi-core processor to simplify the iterative calculation expression to improve computing efficiency.
The triangulation of arbitrary order symmetric matrix is realized, which improves the calculation efficiency of matrix triangulation, reduces iterative computing time, and supports multi-core parallel computing to improve hardware efficiency.
Smart Images

Figure CN119149891A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of linear algebra, and in particular, to a method, apparatus, computer device and storage medium for triangulating a symmetric matrix. Background Art
[0002] The tridiagonalization technique of matrices is an important topic in linear algebra and numerical analysis, and has wide applications in mathematics, engineering, and computational science.
[0003] The tridiagonalization of a matrix is the process of converting a matrix into a tridiagonal matrix through similarity transformation. The so-called tridiagonal matrix refers to a principle in which all elements except the main diagonal and the elements above and below the diagonal are zero. This technology can be traced back to the problem of solving linear equations. The generation and development of the concept of matrix is closely related to solving linear equations. Specifically, the problem of matrix diagonalization is an important part of matrix theory. It plays a fundamental role in singular value decomposition, eigenvalue decomposition and simultaneous diagonal decomposition of orthogonal matrix blocks.
[0004] The main methods for tridiagonalization of matrices are: Jacobi iteration method, Gauss-Seidel method, block Gauss-Seidel method, Householder method, single leaf function parameter representation method, etc. In order to avoid rounding errors in the calculation process and improve the accuracy of the results, Jacobi iteration method and Householder method are generally selected in engineering.
[0005] The Jacobi iteration method eliminates the off-diagonal elements of the matrix through a series of orthogonal rotations to obtain a diagonal matrix. The Householder method uses the so-called "reflection" or "mirror" transformation to construct a series of Householder reflection matrices to change the lower triangular part of the matrix to 0 and achieve tridiagonalization. Compared with the Jacobi iteration method, the Householder method gradually reduces the complexity of the matrix through orthogonal reflection operations, so it converges faster and is particularly suitable for solving large-scale problems.
[0006] The engineering implementation of matrix tridiagonalization is relatively complex, iterative calculation, and time-consuming. As the order increases, the time often increases exponentially.
[0007] When tridiagonalization is generally implemented in engineering, the matrix order is usually fixed. If the order changes, the corresponding software and hardware codes need to be modified, and it is impossible to implement tridiagonalization of arbitrary order. Summary of the invention
[0008] Embodiments of the present application provide a method, apparatus, computer device, and storage medium for triangulating a symmetric matrix.
[0009] A first aspect of an embodiment of the present application provides a method for triangulating a symmetric matrix, comprising:
[0010] For each iterative calculation in the reflection transformation of the target symmetric matrix, determining a first target matrix operation expression for the current iterative calculation;
[0011] Converting the first target matrix operation into a second target matrix operation expression, wherein the variables of the second target matrix operation expression include the target symmetric matrix, a preset transformation matrix column vector, and a preset process calculation column vector;
[0012] Dividing the target symmetric matrix into a plurality of target vectors;
[0013] Each of the target vectors is stored in a different single core in the processor respectively, and the target elements corresponding to each of the target vectors in the preset transformation matrix column vector and the preset process calculation column vector are stored in the single core corresponding to the target vector; in the different single cores, each of the target vectors and the target elements is operated in parallel according to the second target matrix operation expression, and the matrix composed of the results of the different single core operations is used as the result of the current iterative calculation.
[0014] In an optional embodiment of the present application, the second target matrix operation expression includes: a first multiplication operation between the preset transformation matrix column vector and the conjugate transpose of the preset process calculation column vector; a second multiplication operation between the preset process calculation column vector and the conjugate transpose of the preset transformation matrix column vector; and a subtraction operation between the target symmetric matrix and the first multiplication operation result and the second multiplication operation result.
[0015] In an optional embodiment of the present application, in the different single cores, performing parallel operations on each of the target vectors and the target elements according to the second target matrix operation expression includes:
[0016] For each target vector in a single core, the following computations are performed in parallel:
[0017] Determine the first calculation element vectors in the preset transformation matrix column vector corresponding to the current target vector, the second calculation element vectors in the conjugate transpose of the preset transformation matrix column vector corresponding to the current target vector, the third calculation element vectors in the preset process calculation column vector corresponding to the current target vector, and the fourth calculation element vectors in the conjugate transpose of the preset process calculation column vector corresponding to the current target vector;
[0018] Performing a multiplication operation on the first calculation element vector and the fourth calculation element vector to obtain a first multiplication operation matrix;
[0019] Performing a multiplication operation on the third calculation element vector and the second calculation element vector to obtain a second multiplication operation matrix;
[0020] The current target vector performs a subtraction operation on the first multiplication operation matrix and the second multiplication operation matrix to obtain a result of the current single-core operation.
[0021] In an optional embodiment of the present application, when the target vector is a row vector, determining the first calculation element vectors in the preset transformation matrix column vector corresponding to the current target vector, the second calculation element vectors in the conjugate transpose of the preset transformation matrix column vector corresponding to the current target vector, the third calculation element vectors in the preset process calculation column vector corresponding to the current target vector, and the fourth calculation element vectors in the conjugate transpose of the preset process calculation column vector corresponding to the current target vector, includes:
[0022] In the case where the current target vector is a vector composed of elements of the nth row of the target symmetric matrix, the first calculated element vector includes the nth element in the preset transformation matrix column vector; the second calculated element vector includes the nth element to the last element in the conjugate transpose of the preset transformation matrix column vector; the third calculated element vector includes the nth element in the preset process calculation column vector; and the fourth calculated element vector includes the nth element to the last element in the conjugate transpose of the preset process calculation column vector.
[0023] In an optional embodiment of the present application, when the target vector is a column vector, the process of determining the target elements in the preset transformation matrix column vector and the preset process calculation column vector respectively corresponding to the current target vector includes:
[0024] In the case where the current target vector is a vector composed of the elements of the nth column of the target symmetric matrix, the first calculation element vector includes the nth element to the last element in the preset transformation matrix column vector; the second calculation element vector includes the nth element in the conjugate transpose of the preset transformation matrix column vector; the third calculation element vector includes the nth element to the last element in the preset process calculation column vector; and the fourth calculation element vector includes the nth element in the conjugate transpose of the preset process calculation column vector.
[0025] In an optional embodiment of the present application, the method further includes:
[0026] Determining, according to the number of the single cores and the order of the target alignment matrix, the target vector corresponding to the single core for each iteration calculation;
[0027] When the number of the single cores is less than the order of the target alignment matrix, the number of the target vectors corresponding to the single cores calculated in each iteration exceeds one.
[0028] In an optional embodiment of the present application, the method further includes:
[0029] While performing parallel operations on the target vectors and the target elements, a next target vector corresponding to a next operation in the single core is determined, and the next target vector is stored in the single core.
[0030] A second aspect of an embodiment of the present application provides a symmetric matrix triangulation device, comprising:
[0031] A determination module, for determining a first target matrix operation expression for a current iteration calculation for each iteration calculation in a reflection transformation of a target symmetric matrix;
[0032] A conversion module, used for converting the first target matrix operation into a second target matrix operation expression, wherein the variables of the second target matrix operation expression include the target symmetric matrix and a preset transformation matrix column vector and a preset process calculation column vector;
[0033] A division module, used for dividing the target symmetric matrix into a plurality of target vectors;
[0034] An operation module is used to store each of the target vectors in a different single core in the processor, and store the target elements corresponding to each of the target vectors in the preset transformation matrix column vector and the preset process calculation column vector in the single core corresponding to the target vector; in the different single cores, each of the target vectors and the target elements is operated in parallel according to the second target matrix operation expression, and a matrix composed of the results of the different single core operations is used as the result of the current iterative calculation.
[0035] According to a third aspect of an embodiment of the present application, a computer device is provided, comprising: a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of any of the above symmetric matrix triangulation methods are implemented.
[0036] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of any of the above methods for triangulating a symmetric matrix.
[0037] The above technical solution provided by the embodiment of the present application has at least some or all of the following advantages compared with the prior art:
[0038] The symmetric matrix triangulation method described in the embodiment of the present application determines a first target matrix operation expression for the current iterative calculation for each iterative calculation in the reflection transformation of the target symmetric matrix; converts the first target matrix operation into a second target matrix operation expression, wherein the variables of the second target matrix operation expression include the target symmetric matrix and a preset transformation matrix column vector and a preset process calculation column vector; divides the target symmetric matrix into multiple target vectors; stores each of the target vectors in a different single core in the processor, stores the target elements corresponding to each of the target vectors in the preset transformation matrix column vector and the preset process calculation column vector in the single core corresponding to the target vector, and in the different single cores, performs parallel operations on each of the target vectors and the target elements according to the second target matrix operation expression, and uses the matrix composed of the results of the different single core operations as the result of the current iterative calculation, not only supports the tridiagonal decomposition of a symmetric matrix of any order by dividing the target symmetric matrix into multiple target vectors, and the corresponding tridiagonal decomposition can be completed by using the order as an input parameter, but also utilizes multi-core parallel operations to improve the computational efficiency of symmetric matrix triangulation. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0040] Figure 1 A flowchart of a method for triangulating a symmetric matrix provided in one embodiment of the present application;
[0041] Figure 2 A schematic diagram of which row of the target symmetric matrix is processed by each single core in each iteration according to an embodiment of the present application;
[0042] Figure 3 A schematic diagram of elements for calculating the corresponding operation of one row of a target symmetric matrix and vectors v and w in a single core provided by an embodiment of the present application;
[0043] Figure 4 An overall schematic diagram of single-core processing provided by one embodiment of the present application;
[0044] Figure 5 A schematic diagram of the structure of a symmetric matrix triangulation device provided in one embodiment of the present application;
[0045] Figure 6 A schematic diagram of the computer device structure provided for one embodiment of the present application. DETAILED DESCRIPTION
[0046] In the process of implementing the present application, the inventors found that the current method of generating pseudo-random sequences is relatively poor in efficiency and versatility.
[0047] In response to the above problems, the embodiments of the present application provide a method, apparatus, computer device and storage medium for triangulating a symmetric matrix to improve the efficiency of tridiagonalizing a symmetric matrix and support symmetric matrices of any order.
[0048] The solutions in the embodiments of the present application can be implemented using various computer languages, for example, the object-oriented programming language Java and the interpreted scripting language JavaScript.
[0049] In order to make the technical solutions and advantages in the embodiments of the present application more clearly understood, the exemplary embodiments of the present application are further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than an exhaustive list of all the embodiments. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.
[0050] See also Figure 1 The symmetric matrix triangulation method provided in the embodiment of the present application includes the following steps 100 to 300:
[0051] Step 100: For each iterative calculation in the reflection transformation of the target symmetric matrix, determine the first target matrix operation expression used for the current iterative calculation.
[0052] The target symmetric matrix may be an n-order symmetric matrix, where n≥2.
[0053] The process of triangulating a symmetric matrix involves converting the matrix into triangular form using a reflection transformation. In each iteration, the reflection transformation aims to convert one column (or row) of the symmetric matrix to zero, except for the diagonal elements.
[0054] The first target matrix operation expression for the current iteration calculation can be A (k+1) =H k A (k) H k or A (k+1) =H k H A (k) H k , where A (k+1) is the target symmetric matrix after the kth iteration, A (k) is the target symmetric matrix before the kth iteration, H k is the reflection matrix used in the kth iteration of the target symmetric matrix, H k H Hk The conjugate transposed matrix of .
[0055] H k It can be constructed by the following steps: select the kth column (or row) of the target symmetric matrix A as the non-zero vector v; construct a unit vector u such that u T v is a scalar, and u T u=1;H k =I-2uu T .
[0056] H k The calculation expression includes but is not limited to: k =I-τvv H , H k =I-2uu T , H k =I-2vv T , where τ is the reflection operation parameter.
[0057] Step 200: Convert the first target matrix operation into a second target matrix operation expression, wherein the variables of the second target matrix operation expression include the target symmetric matrix and a preset transformation matrix column vector and a preset process calculation column vector.
[0058] Among them, the second target matrix operation expression is: k The calculation expression of is substituted into the first target matrix operation expression to obtain the result. The preset transformation matrix column vector may be the non-zero vector v, and the preset process calculation column vector may be calculated based on the target matrix A and the non-zero vector v.
[0059] Step 300: Divide the target symmetric matrix into multiple target vectors.
[0060] Among them, each of the target vectors can be a row or a column in the target symmetric matrix.
[0061] Step 400: store each of the target vectors in a different single core in the processor, store the target elements corresponding to each of the target vectors in the preset transformation matrix column vector and the preset process calculation column vector in the single core corresponding to the target vector, and in the different single cores, perform parallel operations on each of the target vectors and the target elements according to the second target matrix operation expression, and use the matrix composed of the results of the different single core operations as the result of the current iterative calculation.
[0062] Among them, the target symmetric matrix, the preset transformation matrix column vector and the preset process calculation column vector are decomposed, and the target elements corresponding to each target vector in the decomposed target vector, the preset transformation matrix column vector and the preset process calculation column vector are used as variables of the second target matrix operation expression, and are respectively calculated in parallel in different single cores, so that the calculation speed of each iteration of the target symmetric matrix is accelerated, thereby improving the implementation efficiency of the triangulation of the target symmetric matrix.
[0063] The symmetric matrix triangulation method of the present application simplifies the operation expression of each iterative calculation in the reflection transformation of the target symmetric matrix, decomposes the variables in the simplified operation expression, and parallelly calculates the decomposed variables in different single cores according to the simplified operation expression, thereby improving the efficiency of each iterative calculation in the reflection transformation, thereby improving the implementation speed of the triangulation of the target symmetric matrix.
[0064] In an optional embodiment of the present application, the second target matrix operation expression includes: a first multiplication operation between the preset transformation matrix column vector and the conjugate transpose of the preset process calculation column vector; a second multiplication operation between the preset process calculation column vector and the conjugate transpose of the preset transformation matrix column vector; and a subtraction operation between the target symmetric matrix and the first multiplication operation result and the second multiplication operation result.
[0065] Among them, the first target matrix operation expression used for the current iteration calculation is H k The calculation expression is H k =I-τvv H In the case of, converting the first target matrix operation into a second target matrix operation expression comprises:
[0066]
[0067] Let x = τAv,
[0068]
[0069] In the embodiment of the present application, the first target matrix operation expression is converted into the second target matrix operation expression through a series of orthogonal transformations of the mirror reflection operator, so that the calculation of a single iteration is simplified to the matrix operation between the matrix A and the preset transformation matrix vector v and the preset process calculation vector w, where v and v are both column vectors, vw H and wv HAfter calculation, they are all matrices. Through subtraction operations between the three matrices, the updated matrix is obtained for use in the next iteration. By simplifying the operational expressions of the word iterative calculation, the efficiency of the single iterative calculation is improved, thereby improving the overall implementation efficiency of the target symmetric matrix triangulation.
[0070] In an optional embodiment of the present application, in the different single cores, performing parallel operations on each of the target vectors and the target elements according to the second target matrix operation expression includes:
[0071] For each target vector in a single core, the following computations are performed in parallel:
[0072] Determine the first calculation element vectors in the preset transformation matrix column vector corresponding to the current target vector, the second calculation element vectors in the conjugate transpose of the preset transformation matrix column vector corresponding to the current target vector, the third calculation element vectors in the preset process calculation column vector corresponding to the current target vector, and the fourth calculation element vectors in the conjugate transpose of the preset process calculation column vector corresponding to the current target vector;
[0073] Performing a multiplication operation on the first calculation element vector and the fourth calculation element vector to obtain a first multiplication operation matrix;
[0074] Performing a multiplication operation on the third calculation element vector and the second calculation element vector to obtain a second multiplication operation matrix;
[0075] The current target vector performs a subtraction operation on the first multiplication operation matrix and the second multiplication operation matrix to obtain a result of the current single-core operation.
[0076] Among them, the first calculation element vector includes the elements in the preset transformation matrix vector v that correspond to the current target vector respectively, the second calculation element vector includes the elements in the conjugate transpose of the preset transformation matrix vector v that correspond to the current target vector respectively, the third calculation element vector includes the elements in the preset process calculation vector w that correspond to the current target vector respectively, and the fourth calculation element vector includes the elements in the conjugate transpose of the preset process calculation vector w that correspond to the current target vector respectively.
[0077] In an embodiment of the present application, for each iteration of triangulation of the target symmetric matrix, multiplication operations of two vectors and subtraction operations between three matrices are required. In order to improve the calculation speed of each iteration, the multiplication operation of the two vectors is decomposed into multiple vector operations performed in pairs, and the subtraction operation between the three matrices is decomposed into subtraction operations between three vectors, and they are run in parallel in different single cores, so that the calculation of each iteration is decomposed into multiple small operations executed in parallel, thereby speeding up the calculation speed of each iteration.
[0078] In an optional embodiment of the present application, when the target vector is a row vector, determining the first calculation element vectors in the preset transformation matrix column vector corresponding to the current target vector, the second calculation element vectors in the conjugate transpose of the preset transformation matrix column vector corresponding to the current target vector, the third calculation element vectors in the preset process calculation column vector corresponding to the current target vector, and the fourth calculation element vectors in the conjugate transpose of the preset process calculation column vector corresponding to the current target vector, includes:
[0079] In the case where the current target vector is a vector composed of elements of the nth row of the target symmetric matrix, the first calculated element vector includes the nth element in the preset transformation matrix column vector; the second calculated element vector includes the nth element to the last element in the conjugate transpose of the preset transformation matrix column vector; the third calculated element vector includes the nth element in the preset process calculation column vector; and the fourth calculated element vector includes the nth element to the last element in the conjugate transpose of the preset process calculation column vector.
[0080] See also Figure 2 In each iterative calculation of the target symmetric matrix, in a single core, a row of elements of the target symmetric matrix is selected and operated with corresponding elements selected from the preset transformation matrix column vector, the conjugate transpose of the preset transformation matrix column vector, the preset process calculation column vector and the conjugate transpose of the preset process calculation column vector.
[0081] In the actual operation process, some elements in a row of the target symmetric matrix are selected, wherein the some elements are the elements in the current row except the elements on the diagonal and in front of the diagonal in the target symmetric matrix. Figure 2As shown in the figure, when calculating with a single core, the elements of the fourth row of matrix A (from the fifth element to the last element) are taken and stored, that is, the elements of matrix A; then the fourth element of the two vectors v and w and all the elements after the fourth element are taken and stored separately to facilitate the calculation of the fourth row of the new matrix. In each iteration, each single core takes different data according to the number of rows of the new matrix it calculates, and so on. Which core calculates which row of matrix A is ultimately determined by the total number of iterations i and the calculation starting position of the single core.
[0082] In the embodiment of the present application, the operation in each single core is performed on some elements in a row of the target symmetric matrix, and only relevant elements are taken in the single core for single-row calculation, which reduces the element storage in the single core, reduces the amount of calculation between matrices, and improves the calculation speed of the single core, thereby improving the calculation efficiency of a single iteration and the triangulation of the entire target symmetric matrix.
[0083] In an optional embodiment of the present application, when the target vector is a column vector, the process of determining the target elements in the preset transformation matrix column vector and the preset process calculation column vector respectively corresponding to the current target vector includes:
[0084] In the case where the current target vector is a vector composed of the elements of the nth column of the target symmetric matrix, the first calculation element vector includes the nth element to the last element in the preset transformation matrix column vector; the second calculation element vector includes the nth element in the conjugate transpose of the preset transformation matrix column vector; the third calculation element vector includes the nth element to the last element in the preset process calculation column vector; and the fourth calculation element vector includes the nth element in the conjugate transpose of the preset process calculation column vector.
[0085] In each iterative calculation of the target symmetric matrix, in a single core, a column of elements of the target symmetric matrix is selected and operated with corresponding elements selected from the preset transformation matrix column vector, the conjugate transpose of the preset transformation matrix column vector, the preset process calculation column vector and the conjugate transpose of the preset process calculation column vector.
[0086] In the actual operation process, some elements in a column of the target symmetric matrix are selected, wherein the some elements are the elements in the current column except the elements on and above the diagonal of the target symmetric matrix.
[0087] The operation in each single core of the embodiment of the present application is performed on some elements in a column of the target symmetric matrix, which converts the complex matrix operation that consumes memory space into a mathematical calculation between the target vector and two single-point values, reduces the amount of operations between matrices, simplifies the complexity of updating the target symmetric matrix, saves memory space, and improves the operation speed of the single core, thereby improving the computational efficiency of a single iteration and the triangulation of the entire target symmetric matrix.
[0088] In an optional embodiment of the present application, the method further includes:
[0089] Determining, according to the number of the single cores and the order of the target alignment matrix, the target vector corresponding to the single core for each iteration calculation;
[0090] When the number of the single cores is less than the order of the target alignment matrix, the number of the target vectors corresponding to the single cores calculated in each iteration exceeds one.
[0091] See also Figure 3 , taking the target confrontation matrix as an example where the order is 32, the number of single cores is 16, and the target vector is the row vector of the target confrontation matrix, the single cores include cores 0 to 15. When the iteration number i=1, core 0 processes the first row of the matrix, core 1 processes the second row, and so on. When processing the 17th row of the matrix, it switches back to core 0 for processing, and so on. When the iteration number i=2, core 0 processes the second row of the matrix, core 1 processes the third row, and so on. When processing the 18th row of the matrix, it switches back to core 0 for processing, and so on. Use these 16 cores to process in a loop, and the starting row of the matrix to be processed is different according to the number of iterations. When the number of rows of the matrix to be processed exceeds 16 rows and does not exceed 32 rows, each iteration requires two single core calculations, and each iteration has two target vectors for each single core.
[0092] The embodiment of the present application uses 16 single cores to simultaneously and concurrently calculate the corresponding rows of the target matrix according to the number of rows. The number of calculation cycles within the single core is controlled through the sequential mapping relationship between the number of iterations and the plurality of single cores to achieve the result of updating the complete update matrix. The balance between hardware area and computing efficiency is achieved through the flexible setting of the number of single cores.
[0093] In an optional embodiment of the present application, the method further includes:
[0094] While performing parallel operations on the target vectors and the target elements, a next target vector corresponding to a next operation in the single core is determined, and the next target vector is stored in the single core.
[0095] See also Figure 4, taking the target vector as a row vector of the target alignment matrix as an example, during the operation of the target vector and the target element in the single core, other rows of the target alignment matrix can be moved to another address block in the single core through the shared memory DDR (Double Data Rate) for the next operation in the single core.
[0096] In the embodiment of the present application, during the operation of the target vector and the target element in a single core, the next target vector is stored in the single core, thereby realizing parallel calculation and transmission in the single core, saving transmission time in the single core, improving the calculation efficiency of the single core, and thus improving the efficiency of triangulation of the entire target symmetric matrix.
[0097] In an optional embodiment of the present application, when iteratively calculating the target symmetric matrix, it also includes updating the model to be processed, where the model to be processed refers to the model used when updating the target symmetric matrix, and the updating process is implemented based on a SIMD architecture system, and the SIMD architecture system includes multiple computing units; the updating process includes:
[0098] Split the data model to be processed into multiple data processing sub-models;
[0099] Sending each of the data processing sub-models to each of the computing units for parallel iterative calculations to obtain calculation results of each of the computing units;
[0100] Integrate and process the calculation results according to a preset data processing method to obtain an iterative calculation result of the data model to be processed;
[0101] For each iterative operation, the obtained iterative calculation result and the displacement amount when merging in the corresponding divide-and-conquer method are sent to each of the calculation units for parallel iterative operation to obtain each array element respectively;
[0102] Each of the array elements is integrated to obtain an updated calculation array.
[0103] In an optional embodiment of the present application, the data model to be processed is:
[0104] v(i)=(orig(j)+tau(j)-delta(i))*(1 / (delta(j)-delta(i)))
[0105] Correspondingly, the plurality of data processing sub-models include at least one of the following two data processing sub-models:
[0106] The first data processing sub-model: orig(j)+tau(j)-delta(i)
[0107] Second data processing submodel: 1 / (delta(j)-delta(i))
[0108] Among them, (orig(j)+tau(j)-delta(i))*(1 / (delta(j)-delta(i))) represents the data model to be processed, v(i) represents the single vector eigenvalue obtained by the i-th solution, orig(j) represents the vertical initial vector eigenvalue of the matrix, tau(j) represents the vertical correction scaling factor of the vector eigenvalue in the vertical direction of the matrix, delta(i) represents the horizontal displacement when merging arrays in the divide-and-conquer method, delta(j) represents the vertical displacement when merging arrays in the divide-and-conquer method, i represents the horizontal index of the matrix, j represents the vertical index of the matrix, and i≠j.
[0109] In an optional embodiment of the present application, the plurality of data processing sub-models include the first data processing sub-model and the second data processing sub-model. Correspondingly, the calculation results are integrated and processed according to a preset data processing method to obtain the iterative calculation result of the data model to be processed, including:
[0110] The first calculation result of the first data processing sub-model and the second calculation result of the second data processing sub-model are multiplied to obtain the iterative calculation result.
[0111] In an optional embodiment of the present application, for the first data processing sub-model, sending each of the data processing sub-models to each of the computing units for parallel iterative calculations to obtain calculation results of each of the computing units at least includes:
[0112] Sending each of the lateral displacements to each of the calculation units respectively, and sending the first sum of the first longitudinal initial eigenvalue and the first longitudinal correction scaling factor to each of the calculation units respectively for parallel iterative calculation to obtain a first iterative calculation result;
[0113] The sums of the other longitudinal initial eigenvalues and the corresponding longitudinal correction scaling factors are sequentially sent to the calculation units for parallel iterative calculations, and the iterative calculation results are sequentially obtained;
[0114] For each of the calculation units, all iterative calculation results are integrated to obtain a first calculation result of the calculation unit; wherein the first calculation result refers to the calculation result of the first data processing sub-model.
[0115] First data processing sub-model: orig(j)+tau(j)-delta(i) multiplication parallel calculation iterative operation process can be: delta(1), delta(2), ..., delta(m) are sent to m computing units respectively, then orig(1)+tau(1) is sent to m computing units, and calculation instructions are sent, and m computing units calculate orig(1)+tau(1)-delta(1), orig(1)+tau(1)-delta(2), ... , orig(1)+tau(1)-delta(m), retain the first iterative operation result; then send orig(2)+tau(2) to m computing units, m computing units perform multiplication operations and retain the first iterative operation result, until all iterative operation results are obtained, and all iterative operation results are multiplied to obtain the above-mentioned first calculation result, and so on, the first data processing sub-model (orig(j)+tau(j)-delta(i)) part of m single vector eigenvalues v(i) can be calculated in parallel. In this way, the embodiment of the present application gives full play to the architectural advantage of SIMD, that is, a single instruction controls multiple computing units to calculate in parallel, greatly improving the computing efficiency.
[0116] In an optional embodiment of the present application, for the second data processing sub-model, sending each of the data processing sub-models to each of the computing units for parallel iterative calculations to obtain calculation results of each of the computing units at least includes:
[0117] Sending each of the lateral displacements to each of the calculation units respectively;
[0118] Sending the first longitudinal displacement to each of the calculation units respectively, and each of the calculation units respectively calculating the difference between the first longitudinal displacement and each of the lateral displacements;
[0119] The other longitudinal displacements are sent to the calculation units in sequence, and the calculation units calculate the difference between the other longitudinal displacements and the lateral displacements in sequence;
[0120] The difference values obtained each time are integrated and the inverse is calculated to obtain the second calculation result of each calculation unit; wherein the second calculation result refers to the calculation result of the second data processing sub-model.
[0121] The second calculation result refers to the calculation result of the second data processing sub-model. The process of calculating the second calculation result of the second data processing sub-model (1 / (delta(j)-delta(i))) is as follows: firstly calculate the multiplication result of delta(j)-delta(i), and then find the inverse of the result. The specific process may include: sending delta(1), delta(2), ..., delta(m) to m computing units respectively, and then sending delta(1) to m computing units respectively, sending calculation instructions, and the m computing units will calculate delta(1)-delta(1), delta(1)-delta(2), ..., delta(1)-delta(m) respectively, and then sending delta(2) to m computing units, when j=i, replacing delta(j)-delta(i) with 1, performing multiplication operations on m computing units and retaining the results, and so on, and finally taking the inverse of the multiplication results, and the second data processing sub-model (1 / (delta(j)-delta(i))) of m v(i) can be calculated in parallel. The embodiment of the present application gives full play to the architectural advantages of SIMD in this way, that is, a single instruction controls multiple computing units to calculate in parallel, thereby greatly improving computing efficiency.
[0122] In an optional embodiment of the present application, for each iterative operation, the obtained iterative calculation result and the displacement amount when merging in the corresponding divide-and-conquer method are sent to each of the computing units for parallel iterative operation to obtain each array element respectively, including:
[0123] Sending the first calculation result and the first longitudinal displacement to each of the calculation units respectively, and each of the calculation units respectively calculates the first array element;
[0124] The other calculation results and the corresponding other longitudinal displacements are sent to each of the calculation units in turn, and each of the calculation units calculates and obtains other array elements respectively.
[0125] The specific process of determining each array element is as follows: first, v(1) and delta(1) are sent to m computing units respectively, and v(1)*(1 / (orig(1)-delta(1)+tau(1))), v(1)*(1 / (orig(2)-delta(1)+tau(2))), ..., v(1)*(1 / (orig(m)-delta(1)+tau(m))) are calculated respectively, and Q(1, 1), Q(1, 2), ..., Q(1, m) are obtained, and so on, and all the elements from the 1st column to the mth column of the array Q are obtained, and finally all the array elements of the array Q are obtained.
[0126] It should be understood that, although the various steps in the flow chart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the figure may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0127] See also Figure 5 An embodiment of the present application provides a symmetric matrix triangulation device 600, comprising:
[0128] A determination module 510, for determining a first target matrix operation expression for a current iteration calculation for each iteration calculation in a reflection transformation of a target symmetric matrix;
[0129] A conversion module 520, configured to convert the first target matrix operation into a second target matrix operation expression, wherein the variables of the second target matrix operation expression include the target symmetric matrix and a preset transformation matrix column vector and a preset process calculation column vector;
[0130] A division module 530, configured to divide the target symmetric matrix into a plurality of target vectors;
[0131] The operation module 540 is used to store each of the target vectors in a different single core in the processor, and store the target elements corresponding to each of the target vectors in the preset transformation matrix column vector and the preset process calculation column vector in the single core corresponding to the target vector; in the different single cores, each of the target vectors and the target elements is operated in parallel according to the second target matrix operation expression, and the matrix composed of the results of the different single core operations is used as the result of the current iterative calculation.
[0132] For the specific definition of the above-mentioned device 500, please refer to the definition of the symmetric matrix triangulation method above, which will not be repeated here. Each module in the above-mentioned device 500 can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0133] In one embodiment, a computer device is provided, the internal structure diagram of which can be as follows: Figure 6As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a symmetric matrix triangulation method as described above is implemented. It includes: a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, any step in the symmetric matrix triangulation method as described above is implemented.
[0134] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, any step in the above symmetric matrix triangulation method can be implemented.
[0135] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0136] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0137] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1A function specified in one or more boxes.
[0138] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0139] Although the preferred embodiments of the present application have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0140] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for triangulating a symmetric matrix, characterized in that: include: For each iterative calculation in the reflection transformation of the target symmetric matrix, determining a first target matrix operation expression for the current iterative calculation; Converting the first target matrix operation into a second target matrix operation expression, wherein the variables of the second target matrix operation expression include the target symmetric matrix, a preset transformation matrix column vector, and a preset process calculation column vector; Dividing the target symmetric matrix into a plurality of target vectors; Each of the target vectors is stored in a different single core in the processor respectively, and the target elements corresponding to each of the target vectors in the preset transformation matrix column vector and the preset process calculation column vector are stored in the single core corresponding to the target vector; in the different single cores, each of the target vectors and the target elements is operated in parallel according to the second target matrix operation expression, and the matrix composed of the results of the different single core operations is used as the result of the current iterative calculation.
2. The method according to claim 1, characterized in that The second target matrix operation expression includes: a first multiplication operation between the preset transformation matrix column vector and the conjugate transpose of the preset process calculation column vector; a second multiplication operation between the preset process calculation column vector and the conjugate transpose of the preset transformation matrix column vector; and a subtraction operation between the target symmetric matrix and the first multiplication operation result and the second multiplication operation result.
3. The method according to claim 2, characterized in that The performing parallel operations on the target vectors and the target elements in the different single cores according to the second target matrix operation expression includes: For each target vector in a single core, the following computations are performed in parallel: Determine the first calculation element vectors in the preset transformation matrix column vector corresponding to the current target vector, the second calculation element vectors in the conjugate transpose of the preset transformation matrix column vector corresponding to the current target vector, the third calculation element vectors in the preset process calculation column vector corresponding to the current target vector, and the fourth calculation element vectors in the conjugate transpose of the preset process calculation column vector corresponding to the current target vector; Performing a multiplication operation on the first calculation element vector and the fourth calculation element vector to obtain a first multiplication operation matrix; Performing a multiplication operation on the third calculation element vector and the second calculation element vector to obtain a second multiplication operation matrix; The current target vector performs a subtraction operation on the first multiplication operation matrix and the second multiplication operation matrix to obtain a result of the current single-core operation.
4. The method according to claim 3, characterized in that In the case where the target vector is a row vector, determining first calculation element vectors in the preset transformation matrix column vector corresponding to the current target vector, second calculation element vectors in the conjugate transpose of the preset transformation matrix column vector corresponding to the current target vector, third calculation element vectors in the preset process calculation column vector corresponding to the current target vector, and fourth calculation element vectors in the conjugate transpose of the preset process calculation column vector corresponding to the current target vector, includes: In the case where the current target vector is a vector composed of elements of the nth row of the target symmetric matrix, the first calculated element vector includes the nth element in the preset transformation matrix column vector; the second calculated element vector includes the nth element to the last element in the conjugate transpose of the preset transformation matrix column vector; the third calculated element vector includes the nth element in the preset process calculation column vector; and the fourth calculated element vector includes the nth element to the last element in the conjugate transpose of the preset process calculation column vector.
5. The method according to claim 3, characterized in that: In the case where the target vector is a column vector, the process of determining the target elements respectively corresponding to the current target vector in the preset transformation matrix column vector and the preset process calculation column vector includes: In the case where the current target vector is a vector composed of the elements of the nth column of the target symmetric matrix, the first calculation element vector includes the nth element to the last element in the preset transformation matrix column vector; the second calculation element vector includes the nth element in the conjugate transpose of the preset transformation matrix column vector; the third calculation element vector includes the nth element to the last element in the preset process calculation column vector; and the fourth calculation element vector includes the nth element in the conjugate transpose of the preset process calculation column vector.
6. The method according to claim 1, characterized in that The method further comprises: Determining, according to the number of the single cores and the order of the target alignment matrix, the target vector corresponding to the single core for each iteration calculation; When the number of the single cores is less than the order of the target alignment matrix, the number of the target vectors corresponding to the single cores calculated in each iteration exceeds one.
7. The method according to claim 6, characterized in that The method further comprises: While performing parallel operations on the target vectors and the target elements, a next target vector corresponding to a next operation in the single core is determined, and the next target vector is stored in the single core.
8. A symmetric matrix triangulation device, characterized in that: include: A determination module, for determining a first target matrix operation expression for a current iteration calculation for each iteration calculation in a reflection transformation of a target symmetric matrix; A conversion module, used for converting the first target matrix operation into a second target matrix operation expression, wherein the variables of the second target matrix operation expression include the target symmetric matrix and a preset transformation matrix column vector and a preset process calculation column vector; A division module, used for dividing the target symmetric matrix into a plurality of target vectors; An operation module is used to store each of the target vectors in a different single core in the processor, and store the target elements corresponding to each of the target vectors in the preset transformation matrix column vector and the preset process calculation column vector in the single core corresponding to the target vector; in the different single cores, each of the target vectors and the target elements is operated in parallel according to the second target matrix operation expression, and a matrix composed of the results of the different single core operations is used as the result of the current iterative calculation.
9. A computer device comprising: It comprises a memory and a processor, wherein the memory stores a computer program, and is characterized in that when the processor executes the computer program, the steps of the symmetric matrix triangulation method described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the symmetric matrix triangulation method according to any one of claims 1 to 7 are implemented.
