paddlec 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +674 -0
- data/README.md +56 -0
- data/ext/libpaddlec/arithmetic.c +2486 -0
- data/ext/libpaddlec/comparison.c +683 -0
- data/ext/libpaddlec/complex.c +349 -0
- data/ext/libpaddlec/delay.c +240 -0
- data/ext/libpaddlec/fir_filter.c +724 -0
- data/ext/libpaddlec/fir_filter_avx.c +2645 -0
- data/ext/libpaddlec/fir_filter_neon.c +1767 -0
- data/ext/libpaddlec/fir_filter_sse.c +1677 -0
- data/ext/libpaddlec/libpaddlec.c +933 -0
- data/ext/libpaddlec/libpaddlec.h +473 -0
- data/ext/libpaddlec/math.c +563 -0
- data/ext/libpaddlec/no_fast_math.c +955 -0
- data/ext/libpaddlec/rounding.c +503 -0
- data/ext/paddlec/complex_buffer.c +3555 -0
- data/ext/paddlec/complex_buffer.h +28 -0
- data/ext/paddlec/delay.c +214 -0
- data/ext/paddlec/delay.h +29 -0
- data/ext/paddlec/extconf.rb +106 -0
- data/ext/paddlec/fir_filter.c +892 -0
- data/ext/paddlec/fir_filter.h +28 -0
- data/ext/paddlec/float_buffer.c +4770 -0
- data/ext/paddlec/float_buffer.h +28 -0
- data/ext/paddlec/paddlec.c +788 -0
- data/ext/paddlec/paddlec.h +76 -0
- data/ext/paddlec/pulseaudio.c +6767 -0
- data/ext/paddlec/pulseaudio.h +30 -0
- data/lib/paddlec.rb +26 -0
- data/lib/paddlec/version.rb +3 -0
- data/paddlec.gemspec +55 -0
- data/samples/fmdemod.rb +121 -0
- data/samples/fmdemod_chunk.rb +120 -0
- data/samples/fmdemod_chunk_buffer.rb +144 -0
- data/samples/stereo_chunk.rb +161 -0
- metadata +99 -0
@@ -0,0 +1,683 @@
|
|
1
|
+
/* Copyright (C) 2019 Théotime Bollengier <theotime.bollengier@gmail.com>
|
2
|
+
*
|
3
|
+
* This file is part of PaddleC
|
4
|
+
*
|
5
|
+
* PaddleC is free software: you can redistribute it and/or modify
|
6
|
+
* it under the terms of the GNU General Public License as published by
|
7
|
+
* the Free Software Foundation, either version 3 of the License, or
|
8
|
+
* (at your option) any later version.
|
9
|
+
*
|
10
|
+
* PaddleC is distributed in the hope that it will be useful,
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
* GNU General Public License for more details.
|
14
|
+
*
|
15
|
+
* You should have received a copy of the GNU General Public License
|
16
|
+
* along with PaddleC. If not, see <https://www.gnu.org/licenses/>.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#include <stdlib.h>
|
20
|
+
#include <math.h>
|
21
|
+
#include "libpaddlec.h"
|
22
|
+
|
23
|
+
|
24
|
+
pdlc_buffer_t* pdlc_fb_fb_cmpless(const pdlc_buffer_t *lhs, const pdlc_buffer_t *rhs, pdlc_buffer_t *res)
|
25
|
+
{
|
26
|
+
size_t i;
|
27
|
+
size_t len = lhs->length;
|
28
|
+
|
29
|
+
if (len > rhs->length)
|
30
|
+
len = rhs->length;
|
31
|
+
|
32
|
+
if (!res)
|
33
|
+
res = pdlc_buffer_new(len);
|
34
|
+
else
|
35
|
+
pdlc_buffer_resize(res, len, 0);
|
36
|
+
|
37
|
+
for (i = 0; i < len; i++)
|
38
|
+
res->data[i] = (lhs->data[i] < rhs->data[i]) ? 1.0f : 0.0f;
|
39
|
+
|
40
|
+
return res;
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
pdlc_buffer_t* pdlc_fb_fb_cmpless_inplace(pdlc_buffer_t *lhs, const pdlc_buffer_t *rhs)
|
45
|
+
{
|
46
|
+
size_t i;
|
47
|
+
size_t len = lhs->length;
|
48
|
+
|
49
|
+
if (len > rhs->length)
|
50
|
+
len = rhs->length;
|
51
|
+
|
52
|
+
for (i = 0; i < len; i++)
|
53
|
+
lhs->data[i] = (lhs->data[i] < rhs->data[i]) ? 1.0f : 0.0f;
|
54
|
+
|
55
|
+
return lhs;
|
56
|
+
}
|
57
|
+
|
58
|
+
|
59
|
+
pdlc_buffer_t* pdlc_fb_fs_cmpless(const pdlc_buffer_t *lhs, float rhs, pdlc_buffer_t *res)
|
60
|
+
{
|
61
|
+
size_t i;
|
62
|
+
const size_t len = lhs->length;
|
63
|
+
|
64
|
+
if (!res)
|
65
|
+
res = pdlc_buffer_new(len);
|
66
|
+
else
|
67
|
+
pdlc_buffer_resize(res, len, 0);
|
68
|
+
|
69
|
+
for (i = 0; i < len; i++)
|
70
|
+
res->data[i] = (lhs->data[i] < rhs) ? 1.0f : 0.0f;
|
71
|
+
|
72
|
+
return res;
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
pdlc_buffer_t* pdlc_fb_fs_cmpless_inplace(pdlc_buffer_t *lhs, float rhs)
|
77
|
+
{
|
78
|
+
size_t i;
|
79
|
+
const size_t len = lhs->length;
|
80
|
+
|
81
|
+
for (i = 0; i < len; i++)
|
82
|
+
lhs->data[i] = (lhs->data[i] < rhs) ? 1.0f : 0.0f;
|
83
|
+
|
84
|
+
return lhs;
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
pdlc_buffer_t* pdlc_fb_fb_cmplessequ(const pdlc_buffer_t *lhs, const pdlc_buffer_t *rhs, pdlc_buffer_t *res)
|
89
|
+
{
|
90
|
+
size_t i;
|
91
|
+
size_t len = lhs->length;
|
92
|
+
|
93
|
+
if (len > rhs->length)
|
94
|
+
len = rhs->length;
|
95
|
+
|
96
|
+
if (!res)
|
97
|
+
res = pdlc_buffer_new(len);
|
98
|
+
else
|
99
|
+
pdlc_buffer_resize(res, len, 0);
|
100
|
+
|
101
|
+
for (i = 0; i < len; i++)
|
102
|
+
res->data[i] = (lhs->data[i] <= rhs->data[i]) ? 1.0f : 0.0f;
|
103
|
+
|
104
|
+
return res;
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
pdlc_buffer_t* pdlc_fb_fb_cmplessequ_inplace(pdlc_buffer_t *lhs, const pdlc_buffer_t *rhs)
|
109
|
+
{
|
110
|
+
size_t i;
|
111
|
+
size_t len = lhs->length;
|
112
|
+
|
113
|
+
if (len > rhs->length)
|
114
|
+
len = rhs->length;
|
115
|
+
|
116
|
+
for (i = 0; i < len; i++)
|
117
|
+
lhs->data[i] = (lhs->data[i] <= rhs->data[i]) ? 1.0f : 0.0f;
|
118
|
+
|
119
|
+
return lhs;
|
120
|
+
}
|
121
|
+
|
122
|
+
|
123
|
+
pdlc_buffer_t* pdlc_fb_fs_cmplessequ(const pdlc_buffer_t *lhs, float rhs, pdlc_buffer_t *res)
|
124
|
+
{
|
125
|
+
size_t i;
|
126
|
+
const size_t len = lhs->length;
|
127
|
+
|
128
|
+
if (!res)
|
129
|
+
res = pdlc_buffer_new(len);
|
130
|
+
else
|
131
|
+
pdlc_buffer_resize(res, len, 0);
|
132
|
+
|
133
|
+
for (i = 0; i < len; i++)
|
134
|
+
res->data[i] = (lhs->data[i] <= rhs) ? 1.0f : 0.0f;
|
135
|
+
|
136
|
+
return res;
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
pdlc_buffer_t* pdlc_fb_fs_cmplessequ_inplace(pdlc_buffer_t *lhs, float rhs)
|
141
|
+
{
|
142
|
+
size_t i;
|
143
|
+
const size_t len = lhs->length;
|
144
|
+
|
145
|
+
for (i = 0; i < len; i++)
|
146
|
+
lhs->data[i] = (lhs->data[i] <= rhs) ? 1.0f : 0.0f;
|
147
|
+
|
148
|
+
return lhs;
|
149
|
+
}
|
150
|
+
|
151
|
+
|
152
|
+
pdlc_buffer_t* pdlc_fb_fb_cmpgrt(const pdlc_buffer_t *lhs, const pdlc_buffer_t *rhs, pdlc_buffer_t *res)
|
153
|
+
{
|
154
|
+
size_t i;
|
155
|
+
size_t len = lhs->length;
|
156
|
+
|
157
|
+
if (len > rhs->length)
|
158
|
+
len = rhs->length;
|
159
|
+
|
160
|
+
if (!res)
|
161
|
+
res = pdlc_buffer_new(len);
|
162
|
+
else
|
163
|
+
pdlc_buffer_resize(res, len, 0);
|
164
|
+
|
165
|
+
for (i = 0; i < len; i++)
|
166
|
+
res->data[i] = (lhs->data[i] > rhs->data[i]) ? 1.0f : 0.0f;
|
167
|
+
|
168
|
+
return res;
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
pdlc_buffer_t* pdlc_fb_fb_cmpgrt_inplace(pdlc_buffer_t *lhs, const pdlc_buffer_t *rhs)
|
173
|
+
{
|
174
|
+
size_t i;
|
175
|
+
size_t len = lhs->length;
|
176
|
+
|
177
|
+
if (len > rhs->length)
|
178
|
+
len = rhs->length;
|
179
|
+
|
180
|
+
for (i = 0; i < len; i++)
|
181
|
+
lhs->data[i] = (lhs->data[i] > rhs->data[i]) ? 1.0f : 0.0f;
|
182
|
+
|
183
|
+
return lhs;
|
184
|
+
}
|
185
|
+
|
186
|
+
|
187
|
+
pdlc_buffer_t* pdlc_fb_fs_cmpgrt(const pdlc_buffer_t *lhs, float rhs, pdlc_buffer_t *res)
|
188
|
+
{
|
189
|
+
size_t i;
|
190
|
+
const size_t len = lhs->length;
|
191
|
+
|
192
|
+
if (!res)
|
193
|
+
res = pdlc_buffer_new(len);
|
194
|
+
else
|
195
|
+
pdlc_buffer_resize(res, len, 0);
|
196
|
+
|
197
|
+
for (i = 0; i < len; i++)
|
198
|
+
res->data[i] = (lhs->data[i] > rhs) ? 1.0f : 0.0f;
|
199
|
+
|
200
|
+
return res;
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
pdlc_buffer_t* pdlc_fb_fs_cmpgrt_inplace(pdlc_buffer_t *lhs, float rhs)
|
205
|
+
{
|
206
|
+
size_t i;
|
207
|
+
const size_t len = lhs->length;
|
208
|
+
|
209
|
+
for (i = 0; i < len; i++)
|
210
|
+
lhs->data[i] = (lhs->data[i] > rhs) ? 1.0f : 0.0f;
|
211
|
+
|
212
|
+
return lhs;
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
pdlc_buffer_t* pdlc_fb_fb_cmpgrtequ(const pdlc_buffer_t *lhs, const pdlc_buffer_t *rhs, pdlc_buffer_t *res)
|
217
|
+
{
|
218
|
+
size_t i;
|
219
|
+
size_t len = lhs->length;
|
220
|
+
|
221
|
+
if (len > rhs->length)
|
222
|
+
len = rhs->length;
|
223
|
+
|
224
|
+
if (!res)
|
225
|
+
res = pdlc_buffer_new(len);
|
226
|
+
else
|
227
|
+
pdlc_buffer_resize(res, len, 0);
|
228
|
+
|
229
|
+
for (i = 0; i < len; i++)
|
230
|
+
res->data[i] = (lhs->data[i] >= rhs->data[i]) ? 1.0f : 0.0f;
|
231
|
+
|
232
|
+
return res;
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
pdlc_buffer_t* pdlc_fb_fb_cmpgrtequ_inplace(pdlc_buffer_t *lhs, const pdlc_buffer_t *rhs)
|
237
|
+
{
|
238
|
+
size_t i;
|
239
|
+
size_t len = lhs->length;
|
240
|
+
|
241
|
+
if (len > rhs->length)
|
242
|
+
len = rhs->length;
|
243
|
+
|
244
|
+
for (i = 0; i < len; i++)
|
245
|
+
lhs->data[i] = (lhs->data[i] >= rhs->data[i]) ? 1.0f : 0.0f;
|
246
|
+
|
247
|
+
return lhs;
|
248
|
+
}
|
249
|
+
|
250
|
+
|
251
|
+
pdlc_buffer_t* pdlc_fb_fs_cmpgrtequ(const pdlc_buffer_t *lhs, float rhs, pdlc_buffer_t *res)
|
252
|
+
{
|
253
|
+
size_t i;
|
254
|
+
const size_t len = lhs->length;
|
255
|
+
|
256
|
+
if (!res)
|
257
|
+
res = pdlc_buffer_new(len);
|
258
|
+
else
|
259
|
+
pdlc_buffer_resize(res, len, 0);
|
260
|
+
|
261
|
+
for (i = 0; i < len; i++)
|
262
|
+
res->data[i] = (lhs->data[i] >= rhs) ? 1.0f : 0.0f;
|
263
|
+
|
264
|
+
return res;
|
265
|
+
}
|
266
|
+
|
267
|
+
|
268
|
+
pdlc_buffer_t* pdlc_fb_fs_cmpgrtequ_inplace(pdlc_buffer_t *lhs, float rhs)
|
269
|
+
{
|
270
|
+
size_t i;
|
271
|
+
const size_t len = lhs->length;
|
272
|
+
|
273
|
+
for (i = 0; i < len; i++)
|
274
|
+
lhs->data[i] = (lhs->data[i] >= rhs) ? 1.0f : 0.0f;
|
275
|
+
|
276
|
+
return lhs;
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
pdlc_buffer_t* pdlc_fb_fb_equ(const pdlc_buffer_t *lhs, const pdlc_buffer_t *rhs, pdlc_buffer_t *res)
|
281
|
+
{
|
282
|
+
size_t i;
|
283
|
+
size_t len = lhs->length;
|
284
|
+
|
285
|
+
if (len > rhs->length)
|
286
|
+
len = rhs->length;
|
287
|
+
|
288
|
+
if (!res)
|
289
|
+
res = pdlc_buffer_new(len);
|
290
|
+
else
|
291
|
+
pdlc_buffer_resize(res, len, 0);
|
292
|
+
|
293
|
+
for (i = 0; i < len; i++)
|
294
|
+
res->data[i] = (lhs->data[i] == rhs->data[i]) ? 1.0f : 0.0f;
|
295
|
+
|
296
|
+
return res;
|
297
|
+
}
|
298
|
+
|
299
|
+
|
300
|
+
pdlc_buffer_t* pdlc_fb_fb_equ_inplace(pdlc_buffer_t *lhs, const pdlc_buffer_t *rhs)
|
301
|
+
{
|
302
|
+
size_t i;
|
303
|
+
size_t len = lhs->length;
|
304
|
+
|
305
|
+
if (len > rhs->length)
|
306
|
+
len = rhs->length;
|
307
|
+
|
308
|
+
for (i = 0; i < len; i++)
|
309
|
+
lhs->data[i] = (lhs->data[i] == rhs->data[i]) ? 1.0f : 0.0f;
|
310
|
+
|
311
|
+
return lhs;
|
312
|
+
}
|
313
|
+
|
314
|
+
|
315
|
+
pdlc_buffer_t* pdlc_fb_fs_equ(const pdlc_buffer_t *lhs, float rhs, pdlc_buffer_t *res)
|
316
|
+
{
|
317
|
+
size_t i;
|
318
|
+
const size_t len = lhs->length;
|
319
|
+
|
320
|
+
if (!res)
|
321
|
+
res = pdlc_buffer_new(len);
|
322
|
+
else
|
323
|
+
pdlc_buffer_resize(res, len, 0);
|
324
|
+
|
325
|
+
for (i = 0; i < len; i++)
|
326
|
+
res->data[i] = (lhs->data[i] == rhs) ? 1.0f : 0.0f;
|
327
|
+
|
328
|
+
return res;
|
329
|
+
}
|
330
|
+
|
331
|
+
|
332
|
+
pdlc_buffer_t* pdlc_fb_fs_equ_inplace(pdlc_buffer_t *lhs, float rhs)
|
333
|
+
{
|
334
|
+
size_t i;
|
335
|
+
const size_t len = lhs->length;
|
336
|
+
|
337
|
+
for (i = 0; i < len; i++)
|
338
|
+
lhs->data[i] = (lhs->data[i] == rhs) ? 1.0f : 0.0f;
|
339
|
+
|
340
|
+
return lhs;
|
341
|
+
}
|
342
|
+
|
343
|
+
|
344
|
+
pdlc_buffer_t* pdlc_cb_cb_equ(const pdlc_complex_buffer_t *lhs, const pdlc_complex_buffer_t *rhs, pdlc_buffer_t *res)
|
345
|
+
{
|
346
|
+
size_t i;
|
347
|
+
size_t len = lhs->length;
|
348
|
+
|
349
|
+
if (len > rhs->length)
|
350
|
+
len = rhs->length;
|
351
|
+
|
352
|
+
if (!res)
|
353
|
+
res = pdlc_buffer_new(len);
|
354
|
+
else
|
355
|
+
pdlc_buffer_resize(res, len, 0);
|
356
|
+
|
357
|
+
for (i = 0; i < len; i++)
|
358
|
+
res->data[i] = ((lhs->data[i].real == rhs->data[i].real) && (lhs->data[i].imag == rhs->data[i].imag)) ? 1.0f : 0.0f;
|
359
|
+
|
360
|
+
return res;
|
361
|
+
}
|
362
|
+
|
363
|
+
|
364
|
+
pdlc_buffer_t* pdlc_cb_cs_equ(const pdlc_complex_buffer_t *lhs, pdlc_complex_t rhs, pdlc_buffer_t *res)
|
365
|
+
{
|
366
|
+
size_t i;
|
367
|
+
const size_t len = lhs->length;
|
368
|
+
|
369
|
+
if (!res)
|
370
|
+
res = pdlc_buffer_new(len);
|
371
|
+
else
|
372
|
+
pdlc_buffer_resize(res, len, 0);
|
373
|
+
|
374
|
+
for (i = 0; i < len; i++)
|
375
|
+
res->data[i] = ((lhs->data[i].real == rhs.real) && (lhs->data[i].imag == rhs.imag)) ? 1.0f : 0.0f;
|
376
|
+
|
377
|
+
return res;
|
378
|
+
}
|
379
|
+
|
380
|
+
|
381
|
+
pdlc_buffer_t* pdlc_fb_cb_equ(const pdlc_buffer_t *lhs, const pdlc_complex_buffer_t *rhs, pdlc_buffer_t *res)
|
382
|
+
{
|
383
|
+
size_t i;
|
384
|
+
size_t len = lhs->length;
|
385
|
+
|
386
|
+
if (len > rhs->length)
|
387
|
+
len = rhs->length;
|
388
|
+
|
389
|
+
if (!res)
|
390
|
+
res = pdlc_buffer_new(len);
|
391
|
+
else
|
392
|
+
pdlc_buffer_resize(res, len, 0);
|
393
|
+
|
394
|
+
for (i = 0; i < len; i++)
|
395
|
+
res->data[i] = ((lhs->data[i] == rhs->data[i].real) && (rhs->data[i].imag == 0.0f)) ? 1.0f : 0.0f;
|
396
|
+
|
397
|
+
return res;
|
398
|
+
}
|
399
|
+
|
400
|
+
|
401
|
+
pdlc_buffer_t* pdlc_fb_cb_equ_inplace(pdlc_buffer_t *lhs, const pdlc_complex_buffer_t *rhs)
|
402
|
+
{
|
403
|
+
size_t i;
|
404
|
+
size_t len = lhs->length;
|
405
|
+
|
406
|
+
if (len > rhs->length)
|
407
|
+
len = rhs->length;
|
408
|
+
|
409
|
+
for (i = 0; i < len; i++)
|
410
|
+
lhs->data[i] = ((lhs->data[i] == rhs->data[i].real) && (rhs->data[i].imag == 0.0f)) ? 1.0f : 0.0f;
|
411
|
+
|
412
|
+
return lhs;
|
413
|
+
}
|
414
|
+
|
415
|
+
|
416
|
+
pdlc_buffer_t* pdlc_fb_cs_equ(const pdlc_buffer_t *lhs, pdlc_complex_t rhs, pdlc_buffer_t *res)
|
417
|
+
{
|
418
|
+
size_t i;
|
419
|
+
const size_t len = lhs->length;
|
420
|
+
|
421
|
+
if (!res)
|
422
|
+
res = pdlc_buffer_new(len);
|
423
|
+
else
|
424
|
+
pdlc_buffer_resize(res, len, 0);
|
425
|
+
|
426
|
+
for (i = 0; i < len; i++)
|
427
|
+
res->data[i] = ((lhs->data[i] == rhs.real) && (rhs.imag == 0.0f)) ? 1.0f : 0.0f;
|
428
|
+
|
429
|
+
return res;
|
430
|
+
}
|
431
|
+
|
432
|
+
|
433
|
+
pdlc_buffer_t* pdlc_fb_cs_equ_inplace(pdlc_buffer_t *lhs, pdlc_complex_t rhs)
|
434
|
+
{
|
435
|
+
size_t i;
|
436
|
+
const size_t len = lhs->length;
|
437
|
+
|
438
|
+
for (i = 0; i < len; i++)
|
439
|
+
lhs->data[i] = ((lhs->data[i] == rhs.real) && (rhs.imag == 0.0f)) ? 1.0f : 0.0f;
|
440
|
+
|
441
|
+
return lhs;
|
442
|
+
}
|
443
|
+
|
444
|
+
|
445
|
+
pdlc_buffer_t* pdlc_cb_fb_equ(const pdlc_complex_buffer_t *lhs, const pdlc_buffer_t *rhs, pdlc_buffer_t *res)
|
446
|
+
{
|
447
|
+
size_t i;
|
448
|
+
size_t len = lhs->length;
|
449
|
+
|
450
|
+
if (len > rhs->length)
|
451
|
+
len = rhs->length;
|
452
|
+
|
453
|
+
if (!res)
|
454
|
+
res = pdlc_buffer_new(len);
|
455
|
+
else
|
456
|
+
pdlc_buffer_resize(res, len, 0);
|
457
|
+
|
458
|
+
for (i = 0; i < len; i++)
|
459
|
+
res->data[i] = ((lhs->data[i].real == rhs->data[i]) && (lhs->data[i].imag == 0.0f)) ? 1.0f : 0.0f;
|
460
|
+
|
461
|
+
return res;
|
462
|
+
}
|
463
|
+
|
464
|
+
|
465
|
+
pdlc_buffer_t* pdlc_cb_fs_equ(const pdlc_complex_buffer_t *lhs, float rhs, pdlc_buffer_t *res)
|
466
|
+
{
|
467
|
+
size_t i;
|
468
|
+
const size_t len = lhs->length;
|
469
|
+
|
470
|
+
if (!res)
|
471
|
+
res = pdlc_buffer_new(len);
|
472
|
+
else
|
473
|
+
pdlc_buffer_resize(res, len, 0);
|
474
|
+
|
475
|
+
for (i = 0; i < len; i++)
|
476
|
+
res->data[i] = ((lhs->data[i].real == rhs) && (lhs->data[i].imag == 0.0f)) ? 1.0f : 0.0f;
|
477
|
+
|
478
|
+
return res;
|
479
|
+
}
|
480
|
+
|
481
|
+
|
482
|
+
pdlc_buffer_t* pdlc_fb_fb_different(const pdlc_buffer_t *lhs, const pdlc_buffer_t *rhs, pdlc_buffer_t *res)
|
483
|
+
{
|
484
|
+
size_t i;
|
485
|
+
size_t len = lhs->length;
|
486
|
+
|
487
|
+
if (len > rhs->length)
|
488
|
+
len = rhs->length;
|
489
|
+
|
490
|
+
if (!res)
|
491
|
+
res = pdlc_buffer_new(len);
|
492
|
+
else
|
493
|
+
pdlc_buffer_resize(res, len, 0);
|
494
|
+
|
495
|
+
for (i = 0; i < len; i++)
|
496
|
+
res->data[i] = (lhs->data[i] != rhs->data[i]) ? 1.0f : 0.0f;
|
497
|
+
|
498
|
+
return res;
|
499
|
+
}
|
500
|
+
|
501
|
+
|
502
|
+
pdlc_buffer_t* pdlc_fb_fb_different_inplace(pdlc_buffer_t *lhs, const pdlc_buffer_t *rhs)
|
503
|
+
{
|
504
|
+
size_t i;
|
505
|
+
size_t len = lhs->length;
|
506
|
+
|
507
|
+
if (len > rhs->length)
|
508
|
+
len = rhs->length;
|
509
|
+
|
510
|
+
for (i = 0; i < len; i++)
|
511
|
+
lhs->data[i] = (lhs->data[i] != rhs->data[i]) ? 1.0f : 0.0f;
|
512
|
+
|
513
|
+
return lhs;
|
514
|
+
}
|
515
|
+
|
516
|
+
|
517
|
+
pdlc_buffer_t* pdlc_fb_fs_different(const pdlc_buffer_t *lhs, float rhs, pdlc_buffer_t *res)
|
518
|
+
{
|
519
|
+
size_t i;
|
520
|
+
const size_t len = lhs->length;
|
521
|
+
|
522
|
+
if (!res)
|
523
|
+
res = pdlc_buffer_new(len);
|
524
|
+
else
|
525
|
+
pdlc_buffer_resize(res, len, 0);
|
526
|
+
|
527
|
+
for (i = 0; i < len; i++)
|
528
|
+
res->data[i] = (lhs->data[i] != rhs) ? 1.0f : 0.0f;
|
529
|
+
|
530
|
+
return res;
|
531
|
+
}
|
532
|
+
|
533
|
+
|
534
|
+
pdlc_buffer_t* pdlc_fb_fs_different_inplace(pdlc_buffer_t *lhs, float rhs)
|
535
|
+
{
|
536
|
+
size_t i;
|
537
|
+
const size_t len = lhs->length;
|
538
|
+
|
539
|
+
for (i = 0; i < len; i++)
|
540
|
+
lhs->data[i] = (lhs->data[i] != rhs) ? 1.0f : 0.0f;
|
541
|
+
|
542
|
+
return lhs;
|
543
|
+
}
|
544
|
+
|
545
|
+
|
546
|
+
pdlc_buffer_t* pdlc_cb_cb_different(const pdlc_complex_buffer_t *lhs, const pdlc_complex_buffer_t *rhs, pdlc_buffer_t *res)
|
547
|
+
{
|
548
|
+
size_t i;
|
549
|
+
size_t len = lhs->length;
|
550
|
+
|
551
|
+
if (len > rhs->length)
|
552
|
+
len = rhs->length;
|
553
|
+
|
554
|
+
if (!res)
|
555
|
+
res = pdlc_buffer_new(len);
|
556
|
+
else
|
557
|
+
pdlc_buffer_resize(res, len, 0);
|
558
|
+
|
559
|
+
for (i = 0; i < len; i++)
|
560
|
+
res->data[i] = ((lhs->data[i].real != rhs->data[i].real) || (lhs->data[i].imag != rhs->data[i].imag)) ? 1.0f : 0.0f;
|
561
|
+
|
562
|
+
return res;
|
563
|
+
}
|
564
|
+
|
565
|
+
|
566
|
+
pdlc_buffer_t* pdlc_cb_cs_different(const pdlc_complex_buffer_t *lhs, pdlc_complex_t rhs, pdlc_buffer_t *res)
|
567
|
+
{
|
568
|
+
size_t i;
|
569
|
+
const size_t len = lhs->length;
|
570
|
+
|
571
|
+
if (!res)
|
572
|
+
res = pdlc_buffer_new(len);
|
573
|
+
else
|
574
|
+
pdlc_buffer_resize(res, len, 0);
|
575
|
+
|
576
|
+
for (i = 0; i < len; i++)
|
577
|
+
res->data[i] = ((lhs->data[i].real != rhs.real) || (lhs->data[i].imag != rhs.imag)) ? 1.0f : 0.0f;
|
578
|
+
|
579
|
+
return res;
|
580
|
+
}
|
581
|
+
|
582
|
+
|
583
|
+
pdlc_buffer_t* pdlc_fb_cb_different(const pdlc_buffer_t *lhs, const pdlc_complex_buffer_t *rhs, pdlc_buffer_t *res)
|
584
|
+
{
|
585
|
+
size_t i;
|
586
|
+
size_t len = lhs->length;
|
587
|
+
|
588
|
+
if (len > rhs->length)
|
589
|
+
len = rhs->length;
|
590
|
+
|
591
|
+
if (!res)
|
592
|
+
res = pdlc_buffer_new(len);
|
593
|
+
else
|
594
|
+
pdlc_buffer_resize(res, len, 0);
|
595
|
+
|
596
|
+
for (i = 0; i < len; i++)
|
597
|
+
res->data[i] = ((lhs->data[i] != rhs->data[i].real) || (rhs->data[i].imag != 0.0f)) ? 1.0f : 0.0f;
|
598
|
+
|
599
|
+
return res;
|
600
|
+
}
|
601
|
+
|
602
|
+
|
603
|
+
pdlc_buffer_t* pdlc_fb_cb_different_inplace(pdlc_buffer_t *lhs, const pdlc_complex_buffer_t *rhs)
|
604
|
+
{
|
605
|
+
size_t i;
|
606
|
+
size_t len = lhs->length;
|
607
|
+
|
608
|
+
if (len > rhs->length)
|
609
|
+
len = rhs->length;
|
610
|
+
|
611
|
+
for (i = 0; i < len; i++)
|
612
|
+
lhs->data[i] = ((lhs->data[i] != rhs->data[i].real) || (rhs->data[i].imag != 0.0f)) ? 1.0f : 0.0f;
|
613
|
+
|
614
|
+
return lhs;
|
615
|
+
}
|
616
|
+
|
617
|
+
|
618
|
+
pdlc_buffer_t* pdlc_fb_cs_different(const pdlc_buffer_t *lhs, pdlc_complex_t rhs, pdlc_buffer_t *res)
|
619
|
+
{
|
620
|
+
size_t i;
|
621
|
+
const size_t len = lhs->length;
|
622
|
+
|
623
|
+
if (!res)
|
624
|
+
res = pdlc_buffer_new(len);
|
625
|
+
else
|
626
|
+
pdlc_buffer_resize(res, len, 0);
|
627
|
+
|
628
|
+
for (i = 0; i < len; i++)
|
629
|
+
res->data[i] = ((lhs->data[i] != rhs.real) || (rhs.imag != 0.0f)) ? 1.0f : 0.0f;
|
630
|
+
|
631
|
+
return res;
|
632
|
+
}
|
633
|
+
|
634
|
+
|
635
|
+
pdlc_buffer_t* pdlc_fb_cs_different_inplace(pdlc_buffer_t *lhs, pdlc_complex_t rhs)
|
636
|
+
{
|
637
|
+
size_t i;
|
638
|
+
const size_t len = lhs->length;
|
639
|
+
|
640
|
+
for (i = 0; i < len; i++)
|
641
|
+
lhs->data[i] = ((lhs->data[i] != rhs.real) || (rhs.imag != 0.0f)) ? 1.0f : 0.0f;
|
642
|
+
|
643
|
+
return lhs;
|
644
|
+
}
|
645
|
+
|
646
|
+
|
647
|
+
pdlc_buffer_t* pdlc_cb_fb_different(const pdlc_complex_buffer_t *lhs, const pdlc_buffer_t *rhs, pdlc_buffer_t *res)
|
648
|
+
{
|
649
|
+
size_t i;
|
650
|
+
size_t len = lhs->length;
|
651
|
+
|
652
|
+
if (len > rhs->length)
|
653
|
+
len = rhs->length;
|
654
|
+
|
655
|
+
if (!res)
|
656
|
+
res = pdlc_buffer_new(len);
|
657
|
+
else
|
658
|
+
pdlc_buffer_resize(res, len, 0);
|
659
|
+
|
660
|
+
for (i = 0; i < len; i++)
|
661
|
+
res->data[i] = ((lhs->data[i].real != rhs->data[i]) && (lhs->data[i].imag != 0.0f)) ? 1.0f : 0.0f;
|
662
|
+
|
663
|
+
return res;
|
664
|
+
}
|
665
|
+
|
666
|
+
|
667
|
+
pdlc_buffer_t* pdlc_cb_fs_different(const pdlc_complex_buffer_t *lhs, float rhs, pdlc_buffer_t *res)
|
668
|
+
{
|
669
|
+
size_t i;
|
670
|
+
const size_t len = lhs->length;
|
671
|
+
|
672
|
+
if (!res)
|
673
|
+
res = pdlc_buffer_new(len);
|
674
|
+
else
|
675
|
+
pdlc_buffer_resize(res, len, 0);
|
676
|
+
|
677
|
+
for (i = 0; i < len; i++)
|
678
|
+
res->data[i] = ((lhs->data[i].real != rhs) && (lhs->data[i].imag != 0.0f)) ? 1.0f : 0.0f;
|
679
|
+
|
680
|
+
return res;
|
681
|
+
}
|
682
|
+
|
683
|
+
|