# Patent application title: APPARATUS FOR EVALUATING A MATHEMATICAL FUNCTION

##
Inventors:
Simon Fenney (St. Albans, GB)

IPC8 Class: AG06F1035FI

USPC Class:
708203

Class name: Electrical digital calculating computer particular function performed compression/decompression

Publication date: 2012-05-03

Patent application number: 20120110048

Sign up to receive free email alerts when patent applications with chosen keywords are published SIGN UP

## Abstract:

An apparatus for evaluating a mathematical function at an input value is
provided. The apparatus includes a device for selecting a mathematical
function, a device for inputting a value at which to evaluate the
function, a device for identifying an interval containing the input
value, the interval being described by at least one polynomial function,
a device for retrieving at least one control point representing the
polynomial function from at least one look up table, a device for
deriving the polynomial function from the control points, a device for
evaluating the function for the input value and a device for providing
data representing the evaluated function at an output.## Claims:

**1.**A method for evaluating a mathematical function at an input value comprising the steps of; selecting a mathematical function; inputting a value at which to evaluate the function; identifying an interval containing the input value, the interval being described by at least one polynomial function; retrieving at least one control point representing the polynomial function from at least one look up table, deriving the polynomial function from the control points, evaluating the function for the input value, and providing data representing the evaluated function at an output.

**2.**A method for evaluating a mathematical function at an input value according to claim 1 comprising the further step of interpolating the polynomial function, wherein the step of evaluating the function for an input value is performed using the interpolation.

**3.**A method for evaluating a mathematical function at an input value according to claim 1 wherein the control points are B-spline control points.

**4.**A method for evaluating a mathematical function at an input value according to claim 2 wherein the control points are B-spline control points.

**5.**A method for evaluating a mathematical function at an input value according to claim 3 comprising the further steps of deriving B-Spline representation from the B-spline control points and mapping the B-spline representation to a Bezier representation in order to allow the use of the de Casteljau evaluation method.

**6.**A method for evaluating a mathematical function at an input value according to claim 4 comprising the further steps of deriving B-Spline representation from the B-spline control points and mapping the B-spline representation to a Bezier representation in order to allow the use of the de Casteljau evaluation method.

**7.**A method for evaluating a mathematical function at an input value according to claim 1 comprising the further step of removing a linear term from the function before evaluating the function and re-applying the linear function after the evaluation.

**8.**A method for evaluating a mathematical function at an input value according to claim 2 comprising the further step of removing a linear term from the function before evaluating the function and re-applying the linear function after the evaluation.

**9.**A method for evaluating a mathematical function at an input value according to claim 3 comprising the further step of removing a linear term from the function before evaluating the function and re-applying the linear function after the evaluation.

**10.**A method for evaluating a mathematical function at an input value according to claim 4 comprising the further step of removing a linear term from the function before evaluating the function and re-applying the linear function after the evaluation.

**11.**A method for evaluating a mathematical function at an input value according to claim 5 comprising the further step of removing a linear term from the function before evaluating the function and re-applying the linear function after the evaluation.

**12.**A method for evaluating a mathematical function at an input value according to claim 6 comprising the further step of removing a linear term from the function before evaluating the function and re-applying the linear function after the evaluation.

