Calculation method, calculation device and program
By employing a sequence of reciprocal square root operations to compute √A-√B without direct square root calculations, the method addresses speed and precision issues in graph simplification, achieving up to 36.8% reduction in floating-point operations.
Patent Information
- Application Number
- JP2022564862
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2020-11-25
- Publication Date
- 2024-10-03
- Estimated Expiration
- 2040-11-25
AI Technical Summary
Existing graph simplification methods using Fast Multiple SVT are hindered by the need to calculate square roots and reciprocal square roots, leading to suboptimal processing speeds and precision issues.
A method involving a series of operations including reciprocal square root calculations, subtractions, multiplications, additions, and divisions to compute square roots without directly calculating √A and √B, utilizing fast reciprocal square root methods.
This approach significantly reduces the number of floating-point operations required, enhancing processing speed and precision by approximately 41.2% to 36.8% compared to conventional methods.
Smart Images

Figure 0007560765000007 
Figure 0007560765000008 
Figure 0007560765000009
Abstract
Description
[Technical field]
[0001] The present invention relates to a technique for a calculation method, a calculation device, and a program. [Background technology]
[0002] A data structure called an embedded graph exists in various fields such as networks, geographic information, and image engineering. An embedded graph is defined by combining a graph, which is a set of multiple vertices and edges connecting the vertices, with the vertex positions. For example, in a network, a graph can be constructed by corresponding the network nodes to the vertices and the network links to the edges. In this case, an embedded graph can be found by corresponding the physical positions of the network nodes or the node coordinates when visualizing the network to the vertex positions.
[0003] In geographic information science, boundary data such as national and prefectural borders, coastlines, and lakeshore lines are generally stored as embedded graphs. Boundaries are expressed by densely plotting vertices on the boundaries and connecting the edges. In the field of image engineering, embedded graphs are used to store data related to shapes and regions. For example, data such as object shapes in vector images, depth boundaries in depth maps, subject shapes and texture region shapes in natural images are represented as embedded graphs. Boundaries are expressed by edges by plotting vertices on the boundaries of shapes and regions.
[0004] In the embedded graphs exemplified above, there is a great advantage in simplifying the embedded graph by reducing the number of vertices and edges as much as possible while preserving the shape of the embedded graph as much as possible (hereinafter referred to as simplification of the embedded graph, or simply simplification).
[0005] In a network, the more vertices and edges there are, the more detailed the data can be expressed, but it becomes difficult to grasp the outline of the network configuration at a glance, and the data volume becomes huge, which places a heavy load on drawing. If the embedded graph for this network can be simplified, the network configuration can be presented in a visually easy-to-understand manner, and the number of vertices and edges can be reduced to compress the data and reduce the load on drawing. In geographic information studies, boundaries can be accurately expressed by densely plotting vertices on the boundaries, but the amount of data becomes huge.
[0006] By simplifying the boundary data, it is possible to reduce the amount of data for transmission and storage, and to generate geographic information with simplified boundaries that is visually easy to understand. In image engineering, the more vertices and sides there are, the more detailed the shape and area data can be retained and the more accurate the representation can be, but the amount of data becomes enormous, and the amount of code required for transmission and storage increases.
[0007] If this shape and area can be simplified, the number of vertices and edges can be reduced, thereby reducing the amount of code, while maintaining the accuracy of the representation as much as possible. As an invention for achieving the above simplification, an embedded graph simplification method has been proposed (see Patent Document 2). Also, a high-speed processing method (two-dimensional version) (see Patent Document 3) and a high-speed processing method (multidimensional version) (see Patent Document 4) have been proposed.
[0008] The above high-speed processing method employs Fast Multiple SVT (see Non-Patent Document 1), which performs multiple parallel calculations of Singular Value Thresholding (SVT) (see Patent Document 4). The algorithm is shown in FIG. 16. The third line g of the algorithm shown in FIG. 16A and FIG. 16B -1 and -1 In the fourth line, σ2, the reciprocal square root and the square root difference are calculated, respectively. The reciprocal square root is the bottleneck in the calculation speed of the algorithm shown in Figures 16A and 16B.
[0009] In addition, the square root difference calculation is prone to cancellation and error. Furthermore, in the algorithms shown in Figures 16A and 16B, only the square root difference calculation in line 4 requires the square root calculation, and only the reciprocal square root is used in other places.
[0010] Now, the reciprocal square root a=1 / √A of a certain positive real number A is calculated repeatedly and extensively in the form of normal calculations in simulations of reflected light and scattered light in the field of computer graphics (CG).
[0011] In order to reduce the amount of calculation, the Fast Inverse Square Root (FastInvSqrt) method was invented, which speeds up the calculation of the reciprocal square root by several times by avoiding the calculation of the square root. This technology is implemented in game software using CG (see Non-Patent Document 2). In addition, a modified FastInvSqrt method has been invented as a high-precision version of the FastInvSqrt method (see Non-Patent Document 3).
[0012] By employing this FastInvSqrt method or the modified FastInvSqrt method in the calculation of the reciprocal square root in the Fast Multiple SVT described above, it is expected that the calculation speed will be improved. [Prior art documents] [Patent documents]
[0013] [Patent Document 1] JP 2016-221829 A [Patent Document 2] JP 2017-211706 A [Patent Document 3] JP 2018-082249 A [Patent Document 4] JP 2019-046196 A [Non-patent literature]
[0014] [Non-Patent Document 1] Takamoto Sasaki, Masaki Kitahara, and Jun Shimizu, "Fast Singular Value Thresholding for Low-Rank Optimization," 16th Forum on Information Science and Technology, 2017 [Non-Patent Document 2] M. Robertson, “A Brief History of InvSqrt,” Bachelor Thesis, University of New Brunswick, 2012. [Non-Patent Document 3] CJ Walczyk, ``A Modification of the Fast Inverse Square,'' MDPI Computation, vol. 7, no. 3, 2019 Summary of the Invention [Problem to be solved by the invention]
[0015] However, Fast Multiple SVT requires square root difference calculations, so the square root is still required, and the reciprocal calculation is still required, so the speedup mentioned above is not achieved.
[0016] Thus, a graph simplification device using Fast Multiple SVT cannot perform high-speed processing, and graph drawing and graph processing cannot be performed at high speed.
[0017] In view of the above circumstances, an object of the present invention is to provide a technique for performing calculations including square roots faster. [Means for solving the problem]
[0018] One aspect of the present invention is a calculation method including: a first reciprocal square root step in which a computer calculates a reciprocal square root of a positive real number A using a fast reciprocal square root method; a second reciprocal square root step in which a computer calculates a reciprocal square root of a positive real number B using the fast reciprocal square root method; a subtraction step in which a computer subtracts B from A; a first multiplication step in which a computer multiplies a result of the first reciprocal square root step by a result of the second reciprocal square root step; a second multiplication step in which a computer multiplies a result of the first multiplication step by a result of the subtraction step; an addition step in which a computer adds a result of the first reciprocal square root step by a result of the second reciprocal square root step; and a division step in which a computer divides a result of the second multiplication step by a result of the addition step.
[0019] One aspect of the present invention is a program for causing a computer to execute the above-described calculation method.
[0020] One aspect of the present invention is a calculation device including a first reciprocal square root unit that calculates the reciprocal square root of a positive real number A using a fast reciprocal square root method, a second reciprocal square root unit that calculates the reciprocal square root of a positive real number B using the fast reciprocal square root method, a subtraction unit that subtracts B from A, a first multiplication unit that multiplies a result of the calculation in the first reciprocal square root unit by a result of the calculation in the second reciprocal square root unit, a second multiplication unit that multiplies a result of the calculation in the first multiplication unit by a result of the calculation in the subtraction unit, an addition unit that adds the result of the calculation in the first reciprocal square root unit to the result of the calculation in the second reciprocal square root unit, and a division unit that divides the result of the calculation in the second multiplication unit by the result of the calculation in the addition unit. Effect of the Invention
[0021] The present invention allows calculations involving square roots to be performed faster. [Brief description of the drawings]
[0022] [Figure 1] FIG. 1 is a diagram illustrating a configuration of an information processing device including a computing device. [Diagram 2] FIG. 2 is a block diagram showing the configuration of a computing device 10A. [Diagram 3] FIG. 2 is a block diagram showing a computing device 20. [Figure 4] FIG. [Diagram 5] FIG. 2 is a block diagram showing a configuration of a computing device 10B. [Figure 6] FIG. 4 is a block diagram showing a computing device 40. [Figure 7] FIG. 2 is a block diagram showing a configuration of a computing device 10C. [Figure 8] FIG. 2 is a block diagram showing the configuration of a calculation device 10D. [Figure 9] FIG. 2 is a block diagram showing a configuration of a computing device 10E. [Figure 10] FIG. 2 is a block diagram showing the configuration of a computing device 10F. [Figure 11] FIG. 13 is a diagram illustrating an outline of a graph simplification process. [Figure 12] FIG. 1 illustrates an example of the configuration of a graph simplifying device. [Figure 13] 13 is a diagram illustrating an example of the configuration of a local linear alignment unit. [Figure 14] FIG. 13 is a diagram for explaining an operation of arranging vectors of adjacent sides. [Figure 15] FIG. 1 shows an algorithm illustrating the solution to the local linear alignment problem. [Figure 15] FIG. 1 shows an algorithm illustrating the solution to the local linear alignment problem. [Figure 16A] FIG. 1 illustrates an algorithm for singular value threshold processing. [Figure 16B] FIG. 1 illustrates an algorithm for singular value threshold processing. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0023] DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS An embodiment of the present invention will be described in detail with reference to 1 is a diagram showing the configuration of an information processing device 1 including a calculation device 10 in an embodiment. The information processing device 1 includes an input device 3, a calculation device 10, and an output device 5. The input device 3 inputs input data such as numerical values to the calculation device 10. The calculation device 10 performs calculations using the input data and outputs the calculation results to the output device 5.
[0024] The computing device 10 includes a central processing unit (CPU), a memory, an auxiliary storage device, and the like, which are connected by a bus, and executes a computation program to perform computation processing. All or part of the functions of the computing device 10 may be realized using hardware such as an application specific integrated circuit (ASIC), a programmable logic device (PLD), or a field programmable gate array (FPGA). The computation program may be recorded on a computer-readable recording medium. The computer-readable recording medium may be, for example, a portable medium such as a flexible disk, a magneto-optical disk, a ROM, a CD-ROM, or a semiconductor storage device (e.g., a solid state drive (SSD)), or a storage device such as a hard disk built into a computer system. The computation program may be transmitted via an electric communication line.
[0025] Hereinafter, first to sixth embodiments of the calculation device 10 will be described. After that, a graph simplification process will be described as an application example of the calculation device 10. Note that the "fast reciprocal square root calculation unit" in each embodiment calculates the reciprocal square root by the fast reciprocal square root method.
[0026] [First embodiment] Hereinafter, a calculation device 10A, which is the calculation device 10 in the first embodiment, will be described. Fig. 2 is a block diagram showing the configuration of the calculation device 10A that calculates the reciprocal square root and the square root difference in the embodiment. The calculation device 10A is a calculation device that receives positive real numbers A and B from the input device 3 and outputs a=1 / √A, b=1 / √B, and c=√A-√B to the output device 5. The calculation device 10A includes high-speed reciprocal square root calculation units 11 and 21, a subtraction unit 12, multiplication units 17 and 117, an addition unit 13, and a division unit 14.
[0027] In calculation device 10A, when a positive real number A is input, A is input to fast reciprocal square root calculation unit 11 and subtraction unit 12. When a positive real number B is input, B is input to fast reciprocal square root calculation unit 21 and subtraction unit 12. Fast reciprocal square root calculation unit 11 outputs a=1 / √A to subtraction unit 12, addition unit 13, and output device 5. Fast reciprocal square root calculation unit 21 outputs b=1 / √B to subtraction unit 12, addition unit 13, and output device 5. Subtraction unit 12 outputs AB to multiplication unit 117.
[0028] The multiplication unit 17 outputs ab to the multiplication unit 117. The multiplication unit 117 outputs (AB)ab to the division unit 14. The addition unit 13 outputs a+b to the division unit 14. The division unit 14 outputs (AB)ab / (a+b) to the output device 5 as c.
[0029] Here, (AB)ab / (a+b)=√A-√B as follows. √A-√B=(√A-√B)(√A+√B) / (√A+√B) =(AB) / (√A+√B) Where: √A+√B=(1 / √A+1 / √B)(√A√B)=(a+b) / (ab) Therefore (AB) / (√A+√B)=(AB)ab / (a+b)
[0030] From the above, calculation device 10A outputs a=1 / √A, b=1 / √B, and c=√A-√B to output device 5. Calculation device 10A calculates the reciprocal square root, but does not calculate √A and √B. Therefore, it outputs c without calculating √A and √B. In addition, by rationalizing the numerator, it is possible to prevent the loss of digits in √A-√B compared to the case of calculating √A and √B.
[0031] 3 is a block diagram showing a calculation device 20 that calculates √A and √B and outputs a, b, and c as in the conventional case, as a reference example. The calculation device 20 includes square root calculation units 15 and 25, a subtraction unit 22, and division units 24 and .
[0032] In calculation device 20, when a positive real number A is input, square root calculation unit 15 outputs √A to subtraction unit 22 and division unit 24. When a positive real number B is input, square root calculation unit 25 outputs √B to subtraction unit 22 and division unit 34.
[0033] The division unit 24 outputs a=1 / √A. The division unit 34 outputs b=1 / √B. The subtraction unit 22 outputs c=√A-√B.
[0034] In order to compare the amount of calculations, the amount of calculation for each calculation is explained using Figure 4. Figure 4 shows the time required to perform each calculation 1,000,000 times in C++, with addition assumed to be 1 flops. In Figure 4, sqrt(x) and 1 / sqrt(x) show the amount of calculation required when the square root and reciprocal square root are calculated using standard library functions in C++. Also, fastInvSqrt(x) shows the amount of calculation using the Fast Inverse Square Root method with one Newton method. fastInvSqrt2(x) shows the amount of calculation using the Fast Inverse Square Root method with two Newton methods. fastInvSqrt3(x) shows the amount of calculation using the Fast Inverse Square Root method with three Newton methods. mFastInvSqrt(x) shows the amount of calculation using the modified Fast Inverse Square Root method.
[0035] According to HA Thant, et. al., “Mobile Agents Based Load Balancing Method for Parallel Applications,” 6th Asia-Pacific Symposium on Information and Telecommunication Technologies, Yangon, 2005, if the computational effort of one floating-point addition is also taken to be 1 flop, then subtraction and multiplication require 1 flop, while division and square root calculations require 4 flops. Furthermore, the reciprocal square root calculation using the FastInvSqrt method can be estimated to require 1 flop, as shown in Figure 4.
[0036] When a, b, and c are calculated by the conventional calculation device 20, the total amount of calculation is 17 flops. On the other hand, when they are calculated by the calculation device 10A according to this embodiment, the total amount of calculation is 10 flops. Therefore, compared to the conventional calculation device 20, it can be estimated that the calculation device 10A according to this embodiment reduces the number of floating-point operations by 7 flops, or about 41.2%.
[0037] [Second embodiment] Hereinafter, the calculation device 10B, which is the calculation device 10 in the second embodiment, will be described. FIG. 5 is a block diagram showing the configuration of the calculation device 10B that calculates the reciprocal square root of the sum and the difference, and the square root difference of the sum and the difference, in the embodiment. The calculation device 10B is a calculation device that receives positive real numbers X and e (X>e>0) from the input device 3 and outputs a=1 / √(X+e), b=1 / √(Xe), and c=√(X+e)-√(Xe) to the output device 5. The calculation device 10B includes high-speed reciprocal square root calculation units 31 and 41, a subtraction unit 32, multiplication units 27, 37, and 47, addition units 23 and 33, and a division unit 44.
[0038] In calculation device 10B, when a positive real number X is input, X is input to addition unit 23 and subtraction unit 32. When a positive real number e is input, e is input to addition unit 23, subtraction unit 32, and multiplication unit 27. Addition unit 23 outputs X+e to fast reciprocal square root calculation unit 31. Subtraction unit 32 outputs Xe to fast reciprocal square root calculation unit 41. Multiplication unit 27 outputs 2e to multiplication unit 47.
[0039] The fast reciprocal square root calculation unit 31 outputs a=1 / √(X+e) to the multiplication unit 37, the addition unit 33, and the output device 5. The fast reciprocal square root calculation unit 41 outputs b=1 / √(Xe) to the multiplication unit 37, the addition unit 33, and the output device 5. The multiplication unit 37 outputs ab=(1 / √(X+e))(1 / √(Xe)) to the multiplication unit 47. The multiplication unit 47 outputs 2eab to the division unit 44. The addition unit 33 outputs a+b=1 / √(X+e)+1 / √(Xe) to the division unit 44. The division unit 44 outputs 2eab / (a+b) as c to the output device 5. The fact that 2eab / (a+b)=√(X+e)-√(Xe) is shown by setting A to X+e and B to Xe in the first embodiment.
[0040] From the above, calculation device 10B outputs a=1 / √(X+e), b=1 / √(Xe), and c=√(X+e)-√(Xe) to output device 5. Calculation device 10B calculates the reciprocal square root, but does not calculate √(X+e) or √(Xe). Therefore, calculation device 10B outputs c without calculating √(X+e) or √(Xe).
[0041] 6 is a block diagram showing a calculation device 40 that calculates √(X+e) and √(Xe) and outputs a, b, and c as in the conventional case, as a reference example. The calculation device 40 includes square root calculation units 35 and 45, subtraction units 42 and 52, an addition unit 43, and division units 54 and 64.
[0042] In calculation device 40, when positive real numbers X and e are input, addition unit 43 outputs X+e to square root calculation unit 35. Subtraction unit 42 outputs Xe to square root calculation unit 45. Square root calculation unit 35 outputs √(X+e) to division unit 54 and subtraction unit 52. Square root calculation unit 45 outputs √(Xe) to division unit 64 and subtraction unit 52.
[0043] The division unit 54 outputs a=1 / √(X+e). The division unit 64 outputs b=1 / √(Xe). The subtraction unit 52 outputs c=√(X+e)-√(Xe).
[0044] When a, b, and c are calculated by the conventional calculation device 40, the total amount of calculation is 19 flops. On the other hand, when they are calculated by the calculation device 10B according to this embodiment, the total amount of calculation is 12 flops. Therefore, compared to the conventional calculation device 40, it can be estimated that the calculation device 10B according to this embodiment reduces the number of floating-point operations by 7 flops, or about 36.8%.
[0045] [Third embodiment] Hereinafter, a calculation device 10C, which is the calculation device 10 in the third embodiment, will be described. FIG. 7 is a block diagram showing the configuration of the calculation device 10C that calculates the second singular value of an M×2 matrix, the inverse of the sum of the singular values, and the inverse of the difference between the singular values in the embodiment. In this embodiment, M≧3, and M=2 will be described in the fourth embodiment. The calculation device 10C is a calculation device that receives an M×2 matrix Y=[y1,y2] from the input device 3 and outputs the second singular value σ2, the inverse of the sum of the singular values 1 / (σ1+σ2), and the inverse of the difference between the singular values 1 / (σ1-σ2) to the output device 5.
[0046] The calculation device 10C includes the calculation device 10B described in the second embodiment. The calculation device 10C also includes a decomposition unit 110, inner product units 16, 26, and 36, a subtraction unit 62, multiplication units 57, 67, 77, and 87, an addition unit 53, and a square root calculation unit 55.
[0047] When an M×2 matrix Y=[y1, y2] is input to the calculation device 10C, Y is input to the decomposition unit 110. The decomposition unit 110 decomposes the M×2 matrix Y into column vectors y1 and y2. The decomposition unit 110 outputs y1 to the inner product units 16 and 36. The decomposition unit 110 outputs y2 to the inner product units 26 and 36.
[0048] The dot product unit 16 calculates the dot product a between y1 and y1, and outputs a to the addition unit 53, the multiplication unit 67, and the output device 5. The dot product unit 26 calculates the dot product c between y2 and y2, and outputs c to the addition unit 53, the multiplication unit 67, and the output device 5. The dot product unit 36 calculates the dot product b between y1 and y2, and outputs b to the multiplication unit 77 and the output device 5.
[0049] The adder 53 outputs f=a+c to the calculation device 10B and the output device 5. The multiplier 67 outputs ac to the subtractor 62. The multiplier 77 outputs b 2 The subtraction unit 62 outputs d=ac-b 2 to square root calculation unit 55 and output device 5. Square root calculation unit 55 outputs e=√d to multiplication unit 57 and output device 5. Multiplication unit 57 outputs 2e to calculation device 10B.
[0050] Calculation device 10B outputs 1 / √(f+2e) as 1 / (σ1+σ2) to output device 5. Calculation device 10B outputs 1 / √(f-2e) as 1 / (σ1-σ2) to output device 5. Calculation device 10B outputs √(f+2e)-√(f-2e) as 2σ2 to multiplication unit 87. Multiplication unit 87 outputs σ2 to output device 5.
[0051] Here, 1 / √(f±2e) is 1 / (σ1±σ2) as follows. According to Non-Patent Document 1, the sum and difference of the singular values σ1 and σ2 of an M×2 matrix are σ1±σ2=√(tr(Y T Y) ±2√(det(Y T Y))).
[0052] tr(Y T Y) = a (= the dot product of y1 and y1) + c (= the dot product of y2 and y2) = f. det(YT Y) = a (= the inner product of y1 and y1) × c (= the inner product of y2 and y2) - b 2 (=(b, the inner product of y1 and y2) 2 )=ac-b 2 = d. Therefore, √(det(Y T Y))=√d=e.
[0053] Therefore, √(tr(Y T Y) ±2√(det(Y T Y)))=√(f±2e). Therefore, 1 / √(f±2e)=1 / (σ1±σ2).
[0054] As shown in FIG. 7, the calculation device 10C outputs not only the second singular value σ2, the reciprocal of the sum of the singular values 1 / (σ1+σ2), and the reciprocal of the difference between the singular values 1 / (σ1-σ2), but also a, b, c, d, e, and f to the output device 5.
[0055] The computational complexity of calculation device 10C will be described. The processing of decomposition unit 110 simply decomposes a matrix into column vectors, so no floating-point calculations are performed (0 flop). The computational complexity of inner product units 16, 26, and 36 is 2M-1 flops for an input of an M-th order column vector. Furthermore, square root calculation by sqrt is 4 flops as described above. Therefore, the total computational complexity of calculation device 10C is 6M+19 flops. As described above, calculation device 10B has a reduction effect of 7 flops, so calculation device 10C also has a reduction effect of 7 flops due to calculation device 10B. [Fourth embodiment] Hereinafter, a calculation device 10D, which is the calculation device 10 in the fourth embodiment, will be described. Fig. 8 is a block diagram showing the configuration of the calculation device 10D that calculates the second singular value of a 2x2 matrix, the inverse of the sum of the singular values, and the inverse of the difference of the singular values in the embodiment. The calculation device 10D is a calculation device that receives a 2x2 matrix Y=[y1,y2] from the input device 3 and outputs the second singular value σ2, the inverse of the sum of the singular values 1 / (σ1+σ2), and the inverse of the difference of the singular values 1 / (σ1-σ2) to the output device 5.
[0056] The calculation device 10D includes the calculation device 10B described in the second embodiment. The calculation device 10D also includes a decomposition unit 120, inner product units 46 and 56, a determinant calculation unit 19, an absolute value calculation unit 18, multiplication units 97 and 107, and an addition unit 63.
[0057] When a 2×2 matrix Y=[y1, y2] is input to the calculation device 10D, Y is input to the decomposition unit 120. The decomposition unit 120 decomposes the 2×2 matrix Y into column vectors y1 and y2. The decomposition unit 120 outputs y1 to the inner product unit 46. The decomposition unit 120 outputs y2 to the inner product unit 56.
[0058] The inner product unit 46 calculates the inner product a of y1 and y1, and outputs a to the addition unit 63. The inner product unit 56 calculates the inner product c of y2 and y2, and outputs c to the addition unit 63. The determinant calculation unit 19 calculates the determinant d of Y, and outputs d to the absolute value calculation unit 18 and the output device 5.
[0059] Addition unit 63 outputs f=a+c to calculation device 10B and output device 5. Absolute value calculation unit 18 outputs the absolute value e of d to multiplication unit 97. Multiplication unit 97 outputs 2e to calculation device 10B.
[0060] Calculation device 10B outputs 1 / √(f+2e) as 1 / (σ1+σ2) to output device 5. Calculation device 10B outputs 1 / √(f-2e) as 1 / (σ1-σ2) to output device 5. Calculation device 10B outputs √(f+2e)-√(f-2e) as 2σ2 to multiplication unit 107. Multiplication unit 107 outputs σ2 to output device 5.
[0061] Here, 1 / √(f±2e) is 1 / (σ1±σ2) as shown in the third embodiment. As shown in Fig. 8, the calculation device 10D outputs not only the second singular value σ2, the reciprocal of the sum of the singular values 1 / (σ1+σ2), and the reciprocal of the difference between the singular values 1 / (σ1-σ2), but also d and f to the output device 5.
[0062] The calculation amount of calculation device 10D will be described. The calculation amount of determinant calculation unit 19 is 3 flops. Absolute value calculation unit 18 only evaluates the sign and inverts it if it is negative, so no floating point calculation is performed (0 flop). The total calculation amount by calculation device 10D is 24 flops. As described above, calculation device 10B has a reduction effect of 7 flops, so calculation device 10D also has a reduction effect of 7 flops by calculation device 10B. [Fifth embodiment] Hereinafter, a calculation device 10E that is the calculation device 10 in the fifth embodiment will be described. FIG. 9 is a block diagram showing the configuration of the calculation device 10E that calculates the SVT of an M×2 matrix in the embodiment. In this embodiment, M≧3, and M=2 will be described in the sixth embodiment. The calculation device 10E receives an M×2 matrix Y=[y1, y2] and a positive real number μ from the input device 3, performs singular value thresholding (SVT), and calculates a matrix Z shown in the following (1) as a result of the singular value thresholding.
[0063]
number
[0064] In (1), I2 is a 2 × 2 unit matrix. γ, δ, e, a, b, c, and d will be explained later.
[0065] The calculation device 10E includes the calculation device 10C described in the third embodiment, a coefficient calculation device 200, and an M×2 matrix transformation device 300.
[0066] When the M×2 matrix Y=[y1, y2] is input to the calculation device 10E, Y is input to the calculation device 10C, the coefficient calculation device 200, and the M×2 matrix transformation device 300. When the real number μ is input to the calculation device 10E, μ is input to the coefficient calculation device 200. As described in the third embodiment, the calculation device 10C outputs the second singular value σ2, the reciprocal of the sum of the singular values 1 / (σ1+σ2), the reciprocal of the difference of the singular values 1 / (σ1-σ2), a, b, c, d, e, and f. Here, as shown in FIG. 9, g=1 / (σ1+σ2) and h=1 / (σ1-σ2).
[0067] Of the outputs of the calculation device 10C, d, f, σ2, g, and h are output to the coefficient calculation device 200. A, b, c, and e are output to the M×2 matrix transformation device 300.
[0068] The coefficient calculation device 200 receives d, f, σ2, g, h, and μ as input. The coefficient calculation device 200 outputs γ and δ. The calculation method of γ and δ will be described. First, a sufficiently large real number is set as R. Specifically, the size of R can be about one tenth the maximum number of a single-precision floating-point number. Then, the coefficient calculation device 200 calculates γ and δ by dividing the case into the following four cases (a) to (d), and outputs them.
[0069] (a) When Y is a zero matrix (b) If (a) does not apply and d=0 (c) If (b) does not apply and h>R (d) If (c) does not apply
[0070] Below, we show γ and δ that are output for each case. Note that the reciprocal square root calculated using the fast reciprocal square root method is sometimes expressed as isqrt(·). For example, the reciprocal square root of a positive real number A calculated using the fast reciprocal square root method is sometimes expressed as isqrt(A). Also, (·) + The subscript + in indicates a ramp function. A ramp function outputs 0 if the input is a negative real number, and outputs the input real number unchanged if the input is a non-negative real number. The function min outputs the smallest value among the input numbers.
[0071] (a): γ = 0, δ = 0 (b): γ = (1-μ × isqrt(f)) + , δ=0 (c):γ=(1-(√2)×μ×isqrt(f)) + , δ=0 (d): γ = (1-(μ-σ2) + ×h) + , δ = min(μ, σ2) × g
[0072] The coefficient calculation device 200 outputs γ and δ to the M×2 matrix transformation device 300 according to the above case distinction. As a result, the M×2 matrix transformation device 300 has all the parameters included in the above (1), and uses these to output (1) to the output device 5. Note that when e=0, γδ / e in (1) is set to 0.
[0073] The amount of calculations performed by the calculation device 10E will now be described. The ramp function and function min mainly involve the comparison of real values, and no floating-point calculations are performed (0 flop). When performing calculations according to the algorithm shown in FIG. 16B, the amount of calculations is 12M+38 flops. Meanwhile, the total amount of calculations performed by the calculation device 10E is 12M+29 flops. From the above, it can be estimated that the number of floating-point calculations can be reduced by 9 flops. [Sixth embodiment] Hereinafter, a calculation device 10F, which is the calculation device 10 in the sixth embodiment, will be described. FIG. 10 is a block diagram showing the configuration of the calculation device 10F that calculates the SVT of a 2×2 matrix in the embodiment. The calculation device 10F receives the 2×2 matrix Y=[y1, y2] and a positive real number μ from the input device 3, performs the above-mentioned SVT, and calculates the matrix Z shown in the following (1) as the result of the singular value threshold processing. Note that y ij is the i-th row and j-th column component of Y.
[0074]
number
[0075] The function sign(·) in (2) is a sign function that outputs -1 when the input is negative, 0 when the input is 0, and +1 when the input is positive. γ, δ, and d will be described later.
[0076] The calculation device 10F includes the calculation device 10D described in the fourth embodiment, a coefficient calculation device 201, and a 2×2 matrix transformation device 301.
[0077] When a 2×2 matrix Y=[y1, y2] is input to the calculation device 10F, Y is input to the calculation device 10D, the coefficient calculation device 201, and the M×2 matrix transformation device 301. When a real number μ is input to the calculation device 10F, μ is input to the coefficient calculation device 201. As described in the third embodiment, the calculation device 10D outputs the second singular value σ2, the reciprocal of the sum of the singular values 1 / (σ1+σ2), the reciprocal of the difference of the singular values 1 / (σ1-σ2), d, and f. Here, as shown in FIG. 10, g=1 / (σ1+σ2) and h=1 / (σ1-σ2).
[0078] Of the outputs of the calculation device 10D, d, f, σ2, g, and h are output to the coefficient calculation device 201. d is output to the 2×2 matrix transformation device 300.
[0079] The coefficient calculation device 201 receives d, f, σ2, g, h, and μ as input. The coefficient calculation device 201 outputs γ and δ. The calculation method of γ and δ will be described. First, a sufficiently large real number is set as R. Specifically, the size of R can be about one tenth the maximum number of a single-precision floating-point type. Then, the coefficient calculation device 200 calculates γ and δ by dividing the case into the following four cases (a) to (d), and outputs them.
[0080] (a) When Y is a zero matrix (b) If (a) does not apply and d=0 (c) If (b) does not apply and h>R (d) If (c) does not apply
[0081] The γ and δ that are output for each case are shown below. (a): γ = 0, δ = 0 (b): γ = (1-μ × isqrt(f)) + , δ=0 (c):γ=(1-(√2)×μ×isqrt(f)) + , δ=0 (d): γ = (1-(μ-σ2) + ×h) + , δ = min(μ, σ2) × g
[0082] The coefficient calculation device 200 outputs γ and δ to the 2×2 matrix transformation device 301 according to the above case distinction. As a result, the 2×2 matrix transformation device 301 has all the parameters included in the above (2), and outputs (2) to the output device 5 using these parameters.
[0083] The calculation amount of the calculation device 10F will be described. When performing calculations according to the algorithm shown in Fig. 16B, the calculation amount is 41 flops. On the other hand, the total calculation amount by the calculation device 10F is 32 flops. From the above, it can be estimated that the floating-point calculation can be reduced by 9 flops.
[0084] Next, the graph simplification process will be described. Fig. 11 is a diagram showing an outline of the graph simplification process. In Fig. 11, G = (V, E, P) represents a graph embedded in an M-dimensional space. Here, V and E are a set of vertices and edges, respectively, and P ∈ R. |V|×M are the vertex coordinates (where R is the set of all real numbers). Each row vector of P (p1) T , (p2) T , …, (p |v| ) T Let V be the set of vertices with degree 2, and V be V~={v∈V|degv=2}.
[0085] In the graph simplification process, as shown in FIG. 11, an embedded graph with a distorted shape and many vertices is input, and an embedded graph that is locally linearly aligned is intermediately generated (S101), and finally unnecessary points are removed (S102) to obtain the desired graph with a simplified shape.
[0086] FIG. 12 is a diagram showing an example of the configuration of a graph simplifying device 500. The graph simplifying device 500 receives a threshold λ and a graph G as input, and outputs a simplified graph G". The graph simplifying device 500 includes a local linear alignment unit 510 and an unnecessary vertex removal unit 520. The local linear alignment unit 510 outputs G' obtained by locally linearly aligning the graph G using the threshold λ to the unnecessary vertex removal unit 520. The unnecessary vertex removal unit 520 outputs G'' obtained by removing unnecessary vertices from the vertices of the input graph G'.
[0087] Fig. 13 is a diagram showing an example of the configuration of the local linear alignment unit 510 in Fig. 12. As described above, the local linear alignment unit 510 outputs G' obtained by locally linearly aligning the graph G using the threshold value λ to the unnecessary vertex removal unit 520. The local linear alignment unit 510 includes a convex optimization problem formulation unit 511, a convex optimization problem solving unit 512, and a coordinate information replacement unit 513.
[0088] First, the convex optimization problem formulation unit 511 will be described. FIG. 14 is a diagram for explaining the operation of arranging vectors of adjacent sides. The matrix L V is a matrix for arranging vectors from v to adjacent vertices. The matrix L shown in FIG. V For the elements of , all the "..." parts are 0. Also, when the coordinate of v is the kth row of P, L shown in Figure 14 V The "-1" in is the kth column. V P gives us a vector whose starting point is v and whose ending point is the coordinate of the k-1th row, and a vector whose starting point is v and whose ending point is the coordinate of the k+1th row. V The operation of applying is a linear mapping.
[0089] If the number of turns is reduced while faithfully reproducing the shape of the original input graph, it can be said that local linear ordering of the graph has been successful. Here, the measure of faithful reproduction is the L1 norm, and the regularization of the number of turns of an edge is the kernel norm function, and the convex optimization problem formulation unit 511 formulates the optimization problem as shown in (3) below. Here, the kernel norm function is a function that calculates the sum of the singular values of the input matrix.
number
[0090] In order to solve the optimization problem (3) above, we use Primal-Dual Splitting (see L. Condat, “A primal-dual splitting method for convex optimization involving lipschitzian, proximable and linear composite terms,” Journal of Optimization Theory and Applications, 2013). The specific procedure executed by the convex optimization problem solving unit 512 is shown in FIG. 15. FIG. 15 is a diagram showing an algorithm showing a method for solving the local linear sorting problem. Note that the prox in the fourth line of FIG. τf In this case, f is given by (4) below.
[0091]
number
[0092] In the algorithm shown in FIG. 15, in the loop from line 3 to line 11 from n=1 to r, it is shown that the loop from line 6 to line 10 is performed for all elements belonging to V~ described above.
[0093] Therefore, lines 6 to 10 are executed r × (total number of elements belonging to V~) times. The following (5), calculated in line 8 of lines 6 to 10, is the proximity map of the kernel type norm.
[0094]
number
[0095] The above (5) is an SVT with the threshold λ of the matrix (6) below.
number
[0096] The process on line 8 takes up approximately 53.8% of the calculation time of the algorithm shown in Fig. 15. Therefore, by calculating the SVT using the above-mentioned calculation devices 10E and 10F, it is possible to execute the graph simplification process at a higher speed than in the past.
[0097] The coordinate information replacing unit 513 replaces the coordinate information with the vertex coordinates locally linearly aligned by the convex optimization problem solving unit 512, and outputs the locally linearly aligned G'.
[0098] This embodiment is applicable not only to graph simplification but also to all processes that perform SVT. For example, image false color removal, like graph simplification, is classified as a problem of regularizing a large number of small matrices.
[0099] As described above, according to this embodiment, the nucleus norm is expressed by a mixed norm without using singular values, and SVT calculation that does not require SVD is realized, so that the amount of calculation can be reduced. Furthermore, the algorithm can be easily data-parallelized, and multiple matrices can be processed simultaneously. If the algorithm can be data-parallelized, it can be speeded up by implementation using a data-parallel architecture such as Single Instruction Multiple Data (SIMD), which is adopted by many CPUs installed in personal computers.
[0100] In the calculation devices 10A to 10F described above, the components that perform various calculations, such as the addition unit and the inner product unit, may be provided with a storage device, such as a memory, for temporarily storing the calculation results, and the calculation results may be temporarily stored in this storage device.
[0101] Although an embodiment of the present invention has been described in detail above with reference to the drawings, the specific configuration is not limited to this embodiment, and designs that do not deviate from the gist of the present invention are also included. [Industrial Applicability]
[0102] The present invention is applicable to computing devices that perform square root calculations. [Explanation of symbols]
[0103] 10, 10A, 10B, 10C, 10D, 10E, 10F, 20, 40... Calculation device, 11, 21, 31, 41... High-speed reciprocal square root calculation unit, 12, 22, 32, 42, 52... Subtraction unit, 13, 23, 33, 43, 53, 63... Addition unit, 14, 24, 34, 44, 54, 64... Division unit, 15, 25, 35, 45, 55... Square root calculation unit, 16, 26, 36, 46, 56... Inner product unit, 17, 27, 37, 47, 57, 67, 77, 87, 97, 107, 117 ... multiplication unit, 18 ... absolute value calculation unit, 19 ... determinant calculation unit, 110, 120 ... decomposition unit, 200, 201 ... coefficient calculation unit, 300, 301 ... matrix conversion unit, 500 ... graph simplification unit, 510 ... local linear alignment unit, 511 ... convex optimization problem formulation unit, 512 ... convex optimization problem solving unit, 513 ... coordinate information replacement unit, 520 ... unnecessary vertex removal unit
Claims
1. a first reciprocal square root step in which the computer calculates the reciprocal square root of a positive real number A by a fast reciprocal square root method; a second reciprocal square root step in which the computer calculates the reciprocal square root of the positive real number B using a fast reciprocal square root method; A subtraction step in which the computer subtracts B from A; a first multiplication step in which the computer multiplies a result of the first reciprocal square root step by a result of the second reciprocal square root step; a second multiplication step in which the computer multiplies a result of the first multiplication step by a result of the subtraction step; an addition step in which the computer adds a result of the calculation in the first reciprocal square root step and a result of the calculation in the second reciprocal square root step; a division step in which the computer divides the result of the second multiplication step by the result of the addition step; A calculation method that includes:
2. a first addition step in which a computer adds a positive real number X and a positive real number e smaller than the real number X; A subtraction step in which the computer subtracts e from X; a first multiplication step in which the computer doubles e; a first reciprocal square root step in which the computer calculates a reciprocal square root of the calculation result of the first addition step by using a fast reciprocal square root method; a second reciprocal square root step in which the computer calculates a reciprocal square root of the calculation result in the subtraction step by a fast reciprocal square root method; a second addition step in which the computer adds a result of the calculation in the first reciprocal square root step and a result of the calculation in the second reciprocal square root step; a second multiplication step in which the computer multiplies a result of the first reciprocal square root step by a result of the second reciprocal square root step; a third multiplication step in which the computer multiplies a result of the second multiplication step by a result of the subtraction step; a division step in which the computer divides a result of the third multiplication step by a result of the second addition step; A calculation method that includes:
3. a first inner product step in which the computer calculates an inner product between first column vectors among first column vectors and second column vectors that configure an M×2 matrix; a second dot product step in which the computer calculates a dot product between the second column vectors; a third dot product step in which the computer calculates an dot product of the first column vector and the second column vector; an addition step in which a computer adds a calculation result in the first dot product step and a calculation result in the second dot product step; a first multiplication step in which the computer multiplies a calculation result in the first dot product step by a calculation result in the second dot product step; a second multiplication step in which the computer multiplies the inner products calculated in the third inner product step; a subtraction step in which the computer subtracts the calculation result in the second multiplication step from the calculation result in the first multiplication step; a square root calculation step in which the computer calculates the square root of the calculation result in the subtraction step; a third multiplication step in which the computer doubles the result of the square root calculation step; Equipped with A method for calculating the inverse of the sum of two singular values of an M×2 matrix, the inverse of the difference between two singular values, and one singular value by the method according to claim 2, where the calculation result in the addition step is X and the calculation result in the third multiplication step is e.
4. A calculation method comprising the steps of executing each step of claim 3, and further comprising a step of a computer calculating a singular value threshold process of an M×2 matrix using the inverse of the sum of two singular values and the inverse of the difference of the two singular values calculated by the calculation method of claim 3.
5. An alignment step in which a computer locally linearly aligns vertices of a graph in an M-dimensional space; a removing step in which the computer removes unnecessary edges and vertices from the vertices of the graph linearly arranged in the sorting step, based on angles between edges connecting the vertices; Equipped with The method according to claim 4, wherein in the alignment step, singular value threshold processing is performed using a kernicrotype norm function that calculates a sum of singular values.
6. A program for causing a computer to execute the calculation method according to any one of claims 1 to 5.
7. a first reciprocal square root unit that calculates a reciprocal square root of a positive real number A by a fast reciprocal square root method; a second reciprocal square root unit that calculates the reciprocal square root of a positive real number B by a fast reciprocal square root method; A subtraction unit that subtracts B from A; a first multiplication unit that multiplies a calculation result in the first reciprocal square root unit by a calculation result in the second reciprocal square root unit; a second multiplication unit that multiplies a result of the calculation in the first multiplication unit by a result of the calculation in the subtraction unit; an adder that adds a calculation result of the first reciprocal square root unit and a calculation result of the second reciprocal square root unit; a division unit that divides a calculation result in the second multiplication unit by a calculation result in the addition unit; A computing device comprising:
Citation Information
Patent Citations
Liquid discharge head, liquid discharge device and production method for liquid discharge head
JP2016221829A
Embedded graph simplification method, embedded graph simplification device, and computer program
JP2017211706A
Two-dimensional data simplification device, image encoder, image decoder, image coding method and image decoding method
JP2018082249A
Matrix simplification device, program, and matrix simplification method
JP2019046196A
Basis functions of three-dimensional models for compression, transformation and streaming
US20020039454A1
