CN117111885A - Trigonometric function calculation method, trigonometric function calculation device, computer equipment and microprocessor - Google Patents

Trigonometric function calculation method, trigonometric function calculation device, computer equipment and microprocessor Download PDF

Info

Publication number
CN117111885A
CN117111885A CN202311078340.1A CN202311078340A CN117111885A CN 117111885 A CN117111885 A CN 117111885A CN 202311078340 A CN202311078340 A CN 202311078340A CN 117111885 A CN117111885 A CN 117111885A
Authority
CN
China
Prior art keywords
angle value
taylor series
series expansion
converting
floating point
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311078340.1A
Other languages
Chinese (zh)
Inventor
孙阳
吴松波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Gree Electric Appliances Inc of Zhuhai
Zhuhai Zero Boundary Integrated Circuit Co Ltd
Original Assignee
Gree Electric Appliances Inc of Zhuhai
Zhuhai Zero Boundary Integrated Circuit Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Gree Electric Appliances Inc of Zhuhai, Zhuhai Zero Boundary Integrated Circuit Co Ltd filed Critical Gree Electric Appliances Inc of Zhuhai
Priority to CN202311078340.1A priority Critical patent/CN117111885A/en
Publication of CN117111885A publication Critical patent/CN117111885A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/38Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation
    • G06F7/48Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices
    • G06F7/544Methods or arrangements for performing computations using exclusively denominational number representation, e.g. using binary, ternary, decimal representation using non-contact-making devices, e.g. tube, solid state device; using unspecified devices for evaluating functions by calculation
    • G06F7/548Trigonometric functions; Co-ordinate transformations

Abstract

The application provides a trigonometric function calculation method, a trigonometric function calculation device, computer equipment and a microprocessor, wherein the method comprises the steps of converting a first angle value in the form of a floating point number into a second angle value in the form of a fixed point quantity; converting the second angle value into a third angle value of the sine function in the first quadrant; determining a Taylor series expansion corresponding to the third angle value based on a pre-stored corresponding relation between the interval and the Taylor series expansion order; and converting the calculated result of the Taylor series expansion of the third angle value into a floating point quantity. The method provided by the application can be based on a Taylor series expansion formula of a trigonometric function, uses fixed-point operation of unsigned shaping quantity to replace floating-point operation, and plays a role in accelerating floating-point operation on a platform without a floating-point unit.

Description

