spinn_common 7.3.1
Support code for SpiNNaker applications.
|
Fast polynomial evaluation, using ARM DSP instructions. More...
Go to the source code of this file.
Functions | |
static int | __horner_int_b (int *a, int x, int n) |
Horner evaluation of a polynomial of s1615 at a point given by the lower (signed) 16-bits of x. | |
static int | __horner_int_t (int *a, int x, int n) |
Horner evaluation of a polynomial of s1615 at a point given by the upper (signed) 16-bits of x. | |
Fast polynomial evaluation, using ARM DSP instructions.
Each function takes three arguments: the polynomial coefficients, the point at which we are evaluating the polynomial, and the order of the polynomial.
Assume that we have (note the "reverse order"):
int a [] = { a_4, a_3, a_2, a_1, a_0 };
This represents the function:
a_0 + x * (a_1 + x * (a_2 + x * (a_3 + x * a_4)))
To use the fast DSP instructions we use an "odd" representation of x: s0.16. If we are using the usual s0.15 fract type, then we are restricted to x lying in the range [0.5, 0.5).
In the above example (because we have a quartic polynomial) n = 4.
The other point to note is that the addition in the evaluation may overflow. In the code that follows, we use the Q-bit to detect if this has happened. One sure-fire case in which there is no overflow is if the polynomial is alternating.
|
inlinestatic |
Horner evaluation of a polynomial of s1615 at a point given by the lower (signed) 16-bits of x.
[in] | a | The 32-bit signed polynomial coefficients. These can be treated as either s1615 or s031 (or any other signed 32-bit quantity). |
[in] | x | The point at which the polynomial is to be evaluated is given by treating the lower 16-bits of the argument as s0.16. Note this is not a s015, thus, if we are using a s015 here, we must treat the s015 value of -1.0 as if it were only -0.5. |
[in] | n | The number of coefficients in the polynomial. |
|
inlinestatic |
Horner evaluation of a polynomial of s1615 at a point given by the upper (signed) 16-bits of x.
[in] | a | The 32-bit signed polynomial coefficients. These can be treated as either s1615 or s031 (or any other signed 32-bit quantity. |
[in] | x | The point at which the polynomial is to be evaluated is given by treating the upper 16-bits of the argument as s0.16. Note this is not a s015, thus, if we are using a s015 here, we must treat the s015 value of -1.0 as if it were only -0.5. |
[in] | n | The number of coefficients in the polynomial. |