**13.**A method for evaluating a mathematical function at an input value according to claim 1 wherein the positions in the lookup tables from which control points are retrieved are defined by lookup index values, comprising the further steps of manipulating the lookup index values such that, when one control point is retrieved from each of a plurality of lookup tables, the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**14.**A method for evaluating a mathematical function at an input value according to claim 2 wherein the positions in the lookup tables from which control points are retrieved are defined by lookup index values, comprising the further steps of manipulating the lookup index values such that, when one control point is retrieved from each of a plurality of lookup tables, the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**15.**A method for evaluating a mathematical function at an input value according to claim 3 wherein the positions in the lookup tables from which control points are retrieved are defined by lookup index values, comprising the further steps of manipulating the lookup index values such that, when one control point is retrieved from each of a plurality of lookup tables, the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**16.**A method for evaluating a mathematical function at an input value according to claim 4 wherein the positions in the lookup tables from which control points are retrieved are defined by lookup index values, comprising the further steps of manipulating the lookup index values such that, when one control point is retrieved from each of a plurality of lookup tables, the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**17.**A method for evaluating a mathematical function at an input value according to claim 5 wherein the positions in the lookup tables from which control points are retrieved are defined by lookup index values, comprising the further steps of manipulating the lookup index values such that, when one control point is retrieved from each of a plurality of lookup tables, the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**18.**A method for evaluating a mathematical function at an input value according to claim 6 wherein the positions in the lookup tables from which control points are retrieved are defined by lookup index values, comprising the further steps of manipulating the lookup index values such that, when one control point is retrieved from each of a plurality of lookup tables, the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**19.**A method for evaluating a mathematical function at an input value according to claim 7 wherein the positions in the lookup tables from which control points are retrieved are defined by lookup index values, comprising the further steps of manipulating the lookup index values such that, when one control point is retrieved from each of a plurality of lookup tables, the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**20.**A method for evaluating a mathematical function at an input value according to claim 8 wherein the positions in the lookup tables from which control points are retrieved are defined by lookup index values, comprising the further steps of manipulating the lookup index values such that, when one control point is retrieved from each of a plurality of lookup tables, the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**21.**A method for evaluating a mathematical function at an input value according to claim 9 wherein the positions in the lookup tables from which control points are retrieved are defined by lookup index values, comprising the further steps of manipulating the lookup index values such that, when one control point is retrieved from each of a plurality of lookup tables, the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**22.**A method for evaluating a mathematical function at an input value according to claim 10 wherein the positions in the lookup tables from which control points are retrieved are defined by lookup index values, comprising the further steps of manipulating the lookup index values such that, when one control point is retrieved from each of a plurality of lookup tables, the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**23.**A method for evaluating a mathematical function at an input value according to claim 11 wherein the positions in the lookup tables from which control points are retrieved are defined by lookup index values, comprising the further steps of manipulating the lookup index values such that, when one control point is retrieved from each of a plurality of lookup tables, the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**24.**A method for evaluating a mathematical function at an input value according to claim 12 wherein the positions in the lookup tables from which control points are retrieved are defined by lookup index values, comprising the further steps of manipulating the lookup index values such that, when one control point is retrieved from each of a plurality of lookup tables, the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**25.**An apparatus for evaluating a mathematical function at an input value comprising; means for selecting a mathematical function; means for inputting a value at which to evaluate the function; means for identifying an interval containing the input value, the interval being described by at least one polynomial function; means for retrieving at least one control point representing the polynomial function from at least one look up table, means for deriving the polynomial function from the control points, means for interpolating the polynomial function; means for evaluating the function for the input value using the interpolation, and means for providing data representing the evaluated function at an output.

**26.**An apparatus for evaluating a mathematical function at an input value according to claim 25 comprising means for interpolating the polynomial function wherein the means for evaluating the function for the input value uses the interpolation.

**27.**An apparatus for evaluating a mathematical function at an input value according to claim 25 wherein the control points are B-spline control points.

**28.**An apparatus for evaluating a mathematical function at an input value according to claim 26 wherein the control points are B-spline control points.

**29.**An apparatus for evaluating a mathematical function at an input value according to claim 27 comprising means for deriving B-Spline representation from the B-spline control points and means for mapping the B-spline representation to a Bezier representation in order to allow the use of the de Casteljau evaluation method.

**30.**An apparatus for evaluating a mathematical function at an input value according to claim 28 comprising means for deriving B-Spline representation from the B-spline control points and means for mapping the B-spline representation to a Bezier representation in order to allow the use of the de Casteljau evaluation method.

**31.**An apparatus for evaluating a mathematical function at an input value according to claim 25 comprising means for removing a linear term from the function before evaluating the function and re-applying the linear function after the evaluation.

**32.**An apparatus for evaluating a mathematical function at an input value according to claim 26 comprising means for removing a linear term from the function before evaluating the function and re-applying the linear function after the evaluation.

**33.**An apparatus for evaluating a mathematical function at an input value according to claim 27 comprising means for removing a linear term from the function before evaluating the function and re-applying the linear function after the evaluation.

**34.**An apparatus for evaluating a mathematical function at an input value according to claim 28 comprising means for removing a linear term from the function before evaluating the function and re-applying the linear function after the evaluation.

**35.**An apparatus for evaluating a mathematical function at an input value according to claim 29 comprising means for removing a linear term from the function before evaluating the function and re-applying the linear function after the evaluation.

**36.**An apparatus for evaluating a mathematical function at an input value according to claim 30 comprising means for removing a linear term from the function before evaluating the function and re-applying the linear function after the evaluation.