Trigonometric function calculation method, trigonometric function calculation device, computer equipment and microprocessor
Technical Field
The present application relates to the field of microprocessor technologies, and in particular, to a trigonometric function calculation method, apparatus, computer device, and microprocessor.
Background
When the requirements of calculation frequency and precision are high, the requirement of software calculation cannot be met by using a CPU, and the requirement of using the MCU supporting hardware to calculate the trigonometric function is needed. Hardware computation trigonometric functions accelerate computation by a dedicated trigonometric function computation module such as a coordinate rotation digital computer, or by a floating point unit for computing floating point numbers.
Although the use of a trigonometric function MCU supporting hardware solution can improve the calculation efficiency, additional hardware cost may be brought; the software calculation of the trigonometric function by using the CPU does not need additional hardware cost investment, but the calculation speed, the calculation precision and the code quantity are difficult to meet the requirements at the same time. The trigonometric function value calculated by the Taylor series method has the characteristics of simple codes and high calculation accuracy, however, the method comprises a large number of floating point calculations, and the calculation efficiency is low on a platform without a floating point unit.
Disclosure of Invention
In order to solve the problem that the existing microprocessor is difficult to calculate the trigonometric function, the application provides a trigonometric function calculation method, a trigonometric function calculation device, computer equipment and a microprocessor, which can play a role in fast operation of the trigonometric function on a platform without a floating point unit.
In one aspect, a trigonometric function calculation method is provided, the method comprising:
converting the first angle value in the form of floating point number into the second angle value in the form of fixed point quantity;
converting the second angle value into a third angle value of the sine function in the first quadrant;
determining a Taylor series expansion corresponding to the third angle value based on a pre-stored corresponding relation between the interval and the Taylor series expansion order;
and converting the calculated result of the Taylor series expansion of the third angle value into a floating point quantity.
In some embodiments, the converting the first angle value in the form of a floating point number to the second angle value in the form of a fixed point quantity includes:
converting the first angle value in the floating point number form into a second angle value in the 32-bit unsigned shaping quantity form; the 32-bit unsigned shaping amount is a fixed point amount of 1-bit integer plus 31-bit mantissa.
In some embodiments, after converting the first angle value in the form of a floating point number to the second angle value in the form of a fixed point quantity, the method includes:
calculating a sign bit based on the second angle value;
correspondingly, the converting the calculation result of the taylor series expansion of the third angle value into a floating point number includes:
adding the sign bit to the calculated result of the Taylor series expansion of the third angle value;
and converting the calculation result after adding the sign bit into a floating point quantity.
In some embodiments, the calculating a sign bit based on the second angle value includes:
when a sine function is calculated, multiplying the second angle value by 1/pi and rounding;
if the odd number is obtained by rounding, the sign bit is negative; if the rounding results in an even number, the sign bit is positive.
In some embodiments, the method further comprises constructing the interval to taylor series expansion order correspondence:
dividing the [0, pi/2 ] interval into three subintervals of [0, P1], (P1, P2], (P2, pi/2 ], wherein P1 is smaller than pi/4, and P2 is larger than pi/4;
each subinterval corresponds to a taylor series expansion order.
In some embodiments, the constructing the correspondence of the interval and the taylor series expansion order comprises:
the [0, P1] subinterval corresponds to the Taylor series expansion 7 th order, the (P1, P2) subinterval corresponds to the Taylor series expansion 5 th order, and the (P2, pi/2) subinterval corresponds to the Taylor series expansion 8 th order.
In another aspect, there is provided a trigonometric function calculation apparatus including:
the first conversion module is used for converting a first angle value in the form of a floating point number into a second angle value in the form of a fixed point quantity;
the second conversion module is used for converting the second angle value into a third angle value of the sine function in the first quadrant;
the computing module is used for determining a Taylor series expansion corresponding to the third angle value based on a corresponding relation between a pre-stored interval and a Taylor series expansion order;
and the third conversion module is used for converting the calculated result of the Taylor series expansion of the third angle value into a floating point quantity.
In some embodiments, the first conversion module is specifically configured to:
converting the first angle value in the floating point number form into a second angle value in the 32-bit unsigned shaping quantity form; the 32-bit unsigned shaping amount is a fixed point amount of 1-bit integer plus 31-bit mantissa. .
In some embodiments, the apparatus further comprises a symbol calculation module for:
calculating a sign bit based on the second angle value;
correspondingly, the third conversion module is used for:
adding the sign bit to the calculated result of the Taylor series expansion of the third angle value;
and converting the calculation result after adding the sign bit into a floating point quantity.
In some embodiments, the symbol calculation module is specifically configured to:
when a sine function is calculated, multiplying the second angle value by 1/pi and rounding;
if the odd number is obtained by rounding, the sign bit is negative; if the rounding results in an even number, the sign bit is positive.
In some embodiments, the apparatus further includes a correspondence establishing module configured to:
dividing the [0, pi/2 ] interval into three subintervals of [0, P1], (P1, P2], (P2, pi/2 ], wherein P1 is smaller than pi/4, and P2 is larger than pi/4;
each subinterval corresponds to a taylor series expansion order.
In some embodiments, the correspondence establishing module is specifically configured to:
the [0, P1] subinterval corresponds to the Taylor series expansion 7 th order, the (P1, P2) subinterval corresponds to the Taylor series expansion 5 th order, and the (P2, pi/2) subinterval corresponds to the Taylor series expansion 8 th order.
In another aspect, a computer device is provided, where the computer device includes a processor and a memory, where the memory stores at least one instruction, at least one program, a code set, or an instruction set, and the processor may load and execute the at least one instruction, the at least one program, the code set, or the instruction set, to implement the trigonometric function calculation method provided in the embodiment of the application.
In another aspect, a microprocessor is provided, comprising a computer device as described above.
In another aspect, a computer readable storage medium is provided, where at least one instruction, at least one program, a code set, or an instruction set is stored in the readable storage medium, and a processor may load and execute the at least one instruction, the at least one program, the code set, or the instruction set, so as to implement the trigonometric function calculation method provided in the embodiment of the present application.
In another aspect, a computer program product or computer program is provided, the computer program title or computer program comprising computer program instructions stored in a computer readable storage medium. The processor reads the computer instructions from the computer-readable storage medium and executes the computer instructions, so that the computer device performs the trigonometric function calculation method according to any one of the above embodiments.
The technical scheme provided by the application has the beneficial effects that at least: the embodiment of the application provides a trigonometric function calculation method, a trigonometric function calculation device, computer equipment and a microprocessor, wherein the method comprises the steps of converting a first angle value in the form of a floating point number into a second angle value in the form of a fixed point quantity; converting the second angle value into a third angle value of the sine function in the first quadrant; determining a Taylor series expansion corresponding to the third angle value based on a pre-stored corresponding relation between the interval and the Taylor series expansion order; and converting the calculated result of the Taylor series expansion of the third angle value into a floating point quantity. The method provided by the embodiment of the application can be based on a Taylor series expansion formula of a trigonometric function, uses fixed-point operation of unsigned shaping quantity to replace floating-point operation, and plays a role in accelerating floating-point operation similar to a floating-point unit on a platform without the floating-point unit.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram showing an implementation flow of a trigonometric function calculation method according to an exemplary embodiment of the present application;
FIG. 2 is a schematic flow chart of another implementation of a trigonometric function calculation method according to an exemplary embodiment of the present application;
FIG. 3 illustrates a block diagram of a trigonometric function calculation device according to an exemplary embodiment of the present application;
fig. 4 is a schematic structural diagram of a computer device corresponding to a trigonometric function calculation method according to an exemplary embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
The trigonometric function calculation method provided by the application can play a role in the rapid operation of the trigonometric function on a platform without a floating point unit.
Embodiment 1,
Fig. 1 shows a schematic implementation flow diagram of a trigonometric function calculation method according to an embodiment of the present application.
Referring to fig. 1, the trigonometric function calculation method provided by the embodiment of the present application may include steps 101 to 104.
Step 101: the first angle value in the form of a floating point number is converted into a second angle value in the form of a fixed point quantity.
In some embodiments, the input argument is an angle value in the form of an arc angle.
In some embodiments, step 101 comprises:
converting the first angle value in the floating point number form into a second angle value in the 32-bit unsigned shaping quantity form; the 32-bit unsigned shaping amount is a fixed point amount of 1-bit integer plus 31-bit mantissa.
In the [0, pi/2 ] interval, the independent variables x and SIN function values, COS function values are all less than 2, so all floating point numbers are converted into fixed point numbers of 1 bit integer+31 bit mantissas expressed in 32 bit unsigned shaping amount (unsigned long) to realize efficient operation on microprocessors without floating point units.
In practical application, the integer digits and digits can take other values, and the calculation result is closer to the theoretical value of the trigonometric function as the number of mantissas is larger.
Alternatively, the 32-bit unsigned shaping amount can also be 16 bits or 64 bits, and the higher the bit number is, the higher the calculation accuracy is, but the calculation accuracy needs to be matched with the Taylor expansion order, otherwise, the calculation force is wasted.
The addition and subtraction of the fixed point number for the 32-bit unsigned shaped quantity representation may be performed in accordance with the shaped quantity addition and subtraction.
The calculation formula for the fixed point number multiplication for a 32-bit unsigned shaped quantity representation includes:
MN=(M1N1+((M1N2+M2N1)>>16))<<k=P
wherein M and N are respectively fixed point numbers represented by 32-bit unsigned shaping quantity, M1 is the high 16 bits of M, N1 is the high 16 bits of N, M2 is the low 16 bits of M, N2 is the low 16 bits of N, <16 is left shift 16 bits, k is right shift k bits, and P is a calculation result.
K is the sum of the integer numbers of M, N minus the integer number of P, K being 1 in a fixed point operation of a 1-bit integer.
In some embodiments, after step 101, the method further comprises:
and calculating a sign bit based on the second angle value.
In some embodiments, the calculating a sign bit based on the second angle value comprises:
when a sine function is calculated, multiplying the second angle value by 1/pi and rounding;
if the odd number is obtained by rounding, the sign bit is negative; if the rounding results in an even number, the sign bit is positive.
Alternatively, the calculation process of the sign bit may include: calculating X (1/pi) and rounding to obtain n, and combining the sign bit of X to calculate the sign bit of SIN function/COS function calculation result.
The period sign U, SIN function sign bit V, COS sign bit W are defined.
The input radian angle x is a floating point number and can be represented by a signed binary scientific counting method, such as + -1.234 x 2 n.
The floating point number X is split into a sign, an exponent and a base by definition, and the base is converted into a fixed point number X.
Since the SIN function is an odd function, the sign bit of SIN is equal to the sign bit of x.
When n is greater than or equal to 1, the arc angle x is greater than or equal to 2, i.e., x is greater than pi/2. At this time, x (1/pi) is rounded to obtain M, and the sign bit U is negative when M is odd, and the sign bit U is positive when M is even.
Let x=x-M, if x > pi/2, then x=pi/2-x, and the sign bit W of the COS function is negative.
Step 102: the second angle value is converted into a third angle value of the sine function in the first quadrant.
The trigonometric function calculation method provided by the application is based on the Taylor series expansion of the SIN function, and the COS function can be obtained by phase shifting the SIN function because the trigonometric function has symmetry, so that the calculation mode of the SIN function in other quadrants and the COS function can be obtained based on the calculation of the SIN function in the first quadrant.
In some embodiments, the periodicity and symmetry of the trigonometric function are used to convert the input argument x to a sine function within the [0, pi/2 ] interval for computation.
Optionally, modulo X, to obtain x=x-n pi, and converting the cosine function based on the conversion relationship between sine and cosine.
Step 103: and determining the Taylor series expansion corresponding to the third angle value based on the pre-stored corresponding relation between the interval and the Taylor series expansion order.
In some embodiments, the method further comprises constructing the interval to taylor series expansion order correspondence:
dividing the [0, pi/2 ] interval into three subintervals of [0, P1], (P1, P2], (P2, pi/2 ], wherein P1 is smaller than pi/4, and P2 is larger than pi/4;
each subinterval corresponds to a taylor series expansion order.
Alternatively, the [0, P1] subinterval corresponds to the Taylor series expansion 7 th order, the (P1, P2) subinterval corresponds to the Taylor series expansion 5 th order, and the (P2, pi/2) subinterval corresponds to the Taylor series expansion 8 th order.
To meet the error accuracy requirement, the SIN function is expanded to 7 th order using a taylor series at x=0, to 5 th order using a taylor series at x=pi/4, and to 8 th order using a taylor series at x=pi/2.
Alternatively, other expansion series and function segments can be selected based on actual needs, with different expansion series or function segments affecting computational accuracy and complexity
Step 104: and converting the calculated result of the Taylor series expansion of the third angle value into a floating point quantity.
In some embodiments, step 104 further comprises:
adding the sign bit to the calculated result of the Taylor series expansion of the third angle value;
and converting the calculation result after adding the sign bit into a floating point quantity.
In some embodiments, the fixed point number is converted into the floating point number to output the operation result, and sign bits are added, where the sign bits have a value of u×v.
When calculating the COS function, the independent variable x=pi/2-x, and the final added sign bit takes a value of U.
In practical application, the fixed point number is not defined in a standardized way like the floating point number, and the numerical range which can be represented by the fixed point number is not as good as the floating point number, however, the numerical format and the operation method provided by the application are suitable for the calculation of the trigonometric function, and the purpose of accelerating the calculation can be achieved by applying the numerical format and the operation method to the process of calculating the trigonometric function value by the Taylor method.
The trigonometric function calculation method provided by the embodiment of the application adopts fixed-point operation of unsigned shaping quantity to replace floating point budget, can realize the acceleration of the calculation of the Taylor series trigonometric function under the condition of no floating point unit and trigonometric function calculation module, improves the calculation speed of the trigonometric function under the premise of not increasing the cost, and has the characteristics of simple code, high calculation precision and high calculation efficiency.
Embodiment II,
Fig. 2 is a schematic flow chart of another implementation of the trigonometric function calculation method according to the embodiment of the present application.
Referring to fig. 2, in a specific example, the implementation procedure of the method provided by the embodiment of the present application is as follows.
Firstly, inputting an arc angle X to be calculated, converting the arc angle into a fixed point quantity X, calculating X (1/pi) and rounding, and then using the fixed point quantity X to perform modulo taking.
If X > pi/2, let x=pi/2-X.
Further, it is determined whether to calculate the cos value or the sin value. If the cos value is calculated, let x=pi/2-X.
And judging the interval where X is located. If X < P1, then calculate using equation a; if P1< X < P2, then it is calculated using equation b, and if X > P2, then it is calculated using equation c.
On the other hand, the sign bit is calculated according to the structure, and the sign bit is added to the calculation result obtained by using the formula.
And finally converting the calculation result into floating point quantity output.
In a specific illustration, the method provided by the application is verified based on a platform, compared with a single-precision trigonometric function defined in a C voice standard library using a Taylor series and a table lookup method, the code volume is only 30% of functions in the standard library, the calculation time is 23% of functions provided by the standard library, and the calculation error in the interval of [ -pi, pi ] is 71% of functions provided by the standard library, so that a good optimization effect can be realized.
In summary, the trigonometric function calculation method provided by the embodiment of the application uses the fixed point operation of unsigned shaping quantity to replace floating point budget based on the taylor series expansion formula of the trigonometric function, plays a role in accelerating the floating point operation speed similar to the floating point unit on a platform without the floating point unit, can not depend on extra hardware environment, does not occupy a large amount of code space, and has good compatibility.
Third embodiment,
Fig. 3 is a schematic structural diagram of a trigonometric function calculation device according to an embodiment of the present application.
Referring to fig. 3, a trigonometric function calculation device provided by an embodiment of the present application may include:
the first conversion module is used for converting a first angle value in the form of a floating point number into a second angle value in the form of a fixed point quantity;
the second conversion module is used for converting the second angle value into a third angle value of the sine function in the first quadrant;
the computing module is used for determining a Taylor series expansion corresponding to the third angle value based on a corresponding relation between a pre-stored interval and a Taylor series expansion order;
and the third conversion module is used for converting the calculated result of the Taylor series expansion of the third angle value into a floating point quantity.
In some embodiments, the first conversion module is specifically configured to:
converting the first angle value in the floating point number form into a second angle value in the 32-bit unsigned shaping quantity form; the 32-bit unsigned shaping amount is a fixed point amount of 1-bit integer plus 31-bit mantissa. .
In some embodiments, the apparatus further comprises a symbol calculation module for:
calculating a sign bit based on the second angle value;
correspondingly, the third conversion module is used for:
adding the sign bit to the calculated result of the Taylor series expansion of the third angle value;
and converting the calculation result after adding the sign bit into a floating point quantity.
In some embodiments, the symbol calculation module is specifically configured to:
when a sine function is calculated, multiplying the second angle value by 1/pi and rounding;
if the odd number is obtained by rounding, the sign bit is negative; if the rounding results in an even number, the sign bit is positive.
In some embodiments, the apparatus further includes a correspondence establishing module configured to:
dividing the [0, pi/2 ] interval into three subintervals of [0, P1], (P1, P2], (P2, pi/2 ], wherein P1 is smaller than pi/4, and P2 is larger than pi/4;
each subinterval corresponds to a taylor series expansion order.
In some embodiments, the correspondence establishing module is specifically configured to:
the [0, P1] subinterval corresponds to the Taylor series expansion 7 th order, the (P1, P2) subinterval corresponds to the Taylor series expansion 5 th order, and the (P2, pi/2) subinterval corresponds to the Taylor series expansion 8 th order.
In summary, the trigonometric function calculation device provided by the embodiment of the application can replace floating point budget by using fixed point operation of unsigned shaping quantity based on a taylor series expansion formula of a trigonometric function, plays a role in accelerating floating point operation speed similar to a floating point unit on a platform without the floating point unit, can not depend on extra hardware environment, does not occupy a large amount of code space, and has good compatibility.
Fourth embodiment,
Fig. 4 shows a schematic structural diagram of a computer device according to an exemplary embodiment of the present application, where the computer device includes:
processor 301, including one or more processing cores, executes various functional applications and data processing by running software programs and modules by processor 301.
The receiver 302 and the transmitter 303 may be implemented as one communication component, which may be a communication chip. Alternatively, the communication component may be implemented to include a signaling function. That is, the transmitter 303 may be used to transmit control signals to the image acquisition device and the scanning device, and the receiver 302 may be used to receive corresponding feedback instructions.
The memory 304 is connected to the processor 301 by a bus 305.
The memory 304 may be configured to store at least one instruction, and the processor 301 is configured to execute the at least one instruction to implement steps 101 to 102 in the above-described embodiment of the trigonometric function calculation method.
It will be appreciated by those skilled in the art that fig. 4 is merely an example of a computer device and is not limiting of the computer device, and may include more or fewer components than shown, or may combine certain components, or different components, e.g., the computer device may also include a network access device, etc.
The processor 301 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 304 may be an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. The memory 304 may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like. Further, the memory 304 may also include both internal storage units and external storage devices of the computer device. The memory 304 is used for storing the computer program and other programs and data required by the terminal device. The memory 304 may also be used to temporarily store data that has been output or is to be output.
Fifth embodiment (V),
The embodiment of the application also provides a microprocessor, which comprises the computer equipment.
Embodiment six,
The embodiment of the application also provides a computer readable storage medium, wherein at least one instruction, at least one section of program, code set or instruction set is stored in the readable storage medium, so as to be loaded and executed by a processor to realize the trigonometric function calculation method.
Alternatively, the computer-readable storage medium may include: read Only Memory (ROM), random access Memory (RAM, random Access Memory), solid state disk (SSD, solid State Drives), or optical disk, etc. The random access memory may include resistive random access memory (ReRAM, resistance Random Access Memory) and dynamic random access memory (DRAM, dynamic Random Access Memory), among others.
Embodiment seven,
The present application also provides a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to perform the trigonometric function calculation method according to any one of the above embodiments.
The foregoing description of the embodiments of the present application is provided for the purpose of illustration only, and does not represent the advantages or disadvantages of the implementation.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program for instructing relevant hardware, and the program may be stored in a computer readable storage medium, where the storage medium may be a read-only memory, a magnetic disk or an optical disk, etc. It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (10)

