spinn_common 7.3.1
Support code for SpiNNaker applications.
Loading...
Searching...
No Matches
Functions
polynomial.h File Reference

Fast polynomial evaluation, using ARM DSP instructions. More...

#include "arm_acle.h"
#include "assert.h"

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.
 

Detailed Description

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.

Author
Dave Lester (david.nosp@m..r.l.nosp@m.ester.nosp@m.@man.nosp@m.chest.nosp@m.er.a.nosp@m.c.uk)
Date
13 December, 2014

Function Documentation

◆ __horner_int_b()

static int __horner_int_b ( int *  a,
int  x,
int  n 
)
inlinestatic

Horner evaluation of a polynomial of s1615 at a point given by the lower (signed) 16-bits of x.

Parameters
[in]aThe 32-bit signed polynomial coefficients. These can be treated as either s1615 or s031 (or any other signed 32-bit quantity).
[in]xThe 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]nThe number of coefficients in the polynomial.
Returns
The result as a signed 32-bit quantity.

◆ __horner_int_t()

static int __horner_int_t ( int *  a,
int  x,
int  n 
)
inlinestatic

Horner evaluation of a polynomial of s1615 at a point given by the upper (signed) 16-bits of x.

Parameters
[in]aThe 32-bit signed polynomial coefficients. These can be treated as either s1615 or s031 (or any other signed 32-bit quantity.
[in]xThe 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]nThe number of coefficients in the polynomial.
Returns
The result as a signed 32-bit quantity.