Exponential function-based table lookup method and device, electronic equipment and storage medium

By creating a target exponential function table and adjusting the independent variables using Taylor expansion coefficients and logarithmic functions, the problems of insufficient calculation speed and accuracy in the existing technology are solved, and efficient and high-precision calculation of exponential functions in any range of values ​​is achieved.

CN116186471BActive Publication Date: 2026-02-13SHANGHAI SMARTLOGIC TECHNOLOGY LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310317485.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-28
Publication Date
2026-02-13
Estimated Expiration
2043-03-28

AI Technical Summary

Technical Problem

Existing technologies require more Taylor expansion terms when calculating exponential functions, especially as |x| increases, leading to slower calculation speed and longer calculation time. This makes it difficult to achieve efficient and high-precision calculations under expansion terms of different series.

Method used

By obtaining the Taylor expansion coefficients and preset value range of the exponential function, a target exponential function table is created. The logarithmic function value of the independent variable is then adjusted to the preset value range to obtain address information. Finally, the target function value is calculated using the Taylor expansion formula.

Benefits of technology

It enables efficient and high-precision exponential function calculation results within any range of values, improving both calculation speed and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116186471B_ABST
    Figure CN116186471B_ABST
Patent Text Reader

Abstract

The application discloses an exponential function-based table lookup method and device, electronic equipment and a storage medium. The method comprises the following steps: obtaining a table lookup calculation request, wherein the table lookup calculation request comprises an exponential function required for table lookup and a preset value interval of the exponential function; in response to the table lookup calculation request, obtaining a target exponential function table established in advance; obtaining address information of the exponential function within the preset value interval from the target exponential function table; and calculating a target function value corresponding to the independent variable of the exponential function by using the address information. According to the application, the address information of the exponential function within the preset value interval is obtained from the target exponential function table, and the target function value corresponding to the independent variable of the exponential function is calculated by using the address information, so that high-precision operation results can be efficiently obtained when the independent variable of the exponential function is in any value range.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field, and particularly relates to a table lookup method based on an exponential function, a table lookup device, an electronic device and a storage medium. BACKGROUND

[0002] As a commonly used basic elementary function in engineering calculation, the exponential function is usually widely used in scientific research and industrial production. It is a nonlinear mathematical operation, and when hardware is calculated, the table lookup method is usually used to realize it. The general method of table lookup is as follows: first, a lookup table is manufactured. For the exponential function, in a certain independent variable interval, the most intuitive method is to use the power series expansion of the exponential function:

[0003]

[0004] According to the coefficients of the first n terms of the expansion, the coefficients are stored in the lookup table; when calculating, according to the value of the independent variable, the address of the corresponding coefficient can be found, and then the function value is calculated. The accuracy and calculation time of the method are related to the Taylor expansion coefficients. For the e x function, when |x|<1, the function can quickly obtain accurate results in the case of fewer expansion terms, but if |x| is expected to increase, the e x function value has the same accuracy, more expansion terms are needed, and since different series of expansion terms correspond to different hardware structures, the more expansion terms, the slower the calculation speed, and the longer the calculation time. SUMMARY

[0005] In order to solve the above technical problems or at least partially solve the above technical problems, the present application provides a table lookup method based on an exponential function, a table lookup device, an electronic device and a storage medium.

[0006] According to one aspect of an embodiment of the present application, a table lookup method based on an exponential function is provided, comprising:

[0007] Obtaining a table lookup calculation request, wherein the table lookup calculation request includes an exponential function required for table lookup and a preset value interval of the exponential function;

[0008] In response to the table lookup calculation request, obtaining a pre-established target exponential function table;

[0009] Obtaining address information of the independent variable of the exponential function in the preset value interval from the target exponential function table;

[0010] Using the address information to calculate the target function value corresponding to the independent variable of the exponential function.

[0011] Further, the pre-established target exponential function table includes:

[0012] obtaining Taylor expansion coefficients of the exponential function in the preset value interval;

[0013] creating a target exponential function table by using the Taylor expansion coefficients and the preset value interval.

[0014] Further, the creating a target exponential function table by using the Taylor expansion coefficients and the preset value interval comprises:

[0015] obtaining a segmentation parameter corresponding to the preset value interval;

[0016] dividing the preset value interval according to the segmentation parameter to obtain a plurality of sub-value intervals, and determining a Taylor expansion coefficient corresponding to each sub-value interval;

[0017] creating a target exponential function table based on the sub-value intervals and the Taylor expansion coefficient corresponding to each sub-value interval.