1. A method of trigonometric function calculation, the method comprising:
converting the first angle value in the form of floating point number into the second angle value in the form of fixed point quantity;
converting the second angle value into a third angle value of the sine function in the first quadrant;
determining a Taylor series expansion corresponding to the third angle value based on a pre-stored corresponding relation between the interval and the Taylor series expansion order;
and converting the calculated result of the Taylor series expansion of the third angle value into a floating point quantity.
2. The method of claim 1, wherein converting the first angle value in the form of a floating point number to the second angle value in the form of a fixed point quantity comprises:
converting the first angle value in the floating point number form into a second angle value in the 32-bit unsigned shaping quantity form; the 32-bit unsigned shaping amount is a fixed point amount of 1-bit integer plus 31-bit mantissa.
3. The method of claim 1, wherein after converting the first angle value in the form of a floating point number to the second angle value in the form of a fixed point quantity, the method comprises:
calculating a sign bit based on the second angle value;
correspondingly, the converting the calculation result of the taylor series expansion of the third angle value into a floating point number includes:
adding the sign bit to the calculated result of the Taylor series expansion of the third angle value;
and converting the calculation result after adding the sign bit into a floating point quantity.
4. A method according to claim 3, wherein said calculating sign bits based on said second angle value comprises:
when a sine function is calculated, multiplying the second angle value by 1/pi and rounding;
if the odd number is obtained by rounding, the sign bit is negative; if the rounding results in an even number, the sign bit is positive.
5. The method of claim 1, further comprising constructing the interval to taylor series expansion order correspondence:
dividing the [0, pi/2 ] interval into three subintervals of [0, P1], (P1, P2], (P2, pi/2 ], wherein P1 is smaller than pi/4, and P2 is larger than pi/4;
each subinterval corresponds to a taylor series expansion order.
6. The method of claim 5, wherein said constructing the correspondence of the interval and the taylor series expansion order comprises:
the [0, P1] subinterval corresponds to the Taylor series expansion 7 th order, the (P1, P2) subinterval corresponds to the Taylor series expansion 5 th order, and the (P2, pi/2) subinterval corresponds to the Taylor series expansion 8 th order.
7. A trigonometric function calculation device, the device comprising:
the first conversion module is used for converting a first angle value in the form of a floating point number into a second angle value in the form of a fixed point quantity;
the second conversion module is used for converting the second angle value into a third angle value of the sine function in the first quadrant;
the computing module is used for determining a Taylor series expansion corresponding to the third angle value based on a corresponding relation between a pre-stored interval and a Taylor series expansion order;
and the third conversion module is used for converting the calculated result of the Taylor series expansion of the third angle value into a floating point quantity.
8. A computer device comprising a processor and a memory having stored therein at least one instruction, at least one program, code set, or instruction set that is loaded and executed by the processor to implement the trigonometric function calculation method as recited in any one of claims 1 to 6.
9. A microprocessor comprising the computer device of claim 8.
10. A computer readable storage medium having stored therein at least one instruction, at least one program, code set, or instruction set that is loaded and executed by a processor to implement the trigonometric function calculation method according to any one of claims 1 to 6.
CN202311078340.1A 2023-08-24 2023-08-24 Trigonometric function calculation method, trigonometric function calculation device, computer equipment and microprocessor Pending CN117111885A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311078340.1A CN117111885A (en) 2023-08-24 2023-08-24 Trigonometric function calculation method, trigonometric function calculation device, computer equipment and microprocessor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311078340.1A CN117111885A (en) 2023-08-24 2023-08-24 Trigonometric function calculation method, trigonometric function calculation device, computer equipment and microprocessor