**37.**An apparatus for evaluating a mathematical function at an input value according to claim 25 wherein the positions in the lookup tables from which the control points are read are defined by lookup index values, comprising means for manipulating the lookup index values such that when one control point is retrieved from each of a plurality of lookup tables the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and means for rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**38.**An apparatus for evaluating a mathematical function at an input value according to claim 26 wherein the positions in the lookup tables from which the control points are read are defined by lookup index values, comprising means for manipulating the lookup index values such that when one control point is retrieved from each of a plurality of lookup tables the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and means for rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**39.**An apparatus for evaluating a mathematical function at an input value according to claim 27 wherein the positions in the lookup tables from which the control points are read are defined by lookup index values, comprising means for manipulating the lookup index values such that when one control point is retrieved from each of a plurality of lookup tables the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and means for rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**40.**An apparatus for evaluating a mathematical function at an input value according to claim 28 wherein the positions in the lookup tables from which the control points are read are defined by lookup index values, comprising means for manipulating the lookup index values such that when one control point is retrieved from each of a plurality of lookup tables the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and means for rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**41.**An apparatus for evaluating a mathematical function at an input value according to claim 29 wherein the positions in the lookup tables from which the control points are read are defined by lookup index values, comprising means for manipulating the lookup index values such that when one control point is retrieved from each of a plurality of lookup tables the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and means for rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**42.**An apparatus for evaluating a mathematical function at an input value according to claim 30 wherein the positions in the lookup tables from which the control points are read are defined by lookup index values, comprising means for manipulating the lookup index values such that when one control point is retrieved from each of a plurality of lookup tables the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and means for rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**43.**An apparatus for evaluating a mathematical function at an input value according to claim 31 wherein the positions in the lookup tables from which the control points are read are defined by lookup index values, comprising means for manipulating the lookup index values such that when one control point is retrieved from each of a plurality of lookup tables the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and means for rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**44.**An apparatus for evaluating a mathematical function at an input value according to claim 32 wherein the positions in the lookup tables from which the control points are read are defined by lookup index values, comprising means for manipulating the lookup index values such that when one control point is retrieved from each of a plurality of lookup tables the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and means for rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**45.**An apparatus for evaluating a mathematical function at an input value according to claim 33 wherein the positions in the lookup tables from which the control points are read are defined by lookup index values, comprising means for manipulating the lookup index values such that when one control point is retrieved from each of a plurality of lookup tables the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and means for rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**46.**An apparatus for evaluating a mathematical function at an input value according to claim 34 wherein the positions in the lookup tables from which the control points are read are defined by lookup index values, comprising means for manipulating the lookup index values such that when one control point is retrieved from each of a plurality of lookup tables the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and means for rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**47.**An apparatus for evaluating a mathematical function at an input value according to claim 35 wherein the positions in the lookup tables from which the control points are read are defined by lookup index values, comprising means for manipulating the lookup index values such that when one control point is retrieved from each of a plurality of lookup tables the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and means for rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

**48.**An apparatus for evaluating a mathematical function at an input value according to claim 36 wherein the positions in the lookup tables from which the control points are read are defined by lookup index values, comprising means for manipulating the lookup index values such that when one control point is retrieved from each of a plurality of lookup tables the control points retrieved are sufficient to evaluate the function at the position specified by the index value, and means for rotating the retrieved control points so as to present the control points to an evaluation unit in the required order.

## Description:

**CROSS**-REFERENCE TO RELATED APPLICATIONS

**[0001]**This is a divisional of prior U.S. application Ser. No. 11/140,258, filed May 27, 2005.

**BACKGROUND OF THE INVENTION**

**[0002]**In floating point units of some CPUs or, more particularly, contemporary graphics chips, it is necessary to compute mathematical functions of certain floating point numbers. These are typically continuous and may include functions such as `reciprocal`, i.e. f(x)=1/x, `reciprocal square root`, f(x)=1/ {square root over (x)}, `logarithm base 2`, f(x)=ln x/ln 2, power base 2, f(x)=2

^{x}, sine and cosine. For example, such mathematical functions form part of the instruction set of the Microsoft Direct X graphics specification, and some have appeared, in various forms, as instructions in various CPUs.

**[0003]**With many of these functions, there is a repeating pattern of behaviour that can be exploited to simplify the implementation--cosine and sine are obvious examples, but, this behaviour can also be seen with reciprocal which `repeats` for each for every interval of the form [2.sup.n,2.sup.n+1) and for `reciprocal square root` which repeats on intervals of the form [2.sup.n,2.sup.n+2). Such regions can usually be extracted through simple integer manipulation of the input floating point exponent, and so the difficult part of the evaluation reduces to evaluating a function on a much-reduced range of numbers. Without loss of generality, it can be assumed that the input value to such a reduced function can be mapped to a (typically fixed point) value, x' in the range [0,1]. The output is also assumed to be of the same form.

**[0004]**There are several methods of computing such reduced functions known in the art. The simplest system is that of a direct table look-up. For a given input precision (N bits) and a particular output precision (M bits) the table would contain 2

^{N}entries each of M-bits. The input value is mapped to the nearest entry in the table and the result is obtained. However, for anything except small tables, this is an expensive and generally inaccurate option.

