-
Notifications
You must be signed in to change notification settings - Fork 0
/
scalar.h
298 lines (234 loc) · 16.4 KB
/
scalar.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#include <math.h>
#include "sleefinline_purec_scalar.h"
struct BMAS_ipair_float{long idx; float value;};
struct BMAS_ipair_double{long idx; double value;};
struct BMAS_ipair_int64_t{long idx; int64_t value;};
struct BMAS_ipair_int32_t{long idx; int32_t value;};
struct BMAS_ipair_int16_t{long idx; int16_t value;};
struct BMAS_ipair_int8_t {long idx; int8_t value;};
struct BMAS_ipair_uint64_t{long idx; uint64_t value;};
struct BMAS_ipair_uint32_t{long idx; uint32_t value;};
struct BMAS_ipair_uint16_t{long idx; uint16_t value;};
struct BMAS_ipair_uint8_t {long idx; uint8_t value;};
float static inline BMAS_scalar_sadd(float a, float b){return a+b;}
float static inline BMAS_scalar_ssub(float a, float b){return a-b;}
float static inline BMAS_scalar_smul(float a, float b){return a*b;}
float static inline BMAS_scalar_sdiv(float a, float b){return a/b;}
double static inline BMAS_scalar_dadd(double a, double b){return a+b;}
double static inline BMAS_scalar_dsub(double a, double b){return a-b;}
double static inline BMAS_scalar_dmul(double a, double b){return a*b;}
double static inline BMAS_scalar_ddiv(double a, double b){return a/b;}
int64_t static inline BMAS_scalar_i64add(int64_t a, int64_t b){return a+b;}
int32_t static inline BMAS_scalar_i32add(int32_t a, int32_t b){return a+b;}
int16_t static inline BMAS_scalar_i16add(int16_t a, int16_t b){return a+b;}
int8_t static inline BMAS_scalar_i8add (int8_t a, int8_t b){return a+b;}
int64_t static inline BMAS_scalar_i64sub(int64_t a, int64_t b){return a-b;}
int32_t static inline BMAS_scalar_i32sub(int32_t a, int32_t b){return a-b;}
int16_t static inline BMAS_scalar_i16sub(int16_t a, int16_t b){return a-b;}
int8_t static inline BMAS_scalar_i8sub (int8_t a, int8_t b){return a-b;}
int64_t static inline BMAS_scalar_i64mul(int64_t a, int64_t b){return a*b;}
int32_t static inline BMAS_scalar_i32mul(int32_t a, int32_t b){return a*b;}
int16_t static inline BMAS_scalar_i16mul(int16_t a, int16_t b){return a*b;}
int8_t static inline BMAS_scalar_i8mul (int8_t a, int8_t b){return a*b;}
uint64_t static inline BMAS_scalar_u64mul(uint64_t a, uint64_t b){return a*b;}
uint32_t static inline BMAS_scalar_u32mul(uint32_t a, uint32_t b){return a*b;}
uint16_t static inline BMAS_scalar_u16mul(uint16_t a, uint16_t b){return a*b;}
uint8_t static inline BMAS_scalar_u8mul (uint8_t a, uint8_t b){return a*b;}
int64_t static inline BMAS_scalar_i64abs(int64_t a){return llabs(a);}
int32_t static inline BMAS_scalar_i32abs(int32_t a){return abs(a);}
int16_t static inline BMAS_scalar_i16abs(int16_t a){return abs(a);}
int8_t static inline BMAS_scalar_i8abs (int8_t a) {return abs(a);}
float static inline BMAS_scalar_smax(float a, float b){return (a>b)?a:b;}
double static inline BMAS_scalar_dmax(double a, double b){return (a>b)?a:b;}
int64_t static inline BMAS_scalar_i64max(int64_t a, int64_t b){return (a>b)?a:b;}
int32_t static inline BMAS_scalar_i32max(int32_t a, int32_t b){return (a>b)?a:b;}
int16_t static inline BMAS_scalar_i16max(int16_t a, int16_t b){return (a>b)?a:b;}
int8_t static inline BMAS_scalar_i8max (int8_t a, int8_t b){return (a>b)?a:b;}
uint64_t static inline BMAS_scalar_u64max(uint64_t a, uint64_t b){return (a>b)?a:b;}
uint32_t static inline BMAS_scalar_u32max(uint32_t a, uint32_t b){return (a>b)?a:b;}
uint16_t static inline BMAS_scalar_u16max(uint16_t a, uint16_t b){return (a>b)?a:b;}
uint8_t static inline BMAS_scalar_u8max (uint8_t a, uint8_t b){return (a>b)?a:b;}
float static inline BMAS_scalar_smin(float a, float b){return (a<b)?a:b;}
double static inline BMAS_scalar_dmin(double a, double b){return (a<b)?a:b;}
int64_t static inline BMAS_scalar_i64min(int64_t a, int64_t b){return (a<b)?a:b;}
int32_t static inline BMAS_scalar_i32min(int32_t a, int32_t b){return (a<b)?a:b;}
int16_t static inline BMAS_scalar_i16min(int16_t a, int16_t b){return (a<b)?a:b;}
int8_t static inline BMAS_scalar_i8min (int8_t a, int8_t b){return (a<b)?a:b;}
uint64_t static inline BMAS_scalar_u64min(uint64_t a, uint64_t b){return (a<b)?a:b;}
uint32_t static inline BMAS_scalar_u32min(uint32_t a, uint32_t b){return (a<b)?a:b;}
uint16_t static inline BMAS_scalar_u16min(uint16_t a, uint16_t b){return (a<b)?a:b;}
uint8_t static inline BMAS_scalar_u8min (uint8_t a, uint8_t b){return (a<b)?a:b;}
int8_t static inline BMAS_scalar_i8and(int8_t a, int8_t b){return a & b;}
int8_t static inline BMAS_scalar_i8or (int8_t a, int8_t b){return a | b;}
int8_t static inline BMAS_scalar_i8not(int8_t a){return ~a;}
int8_t static inline BMAS_scalar_i8xor(int8_t a, int8_t b){return a ^ b;}
int8_t static inline BMAS_scalar_i8andnot(int8_t a, int8_t b){return a & ~b;}
int16_t static inline BMAS_scalar_i16and(int16_t a, int16_t b){return a & b;}
int16_t static inline BMAS_scalar_i16or (int16_t a, int16_t b){return a | b;}
int16_t static inline BMAS_scalar_i16not(int16_t a){return ~a;}
int16_t static inline BMAS_scalar_i16xor(int16_t a, int16_t b){return a ^ b;}
int16_t static inline BMAS_scalar_i16andnot(int16_t a, int16_t b){return a & ~b;}
int32_t static inline BMAS_scalar_i32and(int32_t a, int32_t b){return a & b;}
int32_t static inline BMAS_scalar_i32or (int32_t a, int32_t b){return a | b;}
int32_t static inline BMAS_scalar_i32not(int32_t a){return ~a;}
int32_t static inline BMAS_scalar_i32xor(int32_t a, int32_t b){return a ^ b;}
int32_t static inline BMAS_scalar_i32andnot(int32_t a, int32_t b){return a & ~b;}
int64_t static inline BMAS_scalar_i64and(int64_t a, int64_t b){return a & b;}
int64_t static inline BMAS_scalar_i64or (int64_t a, int64_t b){return a | b;}
int64_t static inline BMAS_scalar_i64not(int64_t a){return ~a;}
int64_t static inline BMAS_scalar_i64xor(int64_t a, int64_t b){return a ^ b;}
int64_t static inline BMAS_scalar_i64andnot(int64_t a, int64_t b){return a & ~b;}
uint8_t static inline BMAS_scalar_u8and(uint8_t a, uint8_t b){return a & b;}
uint8_t static inline BMAS_scalar_u8or (uint8_t a, uint8_t b){return a | b;}
uint8_t static inline BMAS_scalar_u8not(uint8_t a){return ~a;}
uint8_t static inline BMAS_scalar_u8xor(uint8_t a, uint8_t b){return a ^ b;}
uint8_t static inline BMAS_scalar_u8andnot(uint8_t a, uint8_t b){return a & ~b;}
uint16_t static inline BMAS_scalar_u16and(uint16_t a, uint16_t b){return a & b;}
uint16_t static inline BMAS_scalar_u16or (uint16_t a, uint16_t b){return a | b;}
uint16_t static inline BMAS_scalar_u16not(uint16_t a){return ~a;}
uint16_t static inline BMAS_scalar_u16xor(uint16_t a, uint16_t b){return a ^ b;}
uint16_t static inline BMAS_scalar_u16andnot(uint16_t a, uint16_t b){return a & ~b;}
uint32_t static inline BMAS_scalar_u32and(uint32_t a, uint32_t b){return a & b;}
uint32_t static inline BMAS_scalar_u32or (uint32_t a, uint32_t b){return a | b;}
uint32_t static inline BMAS_scalar_u32not(uint32_t a){return ~a;}
uint32_t static inline BMAS_scalar_u32xor(uint32_t a, uint32_t b){return a ^ b;}
uint32_t static inline BMAS_scalar_u32andnot(uint32_t a, uint32_t b){return a & ~b;}
uint64_t static inline BMAS_scalar_u64and(uint64_t a, uint64_t b){return a & b;}
uint64_t static inline BMAS_scalar_u64or (uint64_t a, uint64_t b){return a | b;}
uint64_t static inline BMAS_scalar_u64not(uint64_t a){return ~a;}
uint64_t static inline BMAS_scalar_u64xor(uint64_t a, uint64_t b){return a ^ b;}
uint64_t static inline BMAS_scalar_u64andnot(uint64_t a, uint64_t b){return a & ~b;}
// gcc uses arithmetic shift on signed values and logical shift on unsigned values
int64_t static inline BMAS_scalar_i64sra(int64_t a, int64_t count){return a >> count;}
int32_t static inline BMAS_scalar_i32sra(int32_t a, int32_t count){return a >> count;}
int16_t static inline BMAS_scalar_i16sra(int16_t a, int16_t count){return a >> count;}
int8_t static inline BMAS_scalar_i8sra(int8_t a, int8_t count){return a >> count;}
uint64_t static inline BMAS_scalar_u64srl(uint64_t a, uint64_t count){return a >> count;}
uint32_t static inline BMAS_scalar_u32srl(uint32_t a, uint32_t count){return a >> count;}
uint16_t static inline BMAS_scalar_u16srl(uint16_t a, uint16_t count){return a >> count;}
uint8_t static inline BMAS_scalar_u8srl(uint8_t a, uint8_t count){return a >> count;}
uint64_t static inline BMAS_scalar_u64sll(uint64_t a, uint64_t count){return a << count;}
uint32_t static inline BMAS_scalar_u32sll(uint32_t a, uint32_t count){return a << count;}
uint16_t static inline BMAS_scalar_u16sll(uint16_t a, uint16_t count){return a << count;}
uint8_t static inline BMAS_scalar_u8sll(uint8_t a, uint8_t count){return a << count;}
_Bool static inline BMAS_scalar_slt(float a, float b){return a<b;}
_Bool static inline BMAS_scalar_sle(float a, float b){return a<=b;}
_Bool static inline BMAS_scalar_seq(float a, float b){return a==b;}
_Bool static inline BMAS_scalar_sneq(float a, float b){return a!=b;}
_Bool static inline BMAS_scalar_sge(float a, float b){return a>=b;}
_Bool static inline BMAS_scalar_sgt(float a, float b){return a>b;}
_Bool static inline BMAS_scalar_dlt(double a, double b){return a<b;}
_Bool static inline BMAS_scalar_dle(double a, double b){return a<=b;}
_Bool static inline BMAS_scalar_deq(double a, double b){return a==b;}
_Bool static inline BMAS_scalar_dneq(double a, double b){return a!=b;}
_Bool static inline BMAS_scalar_dge(double a, double b){return a>=b;}
_Bool static inline BMAS_scalar_dgt(double a, double b){return a>b;}
_Bool static inline BMAS_scalar_i8lt(int8_t a, int8_t b){return a<b;}
_Bool static inline BMAS_scalar_i8le(int8_t a, int8_t b){return a<=b;}
_Bool static inline BMAS_scalar_i8eq(int8_t a, int8_t b){return a==b;}
_Bool static inline BMAS_scalar_i8neq(int8_t a, int8_t b){return a!=b;}
_Bool static inline BMAS_scalar_i8ge(int8_t a, int8_t b){return a>=b;}
_Bool static inline BMAS_scalar_i8gt(int8_t a, int8_t b){return a>b;}
_Bool static inline BMAS_scalar_i16lt(int16_t a, int16_t b){return a<b;}
_Bool static inline BMAS_scalar_i16le(int16_t a, int16_t b){return a<=b;}
_Bool static inline BMAS_scalar_i16eq(int16_t a, int16_t b){return a==b;}
_Bool static inline BMAS_scalar_i16neq(int16_t a, int16_t b){return a!=b;}
_Bool static inline BMAS_scalar_i16ge(int16_t a, int16_t b){return a>=b;}
_Bool static inline BMAS_scalar_i16gt(int16_t a, int16_t b){return a>b;}
_Bool static inline BMAS_scalar_i32lt(int32_t a, int32_t b){return a<b;}
_Bool static inline BMAS_scalar_i32le(int32_t a, int32_t b){return a<=b;}
_Bool static inline BMAS_scalar_i32eq(int32_t a, int32_t b){return a==b;}
_Bool static inline BMAS_scalar_i32neq(int32_t a, int32_t b){return a!=b;}
_Bool static inline BMAS_scalar_i32ge(int32_t a, int32_t b){return a>=b;}
_Bool static inline BMAS_scalar_i32gt(int32_t a, int32_t b){return a>b;}
_Bool static inline BMAS_scalar_i64lt(int64_t a, int64_t b){return a<b;}
_Bool static inline BMAS_scalar_i64le(int64_t a, int64_t b){return a<=b;}
_Bool static inline BMAS_scalar_i64eq(int64_t a, int64_t b){return a==b;}
_Bool static inline BMAS_scalar_i64neq(int64_t a, int64_t b){return a!=b;}
_Bool static inline BMAS_scalar_i64ge(int64_t a, int64_t b){return a>=b;}
_Bool static inline BMAS_scalar_i64gt(int64_t a, int64_t b){return a>b;}
_Bool static inline BMAS_scalar_u8lt(uint8_t a, uint8_t b){return a<b;}
_Bool static inline BMAS_scalar_u8le(uint8_t a, uint8_t b){return a<=b;}
_Bool static inline BMAS_scalar_u8eq(uint8_t a, uint8_t b){return a==b;}
_Bool static inline BMAS_scalar_u8neq(uint8_t a, uint8_t b){return a!=b;}
_Bool static inline BMAS_scalar_u8ge(uint8_t a, uint8_t b){return a>=b;}
_Bool static inline BMAS_scalar_u8gt(uint8_t a, uint8_t b){return a>b;}
_Bool static inline BMAS_scalar_u16lt(uint16_t a, uint16_t b){return a<b;}
_Bool static inline BMAS_scalar_u16le(uint16_t a, uint16_t b){return a<=b;}
_Bool static inline BMAS_scalar_u16eq(uint16_t a, uint16_t b){return a==b;}
_Bool static inline BMAS_scalar_u16neq(uint16_t a, uint16_t b){return a!=b;}
_Bool static inline BMAS_scalar_u16ge(uint16_t a, uint16_t b){return a>=b;}
_Bool static inline BMAS_scalar_u16gt(uint16_t a, uint16_t b){return a>b;}
_Bool static inline BMAS_scalar_u32lt(uint32_t a, uint32_t b){return a<b;}
_Bool static inline BMAS_scalar_u32le(uint32_t a, uint32_t b){return a<=b;}
_Bool static inline BMAS_scalar_u32eq(uint32_t a, uint32_t b){return a==b;}
_Bool static inline BMAS_scalar_u32neq(uint32_t a, uint32_t b){return a!=b;}
_Bool static inline BMAS_scalar_u32ge(uint32_t a, uint32_t b){return a>=b;}
_Bool static inline BMAS_scalar_u32gt(uint32_t a, uint32_t b){return a>b;}
_Bool static inline BMAS_scalar_u64lt(uint64_t a, uint64_t b){return a<b;}
_Bool static inline BMAS_scalar_u64le(uint64_t a, uint64_t b){return a<=b;}
_Bool static inline BMAS_scalar_u64eq(uint64_t a, uint64_t b){return a==b;}
_Bool static inline BMAS_scalar_u64neq(uint64_t a, uint64_t b){return a!=b;}
_Bool static inline BMAS_scalar_u64ge(uint64_t a, uint64_t b){return a>=b;}
_Bool static inline BMAS_scalar_u64gt(uint64_t a, uint64_t b){return a>b;}
// trigonometric
float static inline BMAS_scalar_ssin(float a){return sinf(a);}
float static inline BMAS_scalar_scos(float a){return cosf(a);}
float static inline BMAS_scalar_stan(float a){return tanf(a);}
float static inline BMAS_scalar_sasin(float a){return asinf(a);}
float static inline BMAS_scalar_sacos(float a){return acosf(a);}
float static inline BMAS_scalar_satan(float a){return atanf(a);}
float static inline BMAS_scalar_ssinh(float a){return sinhf(a);}
float static inline BMAS_scalar_scosh(float a){return coshf(a);}
float static inline BMAS_scalar_stanh(float a){return tanhf(a);}
float static inline BMAS_scalar_sasinh(float a){return asinhf(a);}
float static inline BMAS_scalar_sacosh(float a){return acoshf(a);}
float static inline BMAS_scalar_satanh(float a){return atanhf(a);}
double static inline BMAS_scalar_dsin(double a){return sin(a);}
double static inline BMAS_scalar_dcos(double a){return cos(a);}
double static inline BMAS_scalar_dtan(double a){return tan(a);}
double static inline BMAS_scalar_dasin(double a){return asin(a);}
double static inline BMAS_scalar_dacos(double a){return acos(a);}
double static inline BMAS_scalar_datan(double a){return atan(a);}
double static inline BMAS_scalar_dsinh(double a){return sinh(a);}
double static inline BMAS_scalar_dcosh(double a){return cosh(a);}
double static inline BMAS_scalar_dtanh(double a){return tanh(a);}
double static inline BMAS_scalar_dasinh(double a){return asinh(a);}
double static inline BMAS_scalar_dacosh(double a){return acosh(a);}
double static inline BMAS_scalar_datanh(double a){return atanh(a);}
// log
float static inline BMAS_scalar_slog(float a) {return logf(a);}
float static inline BMAS_scalar_slog10(float a){return log10f(a);}
float static inline BMAS_scalar_slog2(float a) {return log2f(a);}
float static inline BMAS_scalar_slog1p(float a){return log1pf(a);}
double static inline BMAS_scalar_dlog(double a) {return log(a);}
double static inline BMAS_scalar_dlog10(double a){return log10(a);}
double static inline BMAS_scalar_dlog2(double a) {return log2(a);}
double static inline BMAS_scalar_dlog1p(double a){return log1p(a);}
// exp
float static inline BMAS_scalar_sexp(float a) {return expf(a);}
float static inline BMAS_scalar_sexp10(float a){return Sleef_exp10f1_u10purec(a);}
float static inline BMAS_scalar_sexp2(float a) {return exp2f(a);}
float static inline BMAS_scalar_sexpm1(float a){return expm1f(a);}
double static inline BMAS_scalar_dexp(double a) {return exp(a);}
double static inline BMAS_scalar_dexp10(double a){return Sleef_exp10d1_u10purec(a);}
double static inline BMAS_scalar_dexp2(double a) {return exp2(a);}
double static inline BMAS_scalar_dexpm1(double a){return expm1(a);}
// pow and atan2
float static inline BMAS_scalar_spow(float x, float y){return powf(x, y);}
float static inline BMAS_scalar_satan2(float x, float y){return atan2f(x, y);}
double static inline BMAS_scalar_dpow(double x, double y){return pow(x, y);}
double static inline BMAS_scalar_datan2(double x, double y){return atan2(x, y);}
// misc
float static inline BMAS_scalar_sfabs(float x) { return fabsf(x);}
float static inline BMAS_scalar_sceil(float x) { return ceilf(x);}
float static inline BMAS_scalar_strunc(float x) { return truncf(x);}
float static inline BMAS_scalar_sfloor(float x) { return floorf(x);}
float static inline BMAS_scalar_sround(float x) { return roundf(x);}
double static inline BMAS_scalar_dfabs(double x) { return fabs(x);}
double static inline BMAS_scalar_dceil(double x) { return ceil(x);}
double static inline BMAS_scalar_dtrunc(double x) { return trunc(x);}
double static inline BMAS_scalar_dfloor(double x) { return floor(x);}
double static inline BMAS_scalar_dround(double x) { return round(x);}
float static inline BMAS_scalar_ssqrt(float x) { return sqrtf(x); }
double static inline BMAS_scalar_dsqrt(double x){ return sqrt(x); }