[0018] Further, before obtaining address information of the argument of the exponential function in the preset value interval from the target exponential function table, the method further comprises:

[0019] determining a logarithmic function value of the argument of the exponential function with base 2;

[0020] adjusting the argument of the exponential function to the preset value interval by using the logarithmic function value.

[0021] Further, the obtaining address information of the argument of the exponential function in the preset value interval from the target exponential function table comprises:

[0022] obtaining a target column corresponding to the argument of the exponential function in the preset value interval from the target exponential function table;

[0023] taking the target column as the address information.

[0024] Further, the calculating a target function value corresponding to the argument of the exponential function by using the address information comprises:

[0025] obtaining a target Taylor expansion coefficient associated with the target column;

[0026] calculating an initial exponential function value corresponding to the argument of the exponential function based on a Taylor expansion formula and the target Taylor expansion coefficient;

[0027] calculating the target function value by using the initial function value and a preset conversion factor.

[0028] According to another aspect of the embodiments of the present application, there is also provided an index function based table lookup device, comprising:

[0029] an obtaining module, configured to obtain a table lookup calculation request, wherein the table lookup calculation request comprises an index function required for table lookup and a preset value range of the index function;

[0030] a responding module, configured to respond to the table lookup calculation request and obtain a target index function table established in advance;

[0031] a querying module, configured to obtain address information of the index function within the preset value range from the target index function table;

[0032] a calculating module, configured to calculate a target function value corresponding to the independent variable of the index function by using the address information.

[0033] According to another aspect of the embodiments of the present application, there is also provided a storage medium comprising a stored program, which performs the above steps when running.

[0034] According to another aspect of the embodiments of the present application, there is also provided an electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus; wherein the memory is configured to store a computer program; and the processor is configured to execute the steps in the above method by running the program stored in the memory.

[0035] The embodiments of the present application also provide a computer program product comprising instructions which, when executed on a computer, cause the computer to perform the steps in the above method.

[0036] The above technical solutions provided by the embodiments of the present application have the following advantages compared with the prior art: the method provided by the embodiments of the present application obtains address information of the index function within a preset value range from a target index function table, and calculates a target function value corresponding to the independent variable of the index function by using the address information, so that high-precision operation results can be efficiently obtained when the independent variable of the index function is in any value range. BRIEF DESCRIPTION OF DRAWINGS

[0037] The accompanying drawings, which are incorporated herein and constitute part of the specification, illustrate embodiments consistent with the present application and, together with the specification, serve to explain the principles of the present application.

[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without any creative effort.

[0039] Figure 1 A flow chart of an index function-based table lookup method provided by an embodiment of the present application;

[0040] Figure 2 A block diagram of an index function-based table lookup device provided by an embodiment of the present application;

[0041] Figure 3 A structural schematic diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0042] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the following will combine the drawings in the embodiments of the present application to clearly and completely describe the technical solutions 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 of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application, and do not constitute an improper limitation on the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative effort fall within the scope of protection of the present application.

[0043] It should be noted that, in this document, relational terms such as “first” and “second”, and the like, are used solely to distinguish one entity or action from another entity or action, without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms “comprises”, “comprising”, or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without more limitations, an element defined by the phrase “comprising a……” does not exclude the existence of additional identical elements in the process, method, article, or apparatus that includes the element.

[0044] The embodiments of the present application provide an index function-based table lookup method, device, electronic device and storage medium. The method provided by the embodiments of the present application can be applied to any required electronic device, for example, a server, a terminal or the like, which is not specifically limited here, and for the convenience of description, is hereinafter referred to as an electronic device.

[0045] According to an aspect of an embodiment of the present application, a method embodiment of a table lookup method based on an exponential function is provided, Figure 1 A flowchart of a table lookup method based on an exponential function provided by an embodiment of the present application is shown in Figure 1 The method comprises the following steps:

[0046] In step S11, a table lookup calculation request is obtained, wherein the table lookup calculation request comprises an exponential function required for table lookup and a preset value interval of the exponential function.

[0047] The method provided by the embodiment of the present application is applied to a processor. The processor can receive a table lookup calculation request issued by a terminal device, and subsequently perform a table lookup operation using the table lookup calculation request. Specifically, when the terminal device currently has a table lookup requirement, a user can pre-set a preset value interval of an exponential function, generate a table lookup calculation request by combining the exponential function and the preset value interval of the exponential function, and then issue the table lookup calculation request to the processor.

[0048] In step S12, a target exponential function table that is pre-established is obtained in response to the table lookup calculation request.

[0049] In the embodiment of the present application, the target exponential function table that is pre-established is obtained by obtaining Taylor expansion coefficients of the exponential function in the preset value interval, and creating the target exponential function table by using the Taylor expansion coefficients and the preset value interval.

[0050] In the embodiment of the present application, the target exponential function table is created by using the Taylor expansion coefficients and the preset value interval, which comprises the following steps: obtaining a segmentation parameter corresponding to the preset value interval; dividing the preset value interval according to the segmentation parameter to obtain a plurality of sub-value intervals, and determining a Taylor expansion coefficient corresponding to each sub-value interval; and creating the target exponential function table based on the sub-value intervals and the Taylor expansion coefficient corresponding to each sub-value interval.

[0051] In the embodiment of the present application, the exponential function e x The exponential function table is made by expanding in the interval [0.5, 1). The size of the exponential function table is set as a x b, wherein a rows correspond to dividing x in the interval [0.5, 1) into a parts uniformly, and b columns correspond to Taylor expansion coefficients. The result of Taylor expansion when x = x i is calculated, and x i The Taylor expansion coefficients k1, k2, k3, … of each order corresponding to x i are stored in the i-th row of the exponential function table, so that the created exponential function table is used as the target exponential function table.

[0052] In step S13, address information of an independent variable of the exponential function in the preset value interval is obtained from the target exponential function table.

[0053] In the embodiment of the present application, before obtaining the address information of the argument of the exponential function in the target exponential function table within the preset value interval, the method further comprises: determining the logarithmic function value of the argument of the exponential function with base 2; and adjusting the argument of the exponential function to the preset value interval by using the logarithmic function value.

[0054] In the embodiment of the present application, the x value in the interval (-∞, ∞) is limited to the interval [0.5, 1). Specifically, according to the IEEE 754 floating point standard, a single-precision floating point number occupies 4 bytes of 32 bits in a computer, and a double-precision floating point number occupies 8 bytes of 64 bits. The binary storage structures of single-precision and double-precision are both a sign bit, an exponent bit and a mantissa bit. The highest bit (31 bits or 63 bits) is the sign bit, the 30th bit to the 23rd bit of single-precision and the 62nd bit to the 52nd bit of double-precision are the exponent part, and the remaining 23 bits (22th bit to 0th bit) and 52 bits (51th bit to 0th bit) are the mantissa bit respectively.

[0055] According to the IEEE 754 floating point standard, any real number Y can be converted into a binary representation as follows: where s is 0 (positive number) or 1 (negative number), i represents the i-th bit of the mantissa from left to right, m i represents the value of the i-th bit of the mantissa (equal to 0 or 1), and in single-precision floating point numbers, M = 23 and X = E-127, and in double-precision floating point numbers, M = 52 and X = E-1023.

[0056] It should be noted that any real number Y = (-1) S × y × 2 X where y ∈ [1, 2). It is thus deduced that log2|Y| = X + log2y, and the down-rounding of log2|Y| is X, which can be directly obtained by subtracting 127 (for single-precision floating point numbers) or 1023 (for double-precision floating point numbers) from the exponent bit E of the binary representation of Y, without additional calculation.

[0057] Specifically, the logarithmic function value of the argument x of the exponential function with base 2 is calculated. As can be seen from the above formula, the down-rounding result of log2|x| can be directly obtained through the exponent bit of the binary representation of |x|, and S = log2|x| is defined, and S' is obtained by down-rounding X. Subsequently, the argument x is adjusted to the interval [0.5, 1): according to the aforementioned mathematical expression, log2|x| = S' + log2y, where y ∈ [1, 2), in order to adjust the interval, let the conversion factor A = 2 -(S'+1) then the range of x' can be limited to the interval [0.5, 1) by x' = |x| × A.

[0058] In this embodiment of the application, obtaining the address information of the independent variable of the exponential function within a preset value range from the target exponential function table includes: obtaining the target column corresponding to the independent variable of the exponential function within the preset value range from the target exponential function table; and using the target column as address information.

[0059] Step S14: Calculate the objective function value corresponding to the independent variable of the exponential function using the address information.

[0060] In this embodiment of the application, the calculation of the target function value corresponding to the independent variable of the exponential function using address information includes: obtaining the target Taylor expansion coefficient associated with the target column; calculating the initial exponential function value corresponding to the independent variable of the exponential function based on the Taylor expansion formula and the target Taylor expansion coefficient; and calculating the target function value using the initial function value and a preset conversion factor.

[0061] By calculating the address of x' in the function table in the first step, we can obtain its corresponding Taylor expansion coefficients. Then, according to the Taylor expansion formula, we can obtain the exponential function value e corresponding to x'. x '.

[0062] According to the known e x' And x' = |x| × A, we can obtain Therefore e |x| The value is obtained through one e x' By multiplying them together, we can obtain the final exponential function e. x The value is:

[0063]

[0064] The method provided in this application obtains the address information of the independent variable of the exponential function within a preset value range from the target exponential function table, and uses the address information to calculate the target function value corresponding to the independent variable of the exponential function. In this way, it can efficiently obtain high-precision calculation results when the independent variable of the exponential function is in any value range.

[0065] Figure 2 This is a block diagram of a table lookup device based on an exponential function, provided as an embodiment of this application. This device can be implemented as part or all of an electronic device through software, hardware, or a combination of both. Figure 2 As shown, the device includes:

[0066] The acquisition module 21 is used to acquire a table lookup calculation request, wherein the table lookup calculation request includes: the exponential function required for the table lookup and the preset value range of the exponential function;

[0067] Response module 22 is used to respond to table lookup calculation requests and obtain a pre-established target exponential function table;

[0068] The query module 23 is configured to obtain address information of the argument of the exponential function in the preset value interval from the target exponential function table.

[0069] The calculation module 24 is configured to calculate the target function value corresponding to the argument of the exponential function by using the address information.

[0070] In the embodiment of the present application, the obtaining module 21 is configured to obtain Taylor expansion coefficients of the exponential function in the preset value interval; and the target exponential function table is created by using the Taylor expansion coefficients and the preset value interval.

[0071] In the embodiment of the present application, the obtaining module 21 is configured to obtain a segmentation parameter corresponding to the preset value interval; the preset value interval is divided into a plurality of sub-value intervals according to the segmentation parameter, and the Taylor expansion coefficient corresponding to each sub-value interval is determined; and the target exponential function table is created based on the sub-value intervals and the Taylor expansion coefficients corresponding to each sub-value interval.

[0072] In the embodiment of the present application, the table lookup device based on the exponential function further comprises an adjustment module configured to determine a logarithmic function value of the argument of the exponential function with 2 as the base number; and the argument of the exponential function is adjusted to the preset value interval by using the logarithmic function value.

[0073] In the embodiment of the present application, the query module 23 is configured to obtain a target column corresponding to the argument of the exponential function in the preset value interval from the target exponential function table; and the target column is used as the address information.

[0074] In the embodiment of the present application, the calculation module 24 is configured to obtain a target Taylor expansion coefficient associated with the target column; an initial exponential function value corresponding to the argument of the exponential function is calculated based on a Taylor expansion formula and the target Taylor expansion coefficient; and the target function value is calculated by using the initial function value and a preset conversion factor.

[0075] The embodiment of the present application further provides an electronic device, as shown in the figure. Figure 3 The electronic device can include a processor 1501, a communication interface 1502, a memory 1503 and a communication bus 1504, wherein the processor 1501, the communication interface 1502 and the memory 1503 complete mutual communication through the communication bus 1504.

[0076] The memory 1503 is configured to store a computer program.

[0077] The processor 1501 is configured to execute the computer program stored in the memory 1503, so as to realize the steps of the above-mentioned embodiments.

[0078] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For the convenience of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or only one type of bus.

[0079] The communication interface is used for communication between the terminal and other devices.

[0080] The memory can include a Random Access Memory (RAM) and can also include a non-volatile memory, for example, at least one disk memory. Optionally, the memory can also be at least one storage device located away from the processor.

[0081] The processor mentioned above can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; can also be a Digital Signal Processing (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component.

[0082] In another embodiment provided in the present application, a computer readable storage medium is also provided, and the computer readable storage medium stores instructions, when the instructions run on a computer, the computer executes the index function-based table lookup method in any of the above embodiments.

[0083] In another embodiment provided in the present application, a computer program product containing instructions is also provided, when the instructions run on a computer, the computer executes the index function-based table lookup method in any of the above embodiments.

[0084] In the embodiments described above, all or some of the steps can be implemented by software, hardware, firmware or any combination thereof. When implemented in software, all or some of the steps can be stored in or performed in relation to one or more computer program products and can be implemented as one or more computer programs. The computer program product can be a computer program storage medium readable by the computer and encoding a computer program of instructions for executing the procedures according to the methods. The computer program product can be implemented as one or more computer programs including one or more software modules, which are stored in the storage device and executed by the computer. The computer program product can be a non-transitory computer program storage medium having stored thereon the computer program of instructions. The computer program product can be a computer data loadable into working memories including the RAM, the ROM and the like or the computer program product can be a removable non-transitory computer readable storage medium such as a flash drive like USB, SD or SDIO memory card, an optical disk like CD and DVD, magnetic recording disk including floppy disks and hard disks, optical recording disk, solid state disk and the like.

[0085] The specific embodiments described herein are illustrative and not intended to be limiting. Other embodiments will readily occur to those skilled in the art. Modifications may be made to such embodiments without departing from the spirit and scope of the application. Accordingly, it will be appreciated that the present application will be limited only by the claims and equivalents thereof.

[0086] The foregoing is merely illustrative of the principles of this application and various modifications can be made by those skilled in the art without departing from the scope and spirit of the application. The disclosure should be understood to include all such modifications.

Claims

1. An exponential function based table lookup method, characterized by, The method comprises the following steps: obtaining a table lookup calculation request, wherein the table lookup calculation request comprises an exponential function required for table lookup and a preset value interval of the exponential function; obtaining a target exponential function table established in advance in response to the table lookup calculation request; obtaining address information of the exponential function within the preset value interval from the target exponential function table; calculating a target function value corresponding to the exponential function variable by using the address information; before obtaining the address information of the exponential function within the preset value interval from the target exponential function table, the method further comprises the following steps: determining the exponential function variable as a logarithmic function value with a base of 2, and adjusting the exponential function variable to the preset value interval by using the logarithmic function value; wherein the step of determining the exponential function variable as a logarithmic function value with a base of 2 and adjusting the exponential function variable to the preset value interval by using the logarithmic function value comprises the following steps: obtaining an integer part of the logarithmic function value by subtracting a single-precision floating-point number or a double-precision floating-point number from an exponential bit of a binary representation of the variable; calculating a conversion factor based on the integer part, and limiting the variable to the preset value interval based on the conversion factor.

2. The method of claim 1, wherein, The step of obtaining the target exponential function table established in advance comprises the following steps: obtaining Taylor expansion coefficients of the exponential function within the preset value interval; creating a target exponential function table by using the Taylor expansion coefficients and the preset value interval.

3. The method of claim 2, wherein, The step of creating a target exponential function table by using the Taylor expansion coefficients and the preset value interval comprises the following steps: obtaining a segmentation parameter corresponding to the preset value interval; dividing the preset value interval according to the segmentation parameter to obtain a plurality of sub-value intervals, and determining a Taylor expansion coefficient corresponding to each sub-value interval; generating a target exponential function table by taking the sub-value intervals as rows and taking the Taylor expansion coefficients corresponding to each sub-value interval as columns.

4. The method of claim 1, wherein, The step of obtaining address information of the exponential function within the preset value interval from the target exponential function table comprises the following steps: obtaining a target column corresponding to the exponential function variable within the preset value interval from the target exponential function table; taking the target column as the address information.

5. The method of claim 4, wherein, The step of calculating a target function value corresponding to the exponential function variable by using the address information comprises the following steps: obtaining a target Taylor expansion coefficient associated with the target column; calculating an initial exponential function value corresponding to the exponential function variable based on a Taylor expansion formula and the target Taylor expansion coefficient; calculating the target function value by using the initial exponential function value and a preset conversion factor.

6. An exponential function-based table lookup apparatus characterized by comprising: The method comprises the following steps: an obtaining module is configured to obtain a table lookup calculation request, wherein the table lookup calculation request comprises an exponential function required for table lookup and a preset value interval of the exponential function; a response module is configured to obtain a target exponential function table established in advance in response to the table lookup calculation request; a query module is configured to obtain address information of the exponential function within the preset value interval from the target exponential function table; The computing module is configured to calculate a target function value corresponding to the argument of the exponential function by using the address information. The device further comprises an adjusting module configured to determine a logarithmic function value of the argument of the exponential function, and adjust the argument of the exponential function to the preset value interval by using the logarithmic function value. The adjusting module is configured to obtain an integer part of the logarithmic function value by subtracting a single-precision floating-point number or a double-precision floating-point number from an exponential bit of a binary representation of the argument; calculate a conversion factor based on the integer part, and limit the argument in the preset value interval based on the conversion factor.

7. A storage medium, characterized by The storage medium comprises a stored program, wherein the program performs the method of any one of claims 1-5 when running.

8. An electronic device, comprising: The device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus; wherein: The memory is configured to store a computer program. The processor is configured to perform the method of any one of claims 1-5 by running the program stored in the memory.

Citation Information

Patent Citations

  • Data processing method, device and system

    CN113407788A