Calculation method and device of trigonometric function value, storage medium and calculation equipment
By decomposing the input angle value into two parts, and using a lookup table and the traditional CORDIC algorithm combined with the difference-to-product formula to calculate the trigonometric function value, the problem of the traditional CORDIC algorithm having many iterations and long processing time is solved, achieving more efficient calculation and higher accuracy.
Patent Information
- Application Number
- CN202511247458.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2025-05-28
- Filing Date
- 2025-09-03
- Publication Date
- 2025-11-04
AI Technical Summary
Traditional CORDIC algorithms suffer from problems such as a large number of iterations, long processing time, and high hardware overhead in hardware implementation, resulting in low computational efficiency.
The input angle value is decomposed into a first part and a second part. The sine and cosine values of the first part are obtained using a lookup table, and the sine and cosine values of the second part are obtained using the traditional CORDIC algorithm. The final output value is calculated by combining trigonometric functions and the difference-to-product formula.
It reduces the number of iterations and critical path delay, improves computational efficiency, and is suitable for time-delay-sensitive real-time signal processing. At the same time, it improves accuracy, making it suitable for computational processes with high accuracy requirements, and is easy to implement.
Smart Images

Figure CN120892011A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of digital signal processing, and more particularly, to a method and device for calculating trigonometric function values, a storage medium and a computing device. BACKGROUND
[0002] The CORDIC (Coordinate Rotation Digital Computer) algorithm is an algorithm for calculating trigonometric function values, logarithmic function values, exponential function values, and other mathematical operation processing results. The main advantage of the CORDIC algorithm is that it only relies on addition and subtraction and shift operations, which makes it very suitable for implementation in hardware systems such as resource-limited embedded systems, digital chips, etc.
[0003] With the development of disciplines such as digital signal processing and computer graphics, the importance of the CORDIC algorithm in various computing scenarios related thereto is increasingly significant. For example, the CORDIC algorithm has been widely used in the calculation of FFT (Fast Fourier Transform), DCT (Discrete Cosine Transform), and various rotation transforms.
[0004] Although the traditional CORDIC algorithm has significant advantages in hardware implementation, it has certain limitations in terms of iteration number (i.e., calculation delay) and hardware overhead. In order to improve the calculation accuracy and reduce the iteration number, researchers have proposed various improvement schemes, such as the Hybrid CORDIC algorithm and the two-step branch CORDIC algorithm. These improvement schemes optimize the basic architecture and iteration process of the algorithm, improving the performance of the CORDIC algorithm.
[0005] However, these improvement schemes still have some deficiencies in practical applications, such as serious accuracy loss, complex hardware implementation, long critical path delay, etc., resulting in low calculation processing efficiency of the algorithm when actually running inside the hardware.
[0006] Therefore, it is necessary to propose a new method for calculating trigonometric function values to solve the above problems. SUMMARY
[0007] The present application aims to solve the above problems.
[0008] According to a first aspect of the present application, a method for calculating trigonometric function values is provided, the method comprising: obtaining an input angle value; obtaining a first part of the input angle value as a first part angle value; obtaining a second part of the input angle value as a second part angle value; The first partial angle value is taken as a lookup input value of a lookup table, and a first sine value and a first cosine value corresponding to the first partial angle value are obtained based on the lookup table; The second partial angle value is taken as a calculation input value of a traditional CORDIC algorithm, and a second sine value and a second cosine value corresponding to the second partial angle value are obtained based on the traditional CORDIC algorithm; The output trigonometric function value corresponding to the input angle value is obtained based on the first sine value, the first cosine value, the second sine value, the second cosine value and a trigonometric function sum-difference product relation formula, The input angle value is equal to the sum of the first partial angle value and the second partial angle value.
[0009] 1、The above technical solution decomposes the input angle value into a first partial angle value and a second partial angle value, and directly uses the traditional CORDIC algorithm for the second partial angle value (small numerical range, and the maximum number of iterations required to achieve the same accuracy is m times, for example, m=4), which can greatly reduce the number of iterations (for example, from 16 to 4) compared with using the same traditional CORDIC algorithm for the original input angle value (large numerical range, and the maximum number of iterations required to achieve the same accuracy is n times, for example, n=16) -that is, to reduce the critical path delay, assuming that the time delay of one iteration is i clock cycles (for example, i=6), then the critical path delay introduced by this step is m×i (for example, 24 clock cycles).
[0010] 2、The lookup table operation on the first partial angle value in the above technical solution introduces a delay of usually 1 clock cycle. For example, when the lookup table operation and the CORDIC algorithm are executed in parallel, the delay introduced by the lookup table operation is smaller, so it can be ignored in the total delay of the above technical solution.
[0011] 3、The operation of calculating the final output trigonometric function value through the trigonometric function sum-difference product relation formula in the above technical solution introduces a delay of usually 4 clock cycles, or even less than the delay of one iteration (for example, the above i=6 clock cycles).
[0012] In summary, the total delay (m×i+4, for example, 28 clock cycles) of the above technical solution is less than the total delay (n×i, for example, 96 clock cycles) produced by directly using the same traditional CORDIC algorithm for the original input angle value, that is, the above technical solution reduces the delay by 68 clock cycles.
[0013] Therefore, compared with the prior art solution which purely uses the traditional CORDIC algorithm, the above technical solution can reduce the number of iterations (i.e., reduce the critical path delay) while ensuring the same output accuracy. Therefore, the above technical solution is very suitable for real-time signal processing processes which are sensitive to time delay.
[0014] On the other hand, 1) the range of the second partial angle value is small, and when the traditional CORDIC algorithm is used for it, higher-precision second sine and cosine values can be obtained under the same maximum number of iterations; 2) the designed lookup table can store higher-precision first sine and / or first cosine values. Based on these higher-precision first sine, first cosine, second sine, and second cosine values, further calculation of the final desired output trigonometric function value using the trigonometric function and difference product-sum relationship formula can obtain a higher-precision output trigonometric function value. Therefore, the above technical solution can also be applied to calculation processes which are not sensitive to time delay but have high accuracy requirements.
[0015] Compared with the technical solution which purely uses the traditional CORDIC algorithm, the above technical solution obtains the above technical advantages at the cost of: 1) a small amount of time delay (e.g., 4 clock cycles) needs to be added to the trigonometric function and difference product-sum calculation process; 2) storage resources (storage space required by the lookup table) are increased.
[0016] The above technical solution does not make any changes to the traditional CORDIC algorithm (e.g., the traditional iterative calculation process) itself, and therefore, compared with other improved technical solutions for the traditional CORDIC algorithm, such as other improved technical solutions using Hybrid (hybrid) CORDIC algorithm and double-step branch CORDIC algorithm, the above technical solution according to the present application is easier for a skilled person to implement.
[0017] Optionally, the method further comprises: pre-constructing and storing the lookup table, wherein the lookup table comprises at least one of the first sine value and the first cosine value.
[0018] Optionally, the first partial angle value is an integer part of the input angle value, and the second partial angle value is a decimal part of the input angle value.
[0019] According to a second aspect of the present application, a trigonometric function value calculation device is provided, the device comprising: a first obtaining module configured to obtain an input angle value; a second obtaining module configured to obtain a first partial angle value which is a first part of the input angle value; a third obtaining module configured to obtain a second partial angle value which is a second part of the input angle value; a lookup table configured to take the first partial angle value as a lookup input value to obtain a first sine value and a first cosine value corresponding to the first partial angle value; a traditional CORDIC calculation module configured to take the second partial angle value as a calculation input value to obtain a second sine value and a second cosine value corresponding to the second partial angle value based on a traditional CORDIC algorithm; an output trigonometric function value calculation module configured to obtain an output trigonometric function value corresponding to the input angle value based on the first sine value, the first cosine value, the second sine value, the second cosine value and a trigonometric function sum-difference product formula, wherein the input angle value is equal to a sum of the first partial angle value and the second partial angle value.
[0020] Optionally, the first partial angle value is an integer part of the input angle value, and the second partial angle value is a decimal part of the input angle value.
[0021] According to a third aspect of the present application, there is provided a computer readable storage medium having stored thereon a computer program, which, when executed by a processor, implements the method for calculating a trigonometric function value.
[0022] According to a fourth aspect of the present application, there is provided a computing device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method for calculating a trigonometric function value when executing the program.
[0023] The technical effects of the technical solutions according to the second aspect, the third aspect and the fourth aspect of the present application are the same as those of the corresponding technical solutions according to the first aspect of the present application, and will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0024] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present application and, together with the description, serve to explain the principles of the present application. In these drawings, like reference numerals are used to represent similar elements throughout the various figures. The drawings below depict some embodiments of the present application, but not all embodiments. Other embodiments can be derived from the drawings by one of ordinary skill in the art without paying creative labor.
[0025] Figure 1 An embodiment of the method for calculating a trigonometric function value according to the present application is shown; Figure 2 An embodiment of the computing device according to the present application is shown. DETAILED DESCRIPTION
[0026] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application. It should be noted that, in the case of no conflict, the embodiments in the present application and the features in the embodiments can be combined with each other at will.
[0027] Figure 1 An embodiment of the method 100 for calculating trigonometric function values according to the present application is shown.
[0028] As shown in Figure 1 The method 100 for calculating trigonometric function values according to the present application comprises: Step S101: obtaining an input angle value; Step S103: obtaining a first part of the input angle value as a first part angle value; Step S105: obtaining a second part of the input angle value as a second part angle value; Step S107: taking the first part angle value as a lookup input value of a lookup table, and obtaining a first sine value and a first cosine value corresponding to the first part angle value based on the lookup table; Step S109: taking the second part angle value as a calculation input value of a traditional CORDIC algorithm, and obtaining a second sine value and a second cosine value corresponding to the second part angle value based on the traditional CORDIC algorithm; Step S111: obtaining an output trigonometric function value corresponding to the input angle value based on the first sine value, the first cosine value, the second sine value, the second cosine value and a trigonometric function sum-difference product relation formula, wherein the input angle value is equal to the sum of the first part angle value and the second part angle value.
[0029] 1. The above technical solution decomposes the input angle value into a first part and a second part. Only the second part of the angle value (with a small numerical range, requiring fewer maximum iterations to achieve the same accuracy, i.e., m times, for example, m=4) directly adopts the traditional CORDIC algorithm. Compared with the original input angle value (with a large numerical range, requiring more maximum iterations to achieve the same accuracy, i.e., n times, for example, n=16) using the same traditional CORDIC algorithm, the number of iterations can be significantly reduced (e.g., from 16 to 4) – that is, the critical path delay is reduced. Assuming that the delay of one iteration is i clock cycles (e.g., i=6), the critical path delay introduced by this step is m×i (e.g., 24 clock cycles).
[0030] 2. The table lookup operation for the first set of angle values in the above technical solution typically introduces a delay of one clock cycle. For example, when the table lookup operation is executed in parallel with the CORDIC algorithm, the delay introduced by the table lookup operation is smaller and can therefore be disregarded in the total delay of the above technical solution.
[0031] 3. The operation of calculating the final output trigonometric function value through the formula of trigonometric function sum-to-product relationship in the above technical solution usually introduces a delay of 4 clock cycles, or even less than the delay of 1 iteration (for example, i=6 clock cycles above).
[0032] In summary, the total latency of the above technical solution (m×i+4, for example, 28 clock cycles) is less than the total latency (n×i, for example, 96 clock cycles) generated by directly applying the same traditional CORDIC algorithm to the original input angle value. That is, the above technical solution reduces the latency by 68 clock cycles.
[0033] Therefore, compared with existing technologies that purely employ the traditional CORDIC algorithm, the above-mentioned technology can reduce the number of iterations (i.e., reduce critical path delay) while maintaining the same output accuracy. Thus, the above-mentioned technology is highly suitable for time-delay-sensitive real-time signal processing.
[0034] On the other hand, 1) the range of the second part of the angle values is small, and when using the traditional CORDIC algorithm on it, higher precision second sine and second cosine values can be obtained with the same maximum number of iterations; 2) a well-designed lookup table can store higher precision first sine and / or first cosine values. Based on these higher precision first sine, first cosine, second sine, and second cosine values, the final desired output trigonometric function value can be further calculated using the trigonometric function sum-to-product relationship formula, thus obtaining a higher precision output trigonometric function value. Therefore, the above technical solution can also be applied to calculation processes that are not sensitive to time delay but require high precision.
[0035] Compared with the technical solution that uses the traditional CORDIC algorithm, the cost of the above technical solution to achieve the above technical advantages is only: 1) the calculation process of trigonometric functions and difference products requires a small increase in total time delay (e.g., 4 clock cycles); 2) increased storage resources (the storage space required for the lookup table).
[0036] The above technical solution does not modify the traditional CORDIC algorithm (e.g., the traditional iterative calculation process) itself. Therefore, compared with other improved technical solutions for the traditional CORDIC algorithm, such as other improved technical solutions using the Hybrid CORDIC algorithm and the two-step branch CORDIC algorithm, the above technical solution according to the present invention is easier for those skilled in the art to implement.
[0037] Optionally, method 100 may further include: Step S113: Pre-build and store the lookup table. The lookup table includes at least one of the first sine value and the first cosine value.
[0038] Optionally, the first part of the angle value is the integer part of the input angle value, and the second part of the angle value is the fractional part of the input angle value.
[0039] Figure 2 An embodiment of the computing device 200 according to the present invention is shown.
[0040] like Figure 2 As shown, the computing device 200 according to the present invention includes: The first acquisition module 202 is used to acquire the input angle value; The second acquisition module 204 is used to acquire the first part of the input angle value as the first part angle value; The third acquisition module 206 is used to acquire the second part of the input angle value as the second part angle value; Lookup table 208 is used to take the first part of the angle values as lookup input values to obtain the first sine value and the first cosine value corresponding to the first part of the angle values; The conventional CORDIC calculation module 210 is used to take the second part of the angle value as the calculation input value and obtain the second sine value and the second cosine value corresponding to the second part of the angle value based on the conventional CORDIC algorithm. The output trigonometric function value calculation module 212 is used to obtain the output trigonometric function value corresponding to the input angle value based on the first sine value, the first cosine value, the second sine value, the second cosine value, and the trigonometric function sum-to-product relationship formula. The input angle value is equal to the sum of the first partial angle value and the second partial angle value.
[0041] Optionally, the first partial angle value is an integer part of the input angle value, and the second partial angle value is a decimal part of the input angle value.
[0042] According to an embodiment of the present application, a computer readable storage medium is provided, and the storage medium has a computer program stored thereon, and the program, when executed by a processor, implements the steps of the method for calculating a trigonometric function value.
[0043] According to an embodiment of the present application, a computing device is provided, and the computing device comprises a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor, when executing the program, implements the steps of the method for calculating a trigonometric function value.
[0044] The technical effects of the computing device 200, the computer readable storage medium, and the computing device according to the respective technical solutions of the present application are the same as those of the method for calculating a trigonometric function value 100 according to the present application, and will not be described again.
[0045] Those skilled in the art can understand that the above description can be implemented alone or in various combinations, the steps in the above described method can be combined, the order of the steps can be changed, and a part or all of the steps can be executed sequentially and / or in parallel, and these variants are within the protection scope of the present application.
[0046] Those of ordinary skill in the art will understand that all or a portion of the steps in the above-disclosed methods, the functions of the modules / units in the systems, apparatuses, and devices can be implemented as software, firmware, hardware, or any suitable combination thereof. In a hardware implementation, the division of the functionality between the modules / units referred to in the above description does not necessarily correspond to physical divisions of the hardware; for example, one physical component can have multiple functions, or one function or step can be performed by several physical components working together. Some or all of the components can be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or as hardware, or as an integrated circuit, such as an application- specific integrated circuit. Such software can be distributed on computer readable media, which can comprise computer storage media (or non-transitory media) and communication media (or transitory media). As is well known to those of ordinary skill in the art, computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Further, as is well known to those of ordinary skill in the art, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media.
[0047] Finally, it should be noted that the above embodiments are merely used to illustrate the technical solutions of the present application, instead of limiting the technical solutions of the present application. Even though the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that modifications to the technical solutions recorded in the foregoing embodiments, or equivalent replacements to some of the technical features, can be made; and such modifications or replacements do not cause the technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method of calculating a trigonometric function value, characterized by, The method comprises: obtaining an input angle value; obtaining a first part of the input angle value as a first part angle value; obtaining a second part of the input angle value as a second part angle value; taking the first part angle value as a lookup input value of a lookup table, and obtaining a first sine value and a first cosine value corresponding to the first part angle value based on the lookup table; taking the second part angle value as a calculation input value of a traditional CORDIC algorithm, and obtaining a second sine value and a second cosine value corresponding to the second part angle value based on the traditional CORDIC algorithm; obtaining an output trigonometric function value corresponding to the input angle value based on the first sine value, the first cosine value, the second sine value, the second cosine value, and a trigonometric function sum-difference product relation formula, wherein the input angle value is equal to the sum of the first part angle value and the second part angle value.
2. The method of claim 1, wherein, The method further comprises: pre-constructing and storing the lookup table, wherein the lookup table comprises at least one of the first sine value and the first cosine value.
3. The method according to any one of claims 1-2, characterized in that, The first part angle value is an integer part of the input angle value, and the second part angle value is a decimal part of the input angle value.
4. An apparatus for calculating a trigonometric function value, characterized by comprising: The device comprises: a first obtaining module for obtaining an input angle value; a second obtaining module for obtaining a first part of the input angle value as a first part angle value; a third obtaining module for obtaining a second part of the input angle value as a second part angle value; a lookup table for taking the first part angle value as a lookup input value to obtain a first sine value and a first cosine value corresponding to the first part angle value; a traditional CORDIC calculation module for taking the second part angle value as a calculation input value to obtain a second sine value and a second cosine value corresponding to the second part angle value based on a traditional CORDIC algorithm; an output trigonometric function value calculation module for obtaining an output trigonometric function value corresponding to the input angle value based on the first sine value, the first cosine value, the second sine value, the second cosine value, and a trigonometric function sum-difference product relation formula, wherein the input angle value is equal to the sum of the first part angle value and the second part angle value.
5. The apparatus of claim 4, wherein, The first part angle value is an integer part of the input angle value, and the second part angle value is a decimal part of the input angle value.
6. A computer readable storage medium characterized by, The storage medium has a computer program stored thereon, and the program, when executed by a processor, implements the steps of the method according to any one of claims 1 to 3.
7. A computing device, comprising: The computing device comprises a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor, when executing the program, implements the steps of the method according to any one of claims 1 to 3.