**[0005]**One approach that can be used to alleviate the expense is to compress the data in the table--such a scheme was used for reciprocal calculations in U.S. Pat. No. 6,330,000. This scheme, however, is difficult to apply generally and, furthermore, does not offer large levels of compression.

**[0006]**An alternative approach is to use a small look-up table, which only gives moderately precise results, and then apply Newton-Raphson iteration to improve the numerical accuracy. With such a scheme, the precision, in terms of numbers of bits, typically doubles with each such iteration. Turkowski describes such a method in `Graphics Gems V` [ISBN 0-12-543455-3] for computing the reciprocal square root. A look-up table with, say, 2

^{6}entries, produces an initial guess, R

_{0}, which is then improved by use of two Newton-Raphson iteration steps that evaluate:

**R**

_{i}+1=(3-R

_{i}*R

_{i}*x)*x/2

**[0007]**Similarly, the Texas Instrument's `TMS320C3x User's Guide` gives examples for the computation of `reciprocal` and `reciprocal square root`. It, in fact, effectively dispenses with the look-up table and starts with a very approximate initial guess and simply relies on the iteration to improve the accuracy.

**[0008]**One problem with methods that use iterative improvements such as Newton-Raphson is that they require the additional mathematical operations (either floating point or integer) in order to converge to the result. This may not be an issue when the iterations steps are performed in a CPU with multipliers or adders that may otherwise be idle, but including the extra circuits in a dedicated hardware unit may be expensive.

**[0009]**Another alternative is to use a power series to evaluate the function, say, using three or four terms. In this approach, weighted versions of the k derivatives are stored as constants and the function is evaluated as . . .

**f**(x+x')=C

_{0}+C

_{1}x'+C

_{2}x'

^{2}+ . . . +C

_{kx}'

^{k}Eqn. 1

**or**, equivalently, with fewer multiplies, as . . .

**f**(x+x')=C

_{0}+(C

_{1}+(C

_{2}+ . . . )x')x' Eqn. 1 a

**[0010]**Obvious candidates for such an implementation include Sine and Cosine, and, in fact, the Microsoft DirectX 9 specification does give an example using such.

**[0011]**One problem with only having a single function is that it may be difficult to maintain accuracy through the entire domain of the function without having a very large number of terms. A simple remedy is to again use a table approach and use a piecewise approximation to the function. This method is well known in the art and several improvements have been suggested: e.g by Detrey and de Dinechin in "Table-based polynomials for fast hardware function evaluation" or Walters and Schulte in "Efficient Function Approximation Using Truncated Multipliers and Squarers". In this method the domain of the function is broken into 2

^{N}sections with a table entry for each section. Each entry, i, would store the necessary power series constants, i.e., C

_{0}

^{i}, C

_{0}

^{i}. . . C

_{k}

^{i}which describe the curve in that section. In practice, the approximating function would generally be linear, quadratic, or cubic. A simple example of such a quadratic scheme, with N=3, i.e. only 8 sections, is shown graphed in FIG. 1 (A). A possible look-up table for this case is shown below:

**TABLE**-US-00001 Table Entry C

_{0}C

_{1}C

_{2}0 1.0000 -0.1242 0.0131 1 0.8889 -0.0982 0.0094 2 0.8000 -0.0797 0.0069 3 0.7273 -0.0659 0.0053 4 0.6667 -0.0554 0.0041 5 0.6154 -0.0472 0.0033 6 0.5714 -0.0407 0.0026 7 0.5333 -0.0355 0.0022 Note: In a hardware implementation, if so desired, the C

_{0}

^{i}values could all be adjusted by 0.5 to reduce the cost of evaluation since this `bit` is constant.

**[0012]**A plot of the relative error for these values is shown in FIG. 1 (B).

**[0013]**Given the input function value, x', x'ε[0,1), the required table entry is identified by calculating .left brkt-bot.x'*2

^{N}.right brkt-bot.. In hardware or software terms, this is simply a matter of taking the top N bits of a fixed-point representation of x'. An interpolating parameter, αε[0,1), is computed as α=x'*2

^{N}-.left brkt-bot.x'*2

^{N}.right brkt-bot.. This is just a matter of extracting the remaining, least significant bits of the x'value. The function is then computed as:

**f**(x')=C

_{0}+C

_{1}α+C

_{2}α

^{2}

**(or via the alternative factorisation presented above). This example would not be terribly accurate but can be improved through some combination of the following:**

**[0014]**1. Increasing the number of table entries, i.e. increasing N.

**[0015]**2. Using a higher order polynomial.

**[0016]**3. Increasing the precision of the stored values.

**[0017]**The actual size of the multipliers and adders used in the above evaluation is also important and also represents a trade-off of implementation cost and accuracy.

**[0018]**Another advantage of this scheme is that, in a hardware solution, several different functions could share the same polynomial evaluation hardware, i.e., f(x)=C

_{0}+C

_{1}α+C

_{2}α

^{2}+ . . . can be reused. Each particular function would, of course, still need its own look-up table and set-up and finalise units.

**[0019]**Although N, here, is very much smaller than that needed for the simple look-up table described earlier, it still requires a total of k2

^{N}data values. One other concern is that, because the sections are piecewise, care must be taken with the precision so that entire function is continuous, i.e., that the computed end point of one section evaluates to the matching start of the next section. It is also desirable that there not be too great a discontinuity in the derivatives across the segments.

**[0020]**In computer graphics, smooth surfaces and curves are frequently modelled using parametric splines or cubic Catmull-Rom. A good introduction to these systems can be found in `Advanced Animation and Rendering Techniques` by Watt and Watt [ISBN0-201-54412-1]. Spline systems use `control points` to control the local path of a curve or surface, which is a piecewise polynomial of some order, typically cubic. Although some splines are interpolating, i.e., the curve actually passes through the control points, in two of the more popular representation systems, Bezier and (uniform) B-Spline curves, the curve is approximating, meaning that the curve does not generally pass through the control points although it does tend to follow the positions of the control points.

**[0021]**In FIG. 2, a sequence of control points, (one of which is indicated by `1`) has been shown (connected by lines) which, in turn, defines the path of a uniform B-Spline curve, `2`. One particularly nice property of uniform B-Splines is that it is trivial to obtain continuity in both the curve and its derivatives across the piecewise sections. Evaluation, on the other hand, of the splines may be better performed using the de Casteljau algorithm on the Bezier equivalents. (See `Advanced Animation and Rendering Techniques`). Although, in graphics, splines are generally for 2D or 3D curves, the range can be reduced to a single dimension.

**SUMMARY OF THE INVENTION**

**[0022]**We have appreciated that storing polynomial functions in terms of their polynomial coefficients in look up tables requires a large amount of memory, particularly for high order polynomials. It would be beneficial if the same polynomial curves could be represented by fewer stored data in order to reduce the required memory.

**[0023]**Preferred embodiments of the invention reduce the number of data points stored to describe a polynomial curve by storing control points to define the curve and then manipulating the control points using arithmetic blocks to generate the polynomial coefficients. Embodiments of the invention provide the advantage that a single control point can be stored from which the polynomial coefficients can be generated rather than storing the multiple coefficients which define the polynomial. Thus, computational devices, graphics chips or any dedicated hardware which is required to use polynomial functions would benefit from the present invention since the reduction in memory capacity would reduce the cost of the device.

**[0024]**In broad terms, the invention relates to a method and apparatus for evaluating mathematical functions using a look-up table wherein the values stored in the table represent curve control points

**[0025]**Preferred embodiments of the invention reduce the amount of data that needs to be stored in the look-up table in order to represent the polynomial curve by a significant factor and thus reduce the size of the memory required. It also preserves the continuity (including derivatives) across the boundaries between the piecewise sections.

**[0026]**Preferred embodiments use a B-Spline piecewise curve, of quadratic or perhaps cubic order, to represent the function and the look-up table can be reduced in size by a factor of up to three (quadratic) or four (cubic). It achieves this by eliminating the need to store constant factors relating to the 2

^{nd}, 3

^{rd}and higher derivatives (i.e., C

_{1}

^{i}. . . C

_{k}

^{i}). Instead, only a single value, a (uniform) B-Spline control point, is stored `per section` of the look-up table and this, along with the neighbouring control point values, is sufficient to define the piecewise curve in that particular section. The system does require K additional values, where K is the order of the approximation (i.e. quadratic implies K=2), in order to process the extremities of the curve, and so the invention requires a total of 2

^{N}+K values to be stored--a significant reduction from K2

^{N}.

**[0027]**It should be noted that, unlike the prior art solutions where the constant terms, C

_{0}

^{i}, generally lie on the curve, the stored values in the invention generally do not.

**[0028]**Because several neighbouring control point values (i.e. three for quadratic representations, and four for cubic) must be accessed in parallel to evaluate a curve segment, some means of efficiently obtaining this data is required. This is achieved in the invention by replacing the single `2

