spinn_common  7.4.2
Support code for SpiNNaker applications.
normal.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 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 
19 
20 #ifndef __NORMAL_H__
21 #define __NORMAL_H__
22 
23 #include <stdint.h>
24 #include <stdbool.h>
25 #include <stdfix.h>
26 #include "stdfix-full-iso.h"
27 #include "assert.h"
28 
29 #ifndef UNIMPLEMENTED
30 #define UNIMPLEMENTED extern __attribute__((deprecated("Not implemented")))
31 #endif
32 
41 int __norminv_rbits(int x);
42 
49 static inline int __norminv_t_bits(int x) {
50  return __norminv_rbits(x >> 16);
51 }
52 
59 static inline int __norminv_b_bits(int x) {
60  return __norminv_t_bits(x << 16);
61 }
62 
68 static inline s1615 norminv_urb(unsigned int x) {
69  union { unsigned int u; int s; } tmp;
70 
71  tmp.u = x;
72  return kbits(__norminv_b_bits(tmp.s));
73 }
74 
80 static inline s1615 norminv_urt(unsigned int x) {
81  union { unsigned int u; int s; } tmp;
82 
83  tmp.u = x;
84  return kbits(__norminv_t_bits(tmp.s));
85 }
86 
91 static inline s1615 norminv_ur(u016 x) {
92  union { unsigned int u; int s; } tmp;
93 
94  tmp.u = bitsur(x);
95  return kbits(__norminv_rbits(tmp.s + INT16_MIN));
96 }
97 
102 UNIMPLEMENTED s1615 norminv_ulr(u032 x);
103 
108 #define norminv_fx(f) \
109  _Generic((f), \
110  u016: norminv_ur(f), \
111  u032: norminv_ulr(f), \
112  default: __builtin_trap() \
113  )
114 
115 #endif /*__NORMAL_H__*/
SpiNNaker debug header file.
s1615 norminv_ulr(u032 x)
This function takes a uniformly distributed 16-bit PRNG value, x, and returns a normally distributed ...
static int __norminv_t_bits(int x)
This function takes a uniformly distributed 16-bit PRNG value, x, and returns a normally distributed ...
Definition: normal.h:49
static int __norminv_b_bits(int x)
This function takes a uniformly distributed 16-bit PRNG value, x, and returns a normally distributed ...
Definition: normal.h:59
static s1615 norminv_urt(unsigned int x)
This function takes a uniformly distributed 16-bit PRNG value, x, and returns a normally distributed ...
Definition: normal.h:80
static s1615 norminv_urb(unsigned int x)
This function takes a uniformly distributed 16-bit PRNG value, x, and returns a normally distributed ...
Definition: normal.h:68
static s1615 norminv_ur(u016 x)
This function takes a uniformly distributed 16-bit PRNG value, x, and returns a normally distributed ...
Definition: normal.h:91
int __norminv_rbits(int x)
This function takes a uniformly distributed 16-bit PRNG value, x, and returns a normally distributed ...
Definition: normal.c:242
Additions to the stdfix.h file to support full Draft ISO/IEC standards compliance.
unsigned fract u016
An alternative name for the unsigned fract type.
Definition: stdfix-full-iso.h:193
static uint_ur_t bitsur(const u016 f)
Converts an unsigned fract into an integer.
Definition: stdfix-full-iso.h:328
accum s1615
An alternative name for the signed accum type.
Definition: stdfix-full-iso.h:184
unsigned long fract u032
An alternative name for the unsigned long fract type.
Definition: stdfix-full-iso.h:196
static s1615 kbits(const int_k_t n)
Converts a signed integer into a signed accum.
Definition: stdfix-full-iso.h:450