Publications (1)

Publication Number Publication Date
CN117111885A true CN117111885A (en) 2023-11-24

Family

ID=88812335

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311078340.1A Pending CN117111885A (en) 2023-08-24 2023-08-24 Trigonometric function calculation method, trigonometric function calculation device, computer equipment and microprocessor

Country Status (1)

Country Link
CN (1) CN117111885A (en)

Similar Documents

Publication Publication Date Title
US20210349692A1 (en) Multiplier and multiplication method
CN115934030A (en) Arithmetic logic unit, floating point number multiplication calculation method and equipment
CN111008003B (en) Data processor, method, chip and electronic equipment
CN111796870B (en) Data format conversion device, processor, electronic equipment and model operation method
CN110362293B (en) Multiplier, data processing method, chip and electronic equipment
WO2022052625A1 (en) Fixed-point and floating-point converter, processor, method, and storage medium
EP1094401B1 (en) Data calculating device
CN108055041B (en) Data type conversion circuit unit and device
CN111381808B (en) Multiplier, data processing method, chip and electronic equipment
CN113126954B (en) Method, device and arithmetic logic unit for floating point number multiplication calculation
CN117111885A (en) Trigonometric function calculation method, trigonometric function calculation device, computer equipment and microprocessor
CN115483934A (en) Data conversion method and device for multi-party security calculation
CN115658008A (en) Resource multiplexing type transcendental function operation implementation method
US20220137922A1 (en) Bit-width optimization method for performing floating point to fixed point conversion
CN115034163A (en) Floating point number multiply-add computing device supporting two data format switching
CN209895329U (en) Multiplier and method for generating a digital signal
CN112667197B (en) Parameterized addition and subtraction operation circuit based on POSIT floating point number format
CN115268832A (en) Floating point number rounding method and device and electronic equipment
CN111310909B (en) Floating point number conversion circuit
CN109558109B (en) Data operation device and related product
CN109582279B (en) Data operation device and related product
CN114692077A (en) Matrix calculation device, method, system, circuit, chip and equipment
CN111538474A (en) Division and evolution operation processor and operation processing system of Posit floating point number
KR20020024937A (en) Table Lookup Based Phase Calculator with Normalization of Input Operands for High-Speed Communication
CN111313906A (en) Conversion circuit of floating point number

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination