spinn_common 7.3.1
Support code for SpiNNaker applications.
Loading...
Searching...
No Matches
polynomial.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
57#ifndef __POLYNOMIAL_H__
58#define __POLYNOMIAL_H__
59
60#include "arm_acle.h"
61#include "assert.h"
62
74static inline int __horner_int_b(
75 int *a,
76 int x,
77 int n)
78{
79#ifdef __ARM_FEATURE_DSP
80 register int r = *a++;
81
82 assert(!__reset_and_saturation_occurred());
83 for ( ; n > 0; n--) {
84 r = __smlawb(r, x, *a++);
85 }
86 assert(!__saturation_occurred());
87 return r;
88#else
89 register int64_t t = *a++;
90 register int64_t dx = (int64_t) ((int16_t) (x & 0xFFFF));
91
92 for ( ; n > 0; n--) {
93 t = (t * dx >> 16) + *a++;
94 }
95 return (int) (t & 0xFFFFFFFF);
96#endif /*__ARM_FEATURE_DSP*/
97}
98
110static inline int __horner_int_t(
111 int *a,
112 int x,
113 int n)
114{
115#ifdef __ARM_FEATURE_DSP
116 register int r = *a++;
117
118 assert(!__reset_and_saturation_occurred());
119 for ( ; n > 0; n--) {
120 r = __smlawt(r, x, *a++);
121 }
122 assert(!__saturation_occurred());
123 return r;
124#else
125 register int64_t t = *a++;
126 register int64_t dx = (int64_t) (x >> 16);
127
128 for ( ; n > 0; n--) {
129 t = (t * dx >> 16) + *a++;
130 }
131 return (int) (t & 0xFFFFFFFF);
132#endif /*__ARM_FEATURE_DSP*/
133}
134
135#endif /*__POLYNOMIAL_H__*/
SpiNNaker debug header file.
#define assert(assertion)
This macro performs an assertion check on a condition and aborts if the condition is not met.
Definition assert.h:145
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.
Definition polynomial.h:74
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.
Definition polynomial.h:110
const signed char dx[6]