^{N}+K entry` look-up table with several smaller look-up tables. For the case of quadratic approximations, this consists of two, `2

^{N}-2 entry` and two `2

^{N}-2+1 entry` tables, wherein each table thus stores every fourth value. For cubic approximations, 3 tables would have 2

^{N}-2+1 entries.

**[0029]**Preferred embodiments of the invention will now be described in detail by way of example with reference to the accompanying diagrams in which:

**[0030]**FIGS. 1(A) and 1(B) show graphs of a function represented/approximated by eight piecewise sections.

**[0031]**FIG. 2 shows a simple uniform B-Spline with an associated set of control points.

**[0032]**FIG. 3 shows an overview of a preferred embodiment of the invention for evaluating the functions using a piecewise quadratic (or optional cubic) approximation.

**[0033]**FIG. 4 shows the B-Spline evaluation unit.

**PREFERRED EMBODIMENT**

**[0034]**Preferred embodiments of the invention can be implemented on general purpose computers, dedicated hardware or calculators.

**[0035]**In a preferred embodiment, several basic functions are supported including reciprocal, reciprocal square root, logarithm base 2, and power base 2. Others skilled in the art will see that it is trivial to extend this set. An overview of the system will now be described with reference to FIG. 3.

**[0036]**Preferably, a floating-point value is input, `20`, along with an identification of the required function to evaluate, `21`. The value is then manipulated, `22`, to extract the interval over which the function is self-similar, and this provides an initial value x', `25`, to define the position of the floating point within the self-similar interval and an encoding identifying the interval, `26`. This usually involves only simple bit manipulation of the floating point value and/or integer arithmetic on the floating point exponent. Descriptions of this type of process for `reciprocal` and `reciprocal square root` have been described in the aforementioned articles. In particular, for `reciprocal`, (for the purposes of brevity, ignoring special cases such as zero and exact powers of 2) the 8-bit exponent and the sign bit from the floating point number would identify the interval, and the more significant mantissa bits (ignoring the assumed leading `1`) would form the x' value. The requirements for other functions should be apparent to one skilled in the art.

**[0037]**The x' value is then split, `26`, into two components--an `index` which defines how many sections the self-similar interval is broken up into and the relevant section for the x' value, the index is used to reference into the look-up tables, and an `alpha` value in the range [0, 1) which represents the position of the x' value within the section and is used to evaluate the quadratic (or cubic) function. As described in the prior art, this is a trivial operation. Up to this point, the invention has not differed from typical prior art solutions.

**[0038]**The index value is now adjusted in four ways, `40a`, `40b`, `40c` and `40d`, each according to which of the four look-up tables will be accessed. The calculations performed are as follows:

**IndexOut**=floor((IndexIn+3)/4); 40a

**IndexOut**=floor((IndexIn+2)/4) 40b

**IndexOut**=floor((IndexIn+1)/4) 40c

**IndexOut**=floor((IndexIn)/4) 40d

**[0039]**It should be clear, to one skilled in the art, that `divide by 4` and `floor` operations are merely trivial bit selection operations. The IndexOut values represent the locations in the lookup tables of the control points for the curve.

**[0040]**In the preferred embodiment, several different mathematical functions are implemented and so each of `Table(s) 0`, `41a`, `Table(s) 1`, `41b`, `Table(s) 2`, `41c`, and `Table(s) 4`, `41d`, actually store several, possibly combined, look-up tables. The particular table in each set is selected by the function select value, `21`. The indices generated by `40a`, `40b`, `40c` and `40d`, are also supplied to their respective tables, and the referenced values are output to the `rotate` unit, `42`.

**[0041]**In the quadratic embodiment, Table(s)0 and Table(s)1 have 2

^{N}-2+1 entries per function and the other pair, 2

^{N}-2. (In a cubic embodiment, Table(s)2 would also have an extra entry per function). In the preferred embodiment, N would be 6, giving 64 sections in the function, but this value can be varied in alternative embodiments.

**[0042]**The control point values are then manipulated by the `rotate` unit to generate the coefficients describing the polynomial which describes the function in the section. The `rotate` unit takes the least significant pair of bits from the index and `rotates` the supplied values from the tables as follows:

**TABLE**-US-00002 In0 = Table0Result; In1 = Table1Result; In2 = Table2Result; In3 = Table3Result; // // If No rotation required... // If (Bottom2IndexBits == `00`) THEN OutA = In0; OutB = In1; OutC = In2; OPTIONAL_OutD = In3; // Cubic only // // Else if rotate one place... // ELSEIF(Bottom2IndexBits == `01`) THEN OutA = In1; OutB = In2; OutC = In3; OPTIONAL_OutD = In0; // Cubic only ELSEIF(Bottom2IndexBits == `10`) THEN OutA = In2; OutB = In3; OutC = In0; OPTIONAL_OutD = In1; // Cubic only ELSE OutA = In3; OutB = In0; OutC = In1; OPTIONAL_OutD = In2; // Cubic only ENDIF

**[0043]**This functionality can be implemented in hardware using multiplexor units.

**[0044]**In the quadratic embodiment, in which the polynomial describing the function in the section is a quadratic, only `A` through `C` is supplied to the `B-Spline Evaluate` unit, `43`. For the cubic embodiment, the D value, `45`, is also generated and supplied.

**[0045]**The B-Spline evaluator unit, which will be described in more detail shortly, takes the 3 (or 4) supplied values, A, B, C (and optionally D), and the `alpha` value generated by unit `27`, and creates the interpolated result.

**[0046]**This output of `43` is supplied to unit `50` where the interval value is manipulated and combined with the interpolated function to produce the result, `51`. For the case of the reciprocal function, (again ignoring the special cases of 0 and exact powers of two) the IEEE 8-bit output exponent is set to be "127-Input_exponent-1", and the output of the B-Spline unit is used to form the mantissa.

**[0047]**The details of the quadratic embodiment of the B-Spline evaluation unit, 43, will now be described in more detail with reference to FIG. 4. This unit combines conversion from the B-Spline representation to Bezier representation with the de Casteljau evaluation known in the art. Mathematically, this combination can be summarised as:

**T**

_{1}=(A+B)/2+α(B-A)/2

**T**

_{2}=B+α(C-B)/2

**Result**=T

_{1}α(T

_{2}-T

_{1})

**[0048]**In the preferred embodiment, these are achieved with an `add and divide by 2` unit, 100, which sums inputs A and B. Since this is done with integer/fixed-point maths, the divide by 2 is, in effect, a `no operation` as this is just a trivial `renaming` of the bits. Similarly, the `subtract and divide` unit, 101, computes (B-A)/2. This result is scaled, in unit 102, by the alpha value, (recall that αε[0, 1)). Finally, in unit `103`, the result of `102` is added to the result of `100` to produce intermediate value "T

_{1}". Note that this value will lie between A and B.

**[0049]**Similarly, the intermediate value, "T

_{2}", is produced as follows: Unit `104` subtracts B from C (and halves the result) and supplies it to unit `105` where it is scaled by alpha. This result is then summed with B in unit `106`.

**[0050]**The intermediate values, "T

_{1}" and "T

_{2}" are also linearly interpolated in a similar fashion: Unit 107 computes the difference of "T

_{2}" and "T

_{1}" which is then scaled by alpha in `108`. Finally this result is added to "T

_{1}." in `109` to give the result, `110`.

**[0051]**In this description of the embodiment, the exact precision for each of the operators has not been specified, as this can be set according to the required input and output precisions of the overall functions that must be evaluated. Some descriptions of this process will be described shortly. Having said this, the de Casteljau method of evaluation is very mathematically stable and so the system is more tolerant of errors than the polynomial forms given in Equation 1 or 1a, in that the result will always remain inside the convex hull of the control points.

**[0052]**In a second preferred embodiment, a straightforward quadratic approximation is such as that given in equation 1, i.e.

**f**(x+α)=C

_{0}+C

_{1}α+C

_{2}α

^{2}

**[0053]**The terms for these are very similar to those used in the de Casteljau embodiment, with

**C**0 = ( A + B ) / 2 ##EQU00001## C 1 = ( B - A ) ##EQU00001.2## C 2 = ( C - B ) / 2 - ( B - A ) / 2 = ( C + A - 2 B ) / 2 ##EQU00001.3##

**[0054]**The advantage of this scheme is that there is a much shorter `critical path` through the hardware.

**[0055]**In another embodiment, the multiplication units use truncated multipliers and squarers to reduce the cost of the system.

**[0056]**In another embodiment, a trivial simple linear term is removed from the initial function before evaluating the control point values. This trivial linear function is then re-applied after the linear evaluation to obtain the correct result. The linear function is chosen so that it adds only a negligible cost to the hardware (i.e. it requires no multiplier). The advantage of this is that it reduces the number of bits stored in the table by a significant margin. For example, the function chosen for reciprocal would be f(x)=1-x and for "log" or sine (x), f(x)=x.

**Determining the Initial Values for Stored Control Points**:

**[0057]**As stated, unlike the prior art techniques, the 2

^{N}+K control point values that are stored in the tables generally do not lie on the curve of the function. Since it is important to be able to determine correct values for these points, three methods for computing these will be outlined.

**[0058]**The first method uses the standard numerical technique of Singular Value Decomposition, SVD, (e.g. see "Numerical Recipes in C". ISBN 0 521 43108 5) as a means of computing the best fitting control values. Assuming that in an embodiment, x' is J-bits, the function is evaluated at 2

^{H}evenly spread positions, N<H≦J. A vector containing these 2

^{H}values is constructed. A matrix with 2

^{H}rows and 2

^{N}+K columns is also constructed wherein each row represents the weights that must be applied to each of the control points to evaluate the curve at the corresponding position. With a quadratic approximation, at most 3 items in the row will have non-zero values, all weights will be ≦0 and the row will sum to exactly one.

**[0059]**The matrix is then `pseudo` inverted using the SVD technique and multiplied by the vector to produce the 2

^{N}+K control point values. The closer H is to J, the higher the accuracy of the final function, however, as SVD is an O(N

^{3}) algorithm, H should be chosen prudently. One advantage of this technique, though, is that once the psuedo inverse is computed by SVD, it can be used to compute the control points for several functions.

**[0060]**The second method uses the `lifting` techniques of modern wavelet theory (see "Building Your Own Wavelets at Home". Sweldens and Schroder). This type of algorithm is O(N log N) and so is potentially much faster but may be slightly less accurate than the SVD approach though, in practice, this is likely to be insignificant. As with the SVD technique, a set of 2

^{H}(+additional region on either side) samples of the function are taken. For a quadratic system, these are gradually reduced to 2

^{N}+2 using the following procedure

**[0061]**For each odd position, 2i+1, in the current sample set, compute:

**[0061]**Sample[2i+1]=(Sample[2i]+Sample[2i+2])/2-Sample[2i+1];

**[0062]**For each even position, 2i+1, in the current sample set, compute:

**[0062]**Sample[2i]=(Sample[2i-1]+Sample[2i+1])/4+Sample[2i+1];

**[0063]**Discard the odd sample values.

**[0064]**This is repeated until the required number of points remains. Note that either additional sample points on either side of the extremes are required OR the above must be adjusted to stop access outside of the range of sample values.

**[0065]**The third method is very simple and does not try to reduce the error for all the points in the range, yet still produces acceptable results for quadratic approximations. It relies on the fact that the middle point of a quadratic Bezier curve is given by 1/4 A+1/2 B+1/4C. Since we know that A and C also lie on the curve, those values can also be computed, and so we can thus solve for the control point B, which is the value that is stored in the LUT for that segment.

**Determining Precision of the Stored Values and Functional Units**:

**[0066]**In a hardware embodiment, the size of the data in the stored tables and the width of the multipliers and adders/subtracts are critical to the cost of the system. These values can be `tuned` to achieve the minimum cost for the required output accuracy. A very simple procedure is as follows:

**[0067]**The width of the data stored in the lookup tables is, more or less, directly determined by the required accuracy of the output values, since these values are generally of the same magnitude as the output results and therefore must be of the same precision.

**[0068]**This then approximately determines the input size of the adders and subtract units, 100, 101, and 104. Some savings can be made, however, by evaluating the maximum and minimum differences of the A, B, and C values, which can be used to reduce the size of the subtract units, 101 and 104, and subsequently, the multipliers, 102 and 105. The size of these multipliers depends on the choice for the precision of alpha, which in turn depends on the required accuracy of the overall functions. Some savings, however, can be made by discarding some of the LSBs from the multiplier outputs. The process is then repeated for the final linear interpolator formed by 107, 108, and 109. Alternatively, truncated multipliers can be used to reduce the cost.

**[0069]**Once initial guesses at the precision are obtained, an exhaustive test of all input values can be performed to test precision. If this passes, various precisions of the functional units can be reduced and the precision retested in order to find a cheaper implementation.

**[0070]**This scheme could also be used for implementing `gamma correction` tables in computer graphics.

**[0071]**It will be clear to those skilled in the art that embodiments of the present invention reduce the memory required to store polynomial functions by storing control points from which the polynomial coefficients can be generated rather than by storing all the polynomial coefficients. Thus, only one control point is stored for each section of interval rather than the multiple coefficients which define the polynomial (3 for quadratic, 4 for cubic etc). The control points are manipulated to generate the polynomial coefficients. Additional advantages are provided since a complicated change in a curve can be produced by a small change in one control point. In contrast such a change in the curve would be represented by a completely different set of coefficients.

**[0072]**The present invention is directed to producing a reduction in memory requirements for a device using polynomial functions. The steps of manipulating the input function, determining intervals, index and alpha values as well as the polynomial evaluation are common to known systems. Thus any developments to these areas of systems can be combined with the memory saving facility of the present invention.

User Contributions:

Comment about this patent or add new information about this topic:

People who visited this patent also read: | |

Patent application number | Title |
---|---|

20120109957 | GENERATING A SUBSET AGGREGATE DOCUMENT FROM AN EXISTING AGGREGATE DOCUMENT |

20120109956 | PROFILE PREDICTION FOR SHARED COMPUTERS |

20120109955 | ORGANIZING NEARBY PICTURE HOTSPOTS |

20120109954 | UBIQUITOUS BOOKMARKING |

20120109953 | System and Method for Modeling Human Experiences, and Structuring and Associating Experience Information so as to Automate the Production of Knowledge |