paddlec 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,563 @@
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_buffer_acos(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
25
+ {
26
+ size_t i;
27
+
28
+ if (!ofbuf)
29
+ ofbuf = pdlc_buffer_new(fbuf->length);
30
+ else
31
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
32
+
33
+ for (i = 0; i < fbuf->length; i++)
34
+ ofbuf->data[i] = acosf(fbuf->data[i]);
35
+
36
+ return ofbuf;
37
+ }
38
+
39
+
40
+ pdlc_buffer_t* pdlc_buffer_acos_inplace(pdlc_buffer_t *fbuf)
41
+ {
42
+ size_t i;
43
+
44
+ for (i = 0; i < fbuf->length; i++)
45
+ fbuf->data[i] = acosf(fbuf->data[i]);
46
+
47
+ return fbuf;
48
+ }
49
+
50
+
51
+ pdlc_buffer_t* pdlc_buffer_acosh(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
52
+ {
53
+ size_t i;
54
+
55
+ if (!ofbuf)
56
+ ofbuf = pdlc_buffer_new(fbuf->length);
57
+ else
58
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
59
+
60
+ for (i = 0; i < fbuf->length; i++)
61
+ ofbuf->data[i] = acoshf(fbuf->data[i]);
62
+
63
+ return ofbuf;
64
+ }
65
+
66
+
67
+ pdlc_buffer_t* pdlc_buffer_acosh_inplace(pdlc_buffer_t *fbuf)
68
+ {
69
+ size_t i;
70
+
71
+ for (i = 0; i < fbuf->length; i++)
72
+ fbuf->data[i] = acoshf(fbuf->data[i]);
73
+
74
+ return fbuf;
75
+ }
76
+
77
+
78
+ pdlc_buffer_t* pdlc_buffer_asin(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
79
+ {
80
+ size_t i;
81
+
82
+ if (!ofbuf)
83
+ ofbuf = pdlc_buffer_new(fbuf->length);
84
+ else
85
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
86
+
87
+ for (i = 0; i < fbuf->length; i++)
88
+ ofbuf->data[i] = asinf(fbuf->data[i]);
89
+
90
+ return ofbuf;
91
+ }
92
+
93
+
94
+ pdlc_buffer_t* pdlc_buffer_asin_inplace(pdlc_buffer_t *fbuf)
95
+ {
96
+ size_t i;
97
+
98
+ for (i = 0; i < fbuf->length; i++)
99
+ fbuf->data[i] = asinf(fbuf->data[i]);
100
+
101
+ return fbuf;
102
+ }
103
+
104
+
105
+ pdlc_buffer_t* pdlc_buffer_asinh(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
106
+ {
107
+ size_t i;
108
+
109
+ if (!ofbuf)
110
+ ofbuf = pdlc_buffer_new(fbuf->length);
111
+ else
112
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
113
+
114
+ for (i = 0; i < fbuf->length; i++)
115
+ ofbuf->data[i] = asinhf(fbuf->data[i]);
116
+
117
+ return ofbuf;
118
+ }
119
+
120
+
121
+ pdlc_buffer_t* pdlc_buffer_asinh_inplace(pdlc_buffer_t *fbuf)
122
+ {
123
+ size_t i;
124
+
125
+ for (i = 0; i < fbuf->length; i++)
126
+ fbuf->data[i] = asinhf(fbuf->data[i]);
127
+
128
+ return fbuf;
129
+ }
130
+
131
+
132
+ pdlc_buffer_t* pdlc_buffer_atan(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
133
+ {
134
+ size_t i;
135
+
136
+ if (!ofbuf)
137
+ ofbuf = pdlc_buffer_new(fbuf->length);
138
+ else
139
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
140
+
141
+ for (i = 0; i < fbuf->length; i++)
142
+ ofbuf->data[i] = atanf(fbuf->data[i]);
143
+
144
+ return ofbuf;
145
+ }
146
+
147
+
148
+ pdlc_buffer_t* pdlc_buffer_atan_inplace(pdlc_buffer_t *fbuf)
149
+ {
150
+ size_t i;
151
+
152
+ for (i = 0; i < fbuf->length; i++)
153
+ fbuf->data[i] = atanf(fbuf->data[i]);
154
+
155
+ return fbuf;
156
+ }
157
+
158
+
159
+ pdlc_buffer_t* pdlc_buffer_atanh(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
160
+ {
161
+ size_t i;
162
+
163
+ if (!ofbuf)
164
+ ofbuf = pdlc_buffer_new(fbuf->length);
165
+ else
166
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
167
+
168
+ for (i = 0; i < fbuf->length; i++)
169
+ ofbuf->data[i] = atanhf(fbuf->data[i]);
170
+
171
+ return ofbuf;
172
+ }
173
+
174
+
175
+ pdlc_buffer_t* pdlc_buffer_atanh_inplace(pdlc_buffer_t *fbuf)
176
+ {
177
+ size_t i;
178
+
179
+ for (i = 0; i < fbuf->length; i++)
180
+ fbuf->data[i] = atanhf(fbuf->data[i]);
181
+
182
+ return fbuf;
183
+ }
184
+
185
+
186
+ pdlc_buffer_t* pdlc_buffer_cbrt(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
187
+ {
188
+ size_t i;
189
+
190
+ if (!ofbuf)
191
+ ofbuf = pdlc_buffer_new(fbuf->length);
192
+ else
193
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
194
+
195
+ for (i = 0; i < fbuf->length; i++)
196
+ ofbuf->data[i] = cbrtf(fbuf->data[i]);
197
+
198
+ return ofbuf;
199
+ }
200
+
201
+
202
+ pdlc_buffer_t* pdlc_buffer_cbrt_inplace(pdlc_buffer_t *fbuf)
203
+ {
204
+ size_t i;
205
+
206
+ for (i = 0; i < fbuf->length; i++)
207
+ fbuf->data[i] = cbrtf(fbuf->data[i]);
208
+
209
+ return fbuf;
210
+ }
211
+
212
+
213
+ pdlc_buffer_t* pdlc_buffer_cos(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
214
+ {
215
+ size_t i;
216
+
217
+ if (!ofbuf)
218
+ ofbuf = pdlc_buffer_new(fbuf->length);
219
+ else
220
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
221
+
222
+ for (i = 0; i < fbuf->length; i++)
223
+ ofbuf->data[i] = cosf(fbuf->data[i]);
224
+
225
+ return ofbuf;
226
+ }
227
+
228
+
229
+ pdlc_buffer_t* pdlc_buffer_cos_inplace(pdlc_buffer_t *fbuf)
230
+ {
231
+ size_t i;
232
+
233
+ for (i = 0; i < fbuf->length; i++)
234
+ fbuf->data[i] = cosf(fbuf->data[i]);
235
+
236
+ return fbuf;
237
+ }
238
+
239
+
240
+ pdlc_buffer_t* pdlc_buffer_cosh(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
241
+ {
242
+ size_t i;
243
+
244
+ if (!ofbuf)
245
+ ofbuf = pdlc_buffer_new(fbuf->length);
246
+ else
247
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
248
+
249
+ for (i = 0; i < fbuf->length; i++)
250
+ ofbuf->data[i] = coshf(fbuf->data[i]);
251
+
252
+ return ofbuf;
253
+ }
254
+
255
+
256
+ pdlc_buffer_t* pdlc_buffer_cosh_inplace(pdlc_buffer_t *fbuf)
257
+ {
258
+ size_t i;
259
+
260
+ for (i = 0; i < fbuf->length; i++)
261
+ fbuf->data[i] = coshf(fbuf->data[i]);
262
+
263
+ return fbuf;
264
+ }
265
+
266
+
267
+ pdlc_buffer_t* pdlc_buffer_erf(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
268
+ {
269
+ size_t i;
270
+
271
+ if (!ofbuf)
272
+ ofbuf = pdlc_buffer_new(fbuf->length);
273
+ else
274
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
275
+
276
+ for (i = 0; i < fbuf->length; i++)
277
+ ofbuf->data[i] = erff(fbuf->data[i]);
278
+
279
+ return ofbuf;
280
+ }
281
+
282
+
283
+ pdlc_buffer_t* pdlc_buffer_erf_inplace(pdlc_buffer_t *fbuf)
284
+ {
285
+ size_t i;
286
+
287
+ for (i = 0; i < fbuf->length; i++)
288
+ fbuf->data[i] = erff(fbuf->data[i]);
289
+
290
+ return fbuf;
291
+ }
292
+
293
+
294
+ pdlc_buffer_t* pdlc_buffer_erfc(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
295
+ {
296
+ size_t i;
297
+
298
+ if (!ofbuf)
299
+ ofbuf = pdlc_buffer_new(fbuf->length);
300
+ else
301
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
302
+
303
+ for (i = 0; i < fbuf->length; i++)
304
+ ofbuf->data[i] = erfcf(fbuf->data[i]);
305
+
306
+ return ofbuf;
307
+ }
308
+
309
+
310
+ pdlc_buffer_t* pdlc_buffer_erfc_inplace(pdlc_buffer_t *fbuf)
311
+ {
312
+ size_t i;
313
+
314
+ for (i = 0; i < fbuf->length; i++)
315
+ fbuf->data[i] = erfcf(fbuf->data[i]);
316
+
317
+ return fbuf;
318
+ }
319
+
320
+
321
+ pdlc_buffer_t* pdlc_buffer_exp(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
322
+ {
323
+ size_t i;
324
+
325
+ if (!ofbuf)
326
+ ofbuf = pdlc_buffer_new(fbuf->length);
327
+ else
328
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
329
+
330
+ for (i = 0; i < fbuf->length; i++)
331
+ ofbuf->data[i] = expf(fbuf->data[i]);
332
+
333
+ return ofbuf;
334
+ }
335
+
336
+
337
+ pdlc_buffer_t* pdlc_buffer_exp_inplace(pdlc_buffer_t *fbuf)
338
+ {
339
+ size_t i;
340
+
341
+ for (i = 0; i < fbuf->length; i++)
342
+ fbuf->data[i] = expf(fbuf->data[i]);
343
+
344
+ return fbuf;
345
+ }
346
+
347
+
348
+ pdlc_buffer_t* pdlc_buffer_log(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
349
+ {
350
+ size_t i;
351
+
352
+ if (!ofbuf)
353
+ ofbuf = pdlc_buffer_new(fbuf->length);
354
+ else
355
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
356
+
357
+ for (i = 0; i < fbuf->length; i++)
358
+ ofbuf->data[i] = logf(fbuf->data[i]);
359
+
360
+ return ofbuf;
361
+ }
362
+
363
+
364
+ pdlc_buffer_t* pdlc_buffer_log_inplace(pdlc_buffer_t *fbuf)
365
+ {
366
+ size_t i;
367
+
368
+ for (i = 0; i < fbuf->length; i++)
369
+ fbuf->data[i] = logf(fbuf->data[i]);
370
+
371
+ return fbuf;
372
+ }
373
+
374
+
375
+ pdlc_buffer_t* pdlc_buffer_log10(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
376
+ {
377
+ size_t i;
378
+
379
+ if (!ofbuf)
380
+ ofbuf = pdlc_buffer_new(fbuf->length);
381
+ else
382
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
383
+
384
+ for (i = 0; i < fbuf->length; i++)
385
+ ofbuf->data[i] = log10f(fbuf->data[i]);
386
+
387
+ return ofbuf;
388
+ }
389
+
390
+
391
+ pdlc_buffer_t* pdlc_buffer_log10_inplace(pdlc_buffer_t *fbuf)
392
+ {
393
+ size_t i;
394
+
395
+ for (i = 0; i < fbuf->length; i++)
396
+ fbuf->data[i] = log10f(fbuf->data[i]);
397
+
398
+ return fbuf;
399
+ }
400
+
401
+
402
+ pdlc_buffer_t* pdlc_buffer_log2(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
403
+ {
404
+ size_t i;
405
+
406
+ if (!ofbuf)
407
+ ofbuf = pdlc_buffer_new(fbuf->length);
408
+ else
409
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
410
+
411
+ for (i = 0; i < fbuf->length; i++)
412
+ ofbuf->data[i] = log2f(fbuf->data[i]);
413
+
414
+ return ofbuf;
415
+ }
416
+
417
+
418
+ pdlc_buffer_t* pdlc_buffer_log2_inplace(pdlc_buffer_t *fbuf)
419
+ {
420
+ size_t i;
421
+
422
+ for (i = 0; i < fbuf->length; i++)
423
+ fbuf->data[i] = log2f(fbuf->data[i]);
424
+
425
+ return fbuf;
426
+ }
427
+
428
+
429
+ pdlc_buffer_t* pdlc_buffer_sin(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
430
+ {
431
+ size_t i;
432
+
433
+ if (!ofbuf)
434
+ ofbuf = pdlc_buffer_new(fbuf->length);
435
+ else
436
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
437
+
438
+ for (i = 0; i < fbuf->length; i++)
439
+ ofbuf->data[i] = sinf(fbuf->data[i]);
440
+
441
+ return ofbuf;
442
+ }
443
+
444
+
445
+ pdlc_buffer_t* pdlc_buffer_sin_inplace(pdlc_buffer_t *fbuf)
446
+ {
447
+ size_t i;
448
+
449
+ for (i = 0; i < fbuf->length; i++)
450
+ fbuf->data[i] = sinf(fbuf->data[i]);
451
+
452
+ return fbuf;
453
+ }
454
+
455
+
456
+ pdlc_buffer_t* pdlc_buffer_sinh(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
457
+ {
458
+ size_t i;
459
+
460
+ if (!ofbuf)
461
+ ofbuf = pdlc_buffer_new(fbuf->length);
462
+ else
463
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
464
+
465
+ for (i = 0; i < fbuf->length; i++)
466
+ ofbuf->data[i] = sinhf(fbuf->data[i]);
467
+
468
+ return ofbuf;
469
+ }
470
+
471
+
472
+ pdlc_buffer_t* pdlc_buffer_sinh_inplace(pdlc_buffer_t *fbuf)
473
+ {
474
+ size_t i;
475
+
476
+ for (i = 0; i < fbuf->length; i++)
477
+ fbuf->data[i] = sinhf(fbuf->data[i]);
478
+
479
+ return fbuf;
480
+ }
481
+
482
+
483
+ pdlc_buffer_t* pdlc_buffer_sqrt(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
484
+ {
485
+ size_t i;
486
+
487
+ if (!ofbuf)
488
+ ofbuf = pdlc_buffer_new(fbuf->length);
489
+ else
490
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
491
+
492
+ for (i = 0; i < fbuf->length; i++)
493
+ ofbuf->data[i] = sqrtf(fbuf->data[i]);
494
+
495
+ return ofbuf;
496
+ }
497
+
498
+
499
+ pdlc_buffer_t* pdlc_buffer_sqrt_inplace(pdlc_buffer_t *fbuf)
500
+ {
501
+ size_t i;
502
+
503
+ for (i = 0; i < fbuf->length; i++)
504
+ fbuf->data[i] = sqrtf(fbuf->data[i]);
505
+
506
+ return fbuf;
507
+ }
508
+
509
+
510
+ pdlc_buffer_t* pdlc_buffer_tan(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
511
+ {
512
+ size_t i;
513
+
514
+ if (!ofbuf)
515
+ ofbuf = pdlc_buffer_new(fbuf->length);
516
+ else
517
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
518
+
519
+ for (i = 0; i < fbuf->length; i++)
520
+ ofbuf->data[i] = tanf(fbuf->data[i]);
521
+
522
+ return ofbuf;
523
+ }
524
+
525
+
526
+ pdlc_buffer_t* pdlc_buffer_tan_inplace(pdlc_buffer_t *fbuf)
527
+ {
528
+ size_t i;
529
+
530
+ for (i = 0; i < fbuf->length; i++)
531
+ fbuf->data[i] = tanf(fbuf->data[i]);
532
+
533
+ return fbuf;
534
+ }
535
+
536
+
537
+ pdlc_buffer_t* pdlc_buffer_tanh(const pdlc_buffer_t *fbuf, pdlc_buffer_t *ofbuf)
538
+ {
539
+ size_t i;
540
+
541
+ if (!ofbuf)
542
+ ofbuf = pdlc_buffer_new(fbuf->length);
543
+ else
544
+ pdlc_buffer_resize(ofbuf, fbuf->length, 0);
545
+
546
+ for (i = 0; i < fbuf->length; i++)
547
+ ofbuf->data[i] = tanhf(fbuf->data[i]);
548
+
549
+ return ofbuf;
550
+ }
551
+
552
+
553
+ pdlc_buffer_t* pdlc_buffer_tanh_inplace(pdlc_buffer_t *fbuf)
554
+ {
555
+ size_t i;
556
+
557
+ for (i = 0; i < fbuf->length; i++)
558
+ fbuf->data[i] = tanhf(fbuf->data[i]);
559
+
560
+ return fbuf;
561
+ }
562
+
563
+