A multi-mode computing framework and method with adjustable precision for solving singular values
By introducing high-precision and mixed precision modes into the multi-mode computing framework for solving singular values, the rounding error and calculation time problems are solved, and the flexibility of accuracy and speed is achieved, which meets different needs and improves the accuracy of calculation and efficiency.
Patent Information
- Application Number
- CN202210477739.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-05
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2042-05-05
AI Technical Summary
The prior art has accumulated rounding errors when solving matrix singular values, resulting in inaccurate results, especially in large-scale matrix calculations, which are too long to meet the different accuracy requirements of users.
Provide a multi-mode computing framework with adjustable accuracy for solving singular values, including original mode, high-precision mode and mixed precision mode. Through error-free conversion technology and mixed precision ideas, the rounding error accumulation and calculation overhead are reduced respectively to achieve accuracy. and flexible adjustment of speed.
It improves the accuracy and speed of calculation results, especially in pathological problems, reduces rounding errors, reduces calculation time, meets different accuracy requirements, and is universal and universal.
Smart Images

Figure CN114861129B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a multi-mode computing framework and method for solving singular values with adjustable precision. Background Art
[0002] Singular value decomposition (SVD) is widely used in scientific research, medical services, urban construction, and life and leisure, such as rolling bearing diagnosis, phase space growth rate research, digital watermarking technology, enhancing the resolution of seismic data, and micro-expression recognition models. It is one of the most useful tools of linear algebra in matrix analysis. Therefore, there are many methods for calculating matrix singular values, which have important practical significance. For example, matrix singular values play an important role in the least squares method. However, the solution is inaccurate because of the existence of rounding errors. Because in floating-point operations, rounding errors cannot be avoided. When rounding errors are accumulated over a large amount, inaccurate or even wrong calculation results will be obtained. This is especially obvious when encountering pathological problems. Error-free conversion technology shows reliable performance in reducing the accumulation of rounding errors. The key idea is to restore the rounding error of a single operation to the original calculation result through cumulative compensation. On the other hand, mixed precision methods can be used to shorten the calculation time without reducing the accuracy of the result. Numerical methods using this idea generally use higher precision in the key calculation steps of the algorithm and use low precision for calculation in other parts. This idea uses a hybrid data format to take advantage of the high performance of low-precision formats and reduce the cost of global calculations.
[0003] The DQDS algorithm can effectively calculate the singular values of a bidiagonal matrix, and can also be used to calculate the eigenvalues of a tridiagonal matrix.
[0004] Most scholars have studied the shift strategy of the DQDS algorithm to make it converge faster when solving large-scale matrices. In 2000, Parlett and Marques described in detail how to implement the DQDS algorithm efficiently. And DQDS has been included in the LAPACK library as an open source algorithm and is widely used as a DLASQ routine. Li Shengguo et al. improved DQDS and designed a new contraction strategy that can greatly reduce the calculation speed of the DQDS algorithm. The DQDS algorithm improved by Li et al. has been adopted by LAPACK-3.4.1. Aishima et al. studied the convergence of the dqds algorithm. And gave the specific steps of the DQDS algorithm shift strategy, and used mathematical rigor to prove that this strategy has asymptotic cubic convergence. On the above basis, Aishima et al. introduced the convergence rate theorem of the DQDS algorithm under different shift strategies, and proposed a new DQDS. While maintaining global convergence, the asymptotic superquadratic convergence of the DQDS algorithm is achieved.
[0005] Nakatsukasa et al. combined DQDS with early deflation techniques, which significantly reduced the running time of DQDS. The running time of this method is independent of whether there is a shift. Araki et al. proposed a calculation method that combines DQDS and OQDS to calculate the calculation method of the matrix column space, and used the DQDS method to study the distribution of all singular values to determine the numerical rank. Ferreira and Parlett proposed a new DQDS algorithm to calculate the eigenvalues of real tridiagonal matrices, and experimentally proved that the new transformation triple qdqs is faster.
[0006] However, most of the above studies focus on shift strategies and convergence analysis, without considering the accumulation of rounding errors during the calculation process, which leads to a decrease in the accuracy of the calculation and ultimately leads to wrong results. They also do not consider the problem of too long calculation time when calculating large-scale matrices, which ultimately increases the cost of calculation.
[0007] Furthermore, the solutions obtained by the prior art are all of single precision. When users have different requirements for calculation precision, for example, some users need a more precise solution, while some users do not require high precision but need less solution time, the prior art has no solution for this. Summary of the invention
[0008] The present invention discloses a multi-mode computing framework and method for solving singular values with adjustable precision, which can provide different modes to select different algorithms for solving singular values according to different matrices and different solving requirements. In the framework of the present invention, the same solving algorithm includes three solving precision modes, namely the original mode, the high-precision mode, and the mixed-precision mode. The original mode is the initial version of the algorithm. The high-precision mode proposes and implements a high-precision DQDS algorithm based on error-free conversion technology, which reduces the accumulation of rounding errors in calculations and makes the solving results more accurate and reliable. The mixed-precision mode proposes and implements a mixed-precision DQDS algorithm based on the mixed-precision idea, which utilizes the potential performance advantages of different precision formats to reduce overhead while ensuring global accuracy. For different types of matrices, the framework of the present invention can add different solving algorithms, which is universal and universal, so that the technical problems involved in the background technology can be effectively solved.
[0009] To achieve the above object, the technical solution of the present invention is:
[0010] A multi-mode computational framework with adjustable precision for solving singular values, comprising:
[0011] A matrix input module is used to input the matrix to be solved;
[0012] A solution algorithm storage module, used for storing the solution algorithm;
[0013] A solution algorithm adding module, used for adding a solution algorithm to the solution algorithm storage module;
[0014] A solution algorithm selection module, used for selecting a corresponding solution algorithm from the solution algorithm storage module according to an input matrix;
[0015] A solution precision selection module, used to select a solution precision mode of a solution algorithm, wherein the solution precision mode includes an original mode, a high precision mode and a mixed precision mode; and
[0016] The calculation module is used to solve the input matrix with corresponding accuracy using the selected solution algorithm according to the selected accuracy mode.
[0017] As a preferred improvement of the present invention, the original mode is the initial version of the added solution algorithm; the high-precision mode is a reliable numerical algorithm that reduces the accumulation of rounding errors by the added solution algorithm through the EFT technology; the mixed-precision mode is an efficient numerical algorithm that is designed by combining data formats for the added solution algorithm.
[0018] The present invention also provides a multi-mode calculation method with adjustable precision for solving singular values based on the multi-mode calculation framework with adjustable precision for solving singular values, the method comprising the following steps:
[0019] Step 1: Input the matrix to be solved;
[0020] Step 2: Determine whether there is a solution algorithm corresponding to the matrix stored. If not, execute step 3; if yes, execute step 4;
[0021] Step 3: Add solution algorithm;
[0022] Step 4: Select the corresponding solution algorithm for the matrix;
[0023] Step 5: Select a solution accuracy mode of the solution algorithm according to the solution accuracy requirement of the input matrix, wherein the solution accuracy mode includes an original mode, a high-precision mode, and a mixed-precision mode;
[0024] Step 6: Use the selected solution algorithm to solve the input matrix with corresponding accuracy according to the selected solution accuracy mode.
[0025] As a preferred improvement of the present invention, in step six, the high-precision mode solving step includes:
[0026] Step a1, initializing the input matrix;
[0027] Step a2: Use the TwoSum algorithm to calculate and update the compensation item;
[0028] Step a3: Use the TwoProd algorithm and the DivRem algorithm to perform calculations, and accumulate rounding errors to update the compensation item;
[0029] Step a4: Check whether the traversal calculation is completed. If not, return to step a2;
[0030] Step a5: Check whether the convergence condition is met. If not, return to step a2.
[0031] As a preferred improvement of the present invention, in step six, the mixed precision mode solution step includes:
[0032] Step b1, initializing the input matrix;
[0033] Step b2, using double-precision data format for calculation;
[0034] Step b3, using single-precision data format for calculation, and storing the calculation result in double-precision data format;
[0035] Step b4: Check whether the traversal calculation is completed. If not, return to step b2;
[0036] Step b5: Check whether the convergence condition is met. If not, return to step b2.
[0037] As a preferred improvement of the present invention, in the solution process of the mixed precision mode, addition calculation and subtraction calculation use double precision data format, and multiplication calculation and division calculation use single precision data format.
[0038] The beneficial effects of the present invention are as follows:
[0039] 1. By setting the solution algorithm to have three solution accuracy modes, users can choose calculation methods with different accuracy according to their needs, thus helping users to better choose any mode to efficiently solve different problems;
[0040] 2. The high-precision mode of the present invention updates the compensation term when calculating using the solution algorithm, which can accurately improve the accuracy of the result. Especially when calculating pathological problems, it is more likely to have a large number of rounding errors leading to inaccurate or even incorrect results. Therefore, it can solve the technical problem of inaccurate results caused by rounding errors in calculations;
[0041] 3. The mixed precision mode of the present invention uses double-precision data format and single-precision data format for calculation, and the calculation results of the single-precision data format are stored in double-precision data format, which can improve the overall speed of calculation, especially when facing a large amount of calculation data, the mixed precision calculation method can obtain the calculation results faster, thus solving the technical problems of long calculation time and low calculation efficiency;
[0042] 4. According to the idea of the present invention, the solution algorithm that can be added freely is universal and applicable. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work, among which:
[0044] Figure 1 A structural framework diagram of a multi-mode computing framework with adjustable precision for solving singular values according to the present invention;
[0045] Figure 2 A schematic diagram of a solution process of a multi-mode calculation method with adjustable precision for solving singular values according to the present invention;
[0046] Figure 3 A diagram showing the solution process of the high-precision model of the present invention;
[0047] Figure 4 A diagram showing the single-precision and double-precision floating point formats of the present invention;
[0048] Figure 5 This is a diagram of the solution process of the mixed precision mode of the present invention. DETAILED DESCRIPTION
[0049] The technical solutions in the embodiments of the present invention will be described clearly and completely below in combination with the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present invention are only used to explain the relative position relationship, movement status, etc. between the components under a certain specific posture (as shown in the accompanying drawings). If the specific posture changes, the directional indication will also change accordingly.
[0051] In addition, in the present invention, descriptions such as "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0052] In the present invention, unless otherwise clearly specified and limited, the terms "connection", "fixation", etc. should be understood in a broad sense. For example, "fixation" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0053] In addition, the technical solutions between the various embodiments of the present invention can be combined with each other, but it must be based on the fact that ordinary technicians in the field can implement it. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0054] See also Figure 1 As shown, the present invention provides a multi-mode computing framework with adjustable precision for solving singular values, including a matrix input module 1, a solution algorithm storage module 2, a solution algorithm adding module 3, a solution algorithm selection module 4, a solution precision selection module 5 and a calculation module 6.
[0055] Specifically, the matrix input module 1 is used to input the matrix to be solved.
[0056] The solution algorithm storage module 2 is used to store the solution algorithm. Preferably, the multi-mode computing framework adopts C and Matlab versions, so that all solution algorithms can be included in the solution algorithm storage module 2, so that the operation is simple and easy to use.
[0057] The solution algorithm adding module 3 is used to add a solution algorithm to the solution algorithm storage module 2.
[0058] The solution algorithm selection module 4 is used to select a corresponding solution algorithm from the solution algorithm storage module 2 according to the input matrix.
[0059] The solution accuracy selection module 5 is used to select the solution accuracy mode of the solution algorithm selected by the solution algorithm selection module 4, and the solution accuracy modes include the original mode, the high-precision mode and the mixed-precision mode. It should be noted that the original mode is the initial version of the added solution algorithm; the high-precision mode is a reliable numerical algorithm that reduces the accumulation of rounding errors by the added solution algorithm through the EFT technology; the mixed-precision mode is an efficient numerical algorithm designed by the added solution algorithm through a combined data format. In this way, if high calculation accuracy is required, select the high-precision mode; if fast calculation speed and certain accuracy are required, select the mixed-precision mode; if there is no requirement for calculation accuracy, select the original mode.
[0060] The calculation module 5 is used to solve the input matrix with corresponding accuracy using the selected solution algorithm according to the selected accuracy mode.
[0061] Recombination Figure 2 As shown, the present invention also provides a multi-mode calculation method with adjustable precision for solving singular values based on the multi-mode calculation framework with adjustable precision for solving singular values, the method comprising the following steps:
[0062] Step 1: Input the matrix to be solved;
[0063] Step 2: Determine whether there is a solution algorithm corresponding to the matrix stored. If not, execute step 3; if yes, execute step 4;
[0064] Step 3: Add solution algorithm;
[0065] Step 4: Select the corresponding solution algorithm for the matrix;
[0066] Step 5: Select a solution accuracy mode of the solution algorithm according to the solution accuracy requirement of the input matrix, wherein the solution accuracy mode includes an original mode, a high-precision mode, and a mixed-precision mode;
[0067] Step 6: Use the selected solution algorithm to solve the input matrix with corresponding accuracy according to the selected solution accuracy mode.
[0068] In floating-point operations, the calculated value is an approximation rather than a true value because of rounding errors. Rounding errors are unavoidable in floating-point calculations and can lead to inaccurate results. The EFT technology used in the present invention can effectively reduce the accumulation of rounding errors. It compensates for the rounding errors generated in each step of the DQDS algorithm and then designs a reliable numerical algorithm. For details, see Figure 3 As shown, the solution steps of the high-precision mode include:
[0069] Step a1, initializing the input matrix;
[0070] Step a2: Use the TwoSum algorithm to calculate and update the compensation item;
[0071] It should be noted that the initialized matrix is calculated using the TwoSum algorithm, and the errors that were originally to be discarded are recorded and involved in the following calculations, and finally compensated back to the original calculation results, that is, the compensation terms.
[0072] Step a3: Use the TwoProd algorithm and the DivRem algorithm to perform calculations, and accumulate rounding errors to update the compensation item;
[0073] Step a4: Check whether the traversal calculation is completed. If not, return to step a2;
[0074] Step a5: Check whether the convergence condition is met. If not, return to step a2.
[0075] It should be noted that for each inner loop, the rounding error generated by each step of the operation is recorded through the error-free conversion technology, and then compensated back to the original calculation result until the convergence condition is reached. The loop is exited and a more accurate final result is obtained.
[0076] In computers, data is transmitted, processed, and stored in binary form. In the IEEE-754 standard, double-precision data takes up 64 bits, and single-precision data takes up 32 bits. Figure 4 The following table shows the representation of pi in single-precision and double-precision floating point formats. Although double-precision arithmetic will produce more accurate results, 64-bit floating point operations are generally half as fast as 32-bit floating point operations.
[0077] In order to effectively utilize the performance differences of calculations under different precision formats, the present invention adopts a hybrid data format to use different floating-point formats in different operations, thereby ensuring accuracy while reducing overall overhead and speeding up calculations. Numerical methods that adopt this idea generally use higher precision in the key calculation steps of the algorithm, and use low precision for calculations in other parts. In the present invention, the high-precision data format is double precision, and the low-precision data format is single precision. In the algorithm, addition and subtraction calculations use double-precision data format, and multiplication and division calculations use single-precision data format. For details, see Figure 5 As shown, the solution steps of mixed precision mode include:
[0078] Step b1, initializing the input matrix;
[0079] Step b2, using double-precision data format for calculation;
[0080] Step b3, using single-precision data format for calculation, and storing the calculation result in double-precision data format;
[0081] Step b4: Check whether the traversal calculation is completed. If not, return to step b2;
[0082] Step b5: Check whether the convergence condition is met. If not, return to step b2.
[0083] The beneficial effects of the present invention are as follows:
[0084] 1. By setting the solution algorithm to have three solution accuracy modes, users can choose calculation methods with different accuracy according to their needs, thus helping users to better choose any mode to efficiently solve different problems;
[0085] 2. The high-precision mode of the present invention updates the compensation term when calculating using the solution algorithm, which can accurately improve the accuracy of the result. Especially when calculating pathological problems, it is more likely to have a large number of rounding errors leading to inaccurate or even incorrect results. Therefore, it can solve the technical problem of inaccurate results caused by rounding errors in calculations;
[0086] 3. The mixed precision mode of the present invention uses double-precision data format and single-precision data format for calculation, and the calculation results of the single-precision data format are stored in double-precision data format, which can improve the overall speed of calculation, especially when facing a large amount of calculation data, the mixed precision calculation method can obtain the calculation results faster, thus solving the technical problems of long calculation time and low calculation efficiency;
[0087] 4. According to the idea of the present invention, the solution algorithm that can be added freely is universal and applicable.
[0088] Although the embodiments of the present invention have been disclosed as above, they are not limited to the applications listed in the specification and the embodiments. They can be fully applied to various fields suitable for the present invention. For those familiar with the art, additional modifications can be easily implemented. Therefore, without departing from the general concept defined by the claims and the scope of equivalents, the present invention is not limited to the specific details and the illustrations shown and described herein.
Claims
1. A multi-mode computing framework with adjustable precision for solving singular values, characterized in that: include: A matrix input module is used to input the matrix to be solved; A solution algorithm storage module, used for storing the solution algorithm; A solution algorithm adding module, used for adding a solution algorithm to the solution algorithm storage module; A solution algorithm selection module, used for selecting a corresponding solution algorithm from the solution algorithm storage module according to an input matrix; The solution accuracy selection module is used to select the solution accuracy mode of the solution algorithm. The solution accuracy modes include the original mode, the high-precision mode and the mixed-precision mode. The solution steps of the high-precision mode include: Step a1, initializing the input matrix; Step a2: Use the TwoSum algorithm to calculate and update the compensation item; Step a3: Use the TwoProd algorithm and the DivRem algorithm to perform calculations, and accumulate rounding errors to update the compensation item; Step a4: Check whether the traversal calculation is completed. If not, return to step a2; Step a5: Check whether the convergence condition is met. If not, return to step a2; The calculation module is used to solve the input matrix with corresponding accuracy using the selected solution algorithm according to the selected accuracy mode.
2. A multi-mode computing framework with adjustable precision for solving singular values according to claim 1, characterized in that: The original mode is the initial version of the solution algorithm; the high-precision mode is a reliable numerical algorithm that reduces the accumulation of rounding errors through error-free conversion technology; the mixed-precision mode is an efficient numerical algorithm designed by combining data formats.
3. A multi-mode computing method with adjustable precision for solving singular values based on the multi-mode computing framework with adjustable precision for solving singular values according to any one of claims 1 to 2, characterized in that: The method comprises the following steps: Step 1: Input the matrix to be solved; Step 2: Determine whether there is a solution algorithm corresponding to the matrix stored. If not, execute step 3; if yes, execute step 4; Step 3: Add solution algorithm; Step 4: Select the corresponding solution algorithm for the matrix; Step 5: Select a solution accuracy mode of the solution algorithm according to the solution accuracy requirement of the input matrix, wherein the solution accuracy mode includes an original mode, a high-precision mode, and a mixed-precision mode; Step 6: Use the selected solution algorithm to solve the input matrix with corresponding accuracy according to the selected solution accuracy mode.
4. The multi-mode calculation method for solving singular values with adjustable precision according to claim 3, characterized in that: In step six, the high-precision model solution steps include: Step a1, initializing the input matrix; Step a2: Use the TwoSum algorithm to calculate and update the compensation item; Step a3: Use the TwoProd algorithm and the DivRem algorithm to perform calculations, and accumulate rounding errors to update the compensation item; Step a4: Check whether the traversal calculation is completed. If not, return to step a2; Step a5: Check whether the convergence condition is met. If not, return to step a2.
5. The multi-mode calculation method for solving singular values with adjustable precision according to claim 3, characterized in that: In step six, the mixed precision mode solution steps include: Step b1, initializing the input matrix; Step b2, using double-precision data format for calculation; Step b3, using single-precision data format for calculation, and storing the calculation result in double-precision data format; Step b4: Check whether the traversal calculation is completed. If not, return to step b2; Step b5: Check whether the convergence condition is met. If not, return to step b2.
6. The multi-mode calculation method for solving singular values with adjustable precision according to claim 5, characterized in that: In mixed-precision mode, addition and subtraction operations use double-precision data format, and multiplication and division operations use single-precision data format.