@stdlib/math-base-napi-binary 0.0.7 → 0.1.0
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.
- package/CITATION.cff +30 -0
- package/LICENSE +0 -304
- package/NOTICE +1 -1
- package/README.md +579 -15
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +1 -1
- package/include/stdlib/math/base/napi/binary.h +428 -0
- package/lib/index.js +2 -2
- package/manifest.json +6 -1
- package/package.json +18 -10
- package/src/main.c +917 -0
- package/binding.gyp +0 -170
- package/docs/types/test.ts +0 -28
package/README.md
CHANGED
|
@@ -18,9 +18,20 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
21
32
|
# binary
|
|
22
33
|
|
|
23
|
-
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url]
|
|
34
|
+
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
24
35
|
|
|
25
36
|
> C APIs for registering a Node-API module exporting interfaces for invoking binary numerical functions.
|
|
26
37
|
|
|
@@ -108,16 +119,6 @@ console.log( headerDir );
|
|
|
108
119
|
|
|
109
120
|
<!-- C usage documentation. -->
|
|
110
121
|
|
|
111
|
-
<section class="installation">
|
|
112
|
-
|
|
113
|
-
## Installation
|
|
114
|
-
|
|
115
|
-
```bash
|
|
116
|
-
npm install @stdlib/math-base-napi-binary
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
</section>
|
|
120
|
-
|
|
121
122
|
<section class="usage">
|
|
122
123
|
|
|
123
124
|
### Usage
|
|
@@ -202,6 +203,299 @@ The function accepts the following arguments:
|
|
|
202
203
|
|
|
203
204
|
```c
|
|
204
205
|
void stdlib_math_base_napi_ff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float ) );
|
|
206
|
+
```de "stdlib/math/base/napi/binary.h"
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### stdlib_math_base_napi_zz_z( env, info, fcn )
|
|
210
|
+
|
|
211
|
+
Invokes a binary function accepting and returning double-precision complex floating-point numbers.
|
|
212
|
+
|
|
213
|
+
```c
|
|
214
|
+
#include "stdlib/complex/float64.h"
|
|
215
|
+
#include "stdlib/complex/reim.h"
|
|
216
|
+
#include <node_api.h>
|
|
217
|
+
|
|
218
|
+
// ...
|
|
219
|
+
|
|
220
|
+
static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y ) {
|
|
221
|
+
double xre;
|
|
222
|
+
double xim;
|
|
223
|
+
double yre;
|
|
224
|
+
double yim;
|
|
225
|
+
double re;
|
|
226
|
+
double im;
|
|
227
|
+
|
|
228
|
+
stdlib_reim( x, &xre, &xim );
|
|
229
|
+
stdlib_reim( y, &yre, &yim );
|
|
230
|
+
|
|
231
|
+
re = xre + yre;
|
|
232
|
+
im = xim + yim;
|
|
233
|
+
|
|
234
|
+
return stdlib_complex128( re, im );
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// ...
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Receives JavaScript callback invocation data.
|
|
241
|
+
*
|
|
242
|
+
* @param env environment under which the function is invoked
|
|
243
|
+
* @param info callback data
|
|
244
|
+
* @return Node-API value
|
|
245
|
+
*/
|
|
246
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
247
|
+
return stdlib_math_base_napi_zz_z( env, info, add );
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// ...
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
The function accepts the following arguments:
|
|
254
|
+
|
|
255
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
256
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
257
|
+
- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t )` binary function.
|
|
258
|
+
|
|
259
|
+
```c
|
|
260
|
+
void stdlib_math_base_napi_zz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t ) );
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
#### stdlib_math_base_napi_cc_c( env, info, fcn )
|
|
264
|
+
|
|
265
|
+
Invokes a binary function accepting and returning single-precision complex floating-point numbers.
|
|
266
|
+
|
|
267
|
+
```c
|
|
268
|
+
#include "stdlib/complex/float64.h"
|
|
269
|
+
#include "stdlib/complex/reim.h"
|
|
270
|
+
#include <node_api.h>
|
|
271
|
+
|
|
272
|
+
// ...
|
|
273
|
+
|
|
274
|
+
static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y ) {
|
|
275
|
+
float xre;
|
|
276
|
+
float xim;
|
|
277
|
+
float yre;
|
|
278
|
+
float yim;
|
|
279
|
+
float re;
|
|
280
|
+
float im;
|
|
281
|
+
|
|
282
|
+
stdlib_reimf( x, &xre, &xim );
|
|
283
|
+
stdlib_reimf( y, &yre, &yim );
|
|
284
|
+
|
|
285
|
+
re = xre + yre;
|
|
286
|
+
im = xim + yim;
|
|
287
|
+
|
|
288
|
+
return stdlib_complex64( re, im );
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// ...
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Receives JavaScript callback invocation data.
|
|
295
|
+
*
|
|
296
|
+
* @param env environment under which the function is invoked
|
|
297
|
+
* @param info callback data
|
|
298
|
+
* @return Node-API value
|
|
299
|
+
*/
|
|
300
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
301
|
+
return stdlib_math_base_napi_cc_c( env, info, add );
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// ...
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
The function accepts the following arguments:
|
|
308
|
+
|
|
309
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
310
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
311
|
+
- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t )` binary function.
|
|
312
|
+
|
|
313
|
+
```c
|
|
314
|
+
void stdlib_math_base_napi_cc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t ) );
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
#### stdlib_math_base_napi_di_d( env, info, fcn )
|
|
318
|
+
|
|
319
|
+
Invokes a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number.
|
|
320
|
+
|
|
321
|
+
```c
|
|
322
|
+
#include <node_api.h>
|
|
323
|
+
#include <stdint.h>
|
|
324
|
+
|
|
325
|
+
// ...
|
|
326
|
+
|
|
327
|
+
static double mul( const double x, const int32_t y ) {
|
|
328
|
+
return x * y;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// ...
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Receives JavaScript callback invocation data.
|
|
335
|
+
*
|
|
336
|
+
* @param env environment under which the function is invoked
|
|
337
|
+
* @param info callback data
|
|
338
|
+
* @return Node-API value
|
|
339
|
+
*/
|
|
340
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
341
|
+
return stdlib_math_base_napi_di_d( env, info, mul );
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// ...
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
The function accepts the following arguments:
|
|
348
|
+
|
|
349
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
350
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
351
|
+
- **fcn**: `[in] double (*fcn)( double, int32_t )` binary function.
|
|
352
|
+
|
|
353
|
+
```c
|
|
354
|
+
void stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) );
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
#### stdlib_math_base_napi_fi_f( env, info, fcn )
|
|
358
|
+
|
|
359
|
+
Invokes a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number.
|
|
360
|
+
|
|
361
|
+
```c
|
|
362
|
+
#include <node_api.h>
|
|
363
|
+
#include <stdint.h>
|
|
364
|
+
|
|
365
|
+
// ...
|
|
366
|
+
|
|
367
|
+
static float mulf( const float x, const int32_t y ) {
|
|
368
|
+
return x * y;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
// ...
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Receives JavaScript callback invocation data.
|
|
375
|
+
*
|
|
376
|
+
* @param env environment under which the function is invoked
|
|
377
|
+
* @param info callback data
|
|
378
|
+
* @return Node-API value
|
|
379
|
+
*/
|
|
380
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
381
|
+
return stdlib_math_base_napi_fi_f( env, info, mulf );
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// ...
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
The function accepts the following arguments:
|
|
388
|
+
|
|
389
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
390
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
391
|
+
- **fcn**: `[in] float (*fcn)( float, int32_t )` binary function.
|
|
392
|
+
|
|
393
|
+
```c
|
|
394
|
+
void stdlib_math_base_napi_fi_f( napi_env env, napi_callback_info info, float (*fcn)( float, int32_t ) );
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
#### stdlib_math_base_napi_zi_z( env, info, fcn )
|
|
398
|
+
|
|
399
|
+
Invokes a binary function accepting a double-precision complex floating-point number and a signed 32-bit integer and returning a double-precision complex floating-point number.
|
|
400
|
+
|
|
401
|
+
```c
|
|
402
|
+
#include "stdlib/complex/float64.h"
|
|
403
|
+
#include "stdlib/complex/reim.h"
|
|
404
|
+
#include <node_api.h>
|
|
405
|
+
#include <stdint.h>
|
|
406
|
+
|
|
407
|
+
// ...
|
|
408
|
+
|
|
409
|
+
static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) {
|
|
410
|
+
double xre;
|
|
411
|
+
double xim;
|
|
412
|
+
double re;
|
|
413
|
+
double im;
|
|
414
|
+
|
|
415
|
+
stdlib_reim( x, &xre, &xim );
|
|
416
|
+
|
|
417
|
+
re = xre * y;
|
|
418
|
+
im = xim * y;
|
|
419
|
+
|
|
420
|
+
return stdlib_complex128( re, im );
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// ...
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Receives JavaScript callback invocation data.
|
|
427
|
+
*
|
|
428
|
+
* @param env environment under which the function is invoked
|
|
429
|
+
* @param info callback data
|
|
430
|
+
* @return Node-API value
|
|
431
|
+
*/
|
|
432
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
433
|
+
return stdlib_math_base_napi_zi_z( env, info, mul );
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
// ...
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
The function accepts the following arguments:
|
|
440
|
+
|
|
441
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
442
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
443
|
+
- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t )` binary function.
|
|
444
|
+
|
|
445
|
+
```c
|
|
446
|
+
void stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t ) );
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
#### stdlib_math_base_napi_ci_c( env, info, fcn )
|
|
450
|
+
|
|
451
|
+
Invokes a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number.
|
|
452
|
+
|
|
453
|
+
```c
|
|
454
|
+
#include "stdlib/complex/float64.h"
|
|
455
|
+
#include "stdlib/complex/reimf.h"
|
|
456
|
+
#include <node_api.h>
|
|
457
|
+
#include <stdint.h>
|
|
458
|
+
|
|
459
|
+
// ...
|
|
460
|
+
|
|
461
|
+
static stdlib_complex64_t mul( const stdlib_complex64_t x, const int32_t y ) {
|
|
462
|
+
float xre;
|
|
463
|
+
float xim;
|
|
464
|
+
float re;
|
|
465
|
+
float im;
|
|
466
|
+
|
|
467
|
+
stdlib_reimf( x, &xre, &xim );
|
|
468
|
+
|
|
469
|
+
re = xre * y;
|
|
470
|
+
im = xim * y;
|
|
471
|
+
|
|
472
|
+
return stdlib_complex64( re, im );
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
// ...
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Receives JavaScript callback invocation data.
|
|
479
|
+
*
|
|
480
|
+
* @param env environment under which the function is invoked
|
|
481
|
+
* @param info callback data
|
|
482
|
+
* @return Node-API value
|
|
483
|
+
*/
|
|
484
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
485
|
+
return stdlib_math_base_napi_ci_c( env, info, mul );
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// ...
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
The function accepts the following arguments:
|
|
492
|
+
|
|
493
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
494
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
495
|
+
- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t )` binary function.
|
|
496
|
+
|
|
497
|
+
```c
|
|
498
|
+
void stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) );
|
|
205
499
|
```
|
|
206
500
|
|
|
207
501
|
#### STDLIB_MATH_BASE_NAPI_MODULE_DD_D( fcn )
|
|
@@ -246,6 +540,264 @@ The macro expects the following arguments:
|
|
|
246
540
|
|
|
247
541
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
248
542
|
|
|
543
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( fcn )
|
|
544
|
+
|
|
545
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning double-precision complex floating-point numbers.
|
|
546
|
+
|
|
547
|
+
```c
|
|
548
|
+
#include "stdlib/complex/float64.h"
|
|
549
|
+
#include "stdlib/complex/reim.h"
|
|
550
|
+
|
|
551
|
+
static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y ) {
|
|
552
|
+
double xre;
|
|
553
|
+
double xim;
|
|
554
|
+
double yre;
|
|
555
|
+
double yim;
|
|
556
|
+
double re;
|
|
557
|
+
double im;
|
|
558
|
+
|
|
559
|
+
stdlib_reim( x, &xre, &xim );
|
|
560
|
+
stdlib_reim( y, &yre, &yim );
|
|
561
|
+
|
|
562
|
+
re = xre + yre;
|
|
563
|
+
im = xim + yim;
|
|
564
|
+
|
|
565
|
+
return stdlib_complex128( re, im );
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// ...
|
|
569
|
+
|
|
570
|
+
// Register a Node-API module:
|
|
571
|
+
STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( add );
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
The macro expects the following arguments:
|
|
575
|
+
|
|
576
|
+
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t )` binary function.
|
|
577
|
+
|
|
578
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
579
|
+
|
|
580
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_CC_C( fcn )
|
|
581
|
+
|
|
582
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning single-precision complex floating-point numbers.
|
|
583
|
+
|
|
584
|
+
```c
|
|
585
|
+
#include "stdlib/complex/float32.h"
|
|
586
|
+
#include "stdlib/complex/reimf.h"
|
|
587
|
+
|
|
588
|
+
static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y ) {
|
|
589
|
+
float xre;
|
|
590
|
+
float xim;
|
|
591
|
+
float yre;
|
|
592
|
+
float yim;
|
|
593
|
+
float re;
|
|
594
|
+
float im;
|
|
595
|
+
|
|
596
|
+
stdlib_reimf( x, &xre, &xim );
|
|
597
|
+
stdlib_reimf( y, &yre, &yim );
|
|
598
|
+
|
|
599
|
+
re = xre + yre;
|
|
600
|
+
im = xim + yim;
|
|
601
|
+
|
|
602
|
+
return stdlib_complex64( re, im );
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// ...
|
|
606
|
+
|
|
607
|
+
// Register a Node-API module:
|
|
608
|
+
STDLIB_MATH_BASE_NAPI_MODULE_CC_C( add );
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
The macro expects the following arguments:
|
|
612
|
+
|
|
613
|
+
- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t )` binary function.
|
|
614
|
+
|
|
615
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
616
|
+
|
|
617
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_DI_D( fcn )
|
|
618
|
+
|
|
619
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number.
|
|
620
|
+
|
|
621
|
+
```c
|
|
622
|
+
#include <stdint.h>
|
|
623
|
+
|
|
624
|
+
static double mul( const double x, const int32_t y ) {
|
|
625
|
+
return x * y;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
// ...
|
|
629
|
+
|
|
630
|
+
// Register a Node-API module:
|
|
631
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DI_D( mul );
|
|
632
|
+
```
|
|
633
|
+
|
|
634
|
+
The macro expects the following arguments:
|
|
635
|
+
|
|
636
|
+
- **fcn**: `double (*fcn)( double, int32_t )` binary function.
|
|
637
|
+
|
|
638
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
639
|
+
|
|
640
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_FI_F( fcn )
|
|
641
|
+
|
|
642
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number.
|
|
643
|
+
|
|
644
|
+
```c
|
|
645
|
+
#include <stdint.h>
|
|
646
|
+
|
|
647
|
+
static float mulf( const float x, const int32_t y ) {
|
|
648
|
+
return x * y;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// ...
|
|
652
|
+
|
|
653
|
+
// Register a Node-API module:
|
|
654
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FI_F( mulf );
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
The macro expects the following arguments:
|
|
658
|
+
|
|
659
|
+
- **fcn**: `float (*fcn)( float, int32_t )` binary function.
|
|
660
|
+
|
|
661
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
662
|
+
|
|
663
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( fcn )
|
|
664
|
+
|
|
665
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a signed 32-bit and returning a double-precision complex floating-point number.
|
|
666
|
+
|
|
667
|
+
```c
|
|
668
|
+
#include "stdlib/complex/float64.h"
|
|
669
|
+
#include "stdlib/complex/reim.h"
|
|
670
|
+
#include <stdint.h>
|
|
671
|
+
|
|
672
|
+
static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) {
|
|
673
|
+
double xre;
|
|
674
|
+
double xim;
|
|
675
|
+
double re;
|
|
676
|
+
double im;
|
|
677
|
+
|
|
678
|
+
stdlib_reim( x, &xre, &xim );
|
|
679
|
+
|
|
680
|
+
re = xre * y;
|
|
681
|
+
im = xim * y;
|
|
682
|
+
|
|
683
|
+
return stdlib_complex128( re, im );
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
// ...
|
|
687
|
+
|
|
688
|
+
// Register a Node-API module:
|
|
689
|
+
STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( mul );
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
The macro expects the following arguments:
|
|
693
|
+
|
|
694
|
+
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t )` binary function.
|
|
695
|
+
|
|
696
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
697
|
+
|
|
698
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_CI_C( fcn )
|
|
699
|
+
|
|
700
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number.
|
|
701
|
+
|
|
702
|
+
```c
|
|
703
|
+
#include "stdlib/complex/float32.h"
|
|
704
|
+
#include "stdlib/complex/reimf.h"
|
|
705
|
+
#include <stdint.h>
|
|
706
|
+
|
|
707
|
+
static stdlib_complex64_t add( const stdlib_complex64_t x, const int32_t y ) {
|
|
708
|
+
float xre;
|
|
709
|
+
float xim;
|
|
710
|
+
float re;
|
|
711
|
+
float im;
|
|
712
|
+
|
|
713
|
+
stdlib_reimf( x, &xre, &xim );
|
|
714
|
+
|
|
715
|
+
re = xre * y;
|
|
716
|
+
im = xim * y;
|
|
717
|
+
|
|
718
|
+
return stdlib_complex64( re, im );
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
// ...
|
|
722
|
+
|
|
723
|
+
// Register a Node-API module:
|
|
724
|
+
STDLIB_MATH_BASE_NAPI_MODULE_CI_C( add );
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
The macro expects the following arguments:
|
|
728
|
+
|
|
729
|
+
- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t )` binary function.
|
|
730
|
+
|
|
731
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
732
|
+
|
|
733
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( fcn )
|
|
734
|
+
|
|
735
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number.
|
|
736
|
+
|
|
737
|
+
```c
|
|
738
|
+
#include "stdlib/complex/float64.h"
|
|
739
|
+
#include "stdlib/complex/reim.h"
|
|
740
|
+
|
|
741
|
+
static stdlib_complex128_t mul( const stdlib_complex128_t x, const double y ) {
|
|
742
|
+
double xre;
|
|
743
|
+
double xim;
|
|
744
|
+
double re;
|
|
745
|
+
double im;
|
|
746
|
+
|
|
747
|
+
stdlib_reim( x, &xre, &xim );
|
|
748
|
+
|
|
749
|
+
re = xre * y;
|
|
750
|
+
im = xim * y;
|
|
751
|
+
|
|
752
|
+
return stdlib_complex128( re, im );
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
// ...
|
|
756
|
+
|
|
757
|
+
// Register a Node-API module:
|
|
758
|
+
STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( mul );
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
The macro expects the following arguments:
|
|
762
|
+
|
|
763
|
+
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, double )` binary function.
|
|
764
|
+
|
|
765
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
766
|
+
|
|
767
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_CF_C( fcn )
|
|
768
|
+
|
|
769
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number.
|
|
770
|
+
|
|
771
|
+
```c
|
|
772
|
+
#include "stdlib/complex/float32.h"
|
|
773
|
+
#include "stdlib/complex/reimf.h"
|
|
774
|
+
|
|
775
|
+
static stdlib_complex64_t add( const stdlib_complex64_t x, const float y ) {
|
|
776
|
+
float xre;
|
|
777
|
+
float xim;
|
|
778
|
+
float re;
|
|
779
|
+
float im;
|
|
780
|
+
|
|
781
|
+
stdlib_reimf( x, &xre, &xim );
|
|
782
|
+
|
|
783
|
+
re = xre * y;
|
|
784
|
+
im = xim * y;
|
|
785
|
+
|
|
786
|
+
return stdlib_complex64( re, im );
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// ...
|
|
790
|
+
|
|
791
|
+
// Register a Node-API module:
|
|
792
|
+
STDLIB_MATH_BASE_NAPI_MODULE_CF_C( add );
|
|
793
|
+
```
|
|
794
|
+
|
|
795
|
+
The macro expects the following arguments:
|
|
796
|
+
|
|
797
|
+
- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, float )` binary function.
|
|
798
|
+
|
|
799
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
800
|
+
|
|
249
801
|
</section>
|
|
250
802
|
|
|
251
803
|
<!-- /.usage -->
|
|
@@ -285,6 +837,14 @@ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro inc
|
|
|
285
837
|
|
|
286
838
|
<!-- /.references -->
|
|
287
839
|
|
|
840
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
841
|
+
|
|
842
|
+
<section class="related">
|
|
843
|
+
|
|
844
|
+
</section>
|
|
845
|
+
|
|
846
|
+
<!-- /.related -->
|
|
847
|
+
|
|
288
848
|
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
289
849
|
|
|
290
850
|
|
|
@@ -311,7 +871,7 @@ See [LICENSE][stdlib-license].
|
|
|
311
871
|
|
|
312
872
|
## Copyright
|
|
313
873
|
|
|
314
|
-
Copyright © 2016-
|
|
874
|
+
Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
315
875
|
|
|
316
876
|
</section>
|
|
317
877
|
|
|
@@ -324,17 +884,21 @@ Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors].
|
|
|
324
884
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/math-base-napi-binary.svg
|
|
325
885
|
[npm-url]: https://npmjs.org/package/@stdlib/math-base-napi-binary
|
|
326
886
|
|
|
327
|
-
[test-image]: https://github.com/stdlib-js/math-base-napi-binary/actions/workflows/test.yml/badge.svg
|
|
328
|
-
[test-url]: https://github.com/stdlib-js/math-base-napi-binary/actions/workflows/test.yml
|
|
887
|
+
[test-image]: https://github.com/stdlib-js/math-base-napi-binary/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
888
|
+
[test-url]: https://github.com/stdlib-js/math-base-napi-binary/actions/workflows/test.yml?query=branch:v0.1.0
|
|
329
889
|
|
|
330
890
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-napi-binary/main.svg
|
|
331
891
|
[coverage-url]: https://codecov.io/github/stdlib-js/math-base-napi-binary?branch=main
|
|
332
892
|
|
|
893
|
+
<!--
|
|
894
|
+
|
|
333
895
|
[dependencies-image]: https://img.shields.io/david/stdlib-js/math-base-napi-binary.svg
|
|
334
896
|
[dependencies-url]: https://david-dm.org/stdlib-js/math-base-napi-binary/main
|
|
335
897
|
|
|
898
|
+
-->
|
|
899
|
+
|
|
336
900
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
337
|
-
[chat-url]: https://gitter.im
|
|
901
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
338
902
|
|
|
339
903
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
340
904
|
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var a=function(s,e){return function(){return e||s((e={exports:{}}).exports,e),e.exports}};var i=a(function(c,r){
|
|
2
|
+
var t=require("path").resolve,u=t(__dirname,"..","include");r.exports=u
|
|
3
|
+
});var v=i();module.exports=v;
|
|
4
|
+
/** @license Apache-2.0 */
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolve = require( 'path' ).resolve;\n\n\n// MAIN //\n\n/**\n* Absolute file path for the directory containing header files for C APIs.\n*\n* @name headerDir\n* @constant\n* @type {string}\n*/\nvar headerDir = resolve( __dirname, '..', 'include' );\n\n\n// EXPORTS //\n\nmodule.exports = headerDir;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Absolute file path for the directory containing header files for C APIs.\n*\n* @module @stdlib/math-base-napi-binary\n*\n* @example\n* var headerDir = require( '@stdlib/math-base-napi-binary' );\n*\n* console.log( headerDir );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,MAAO,EAAE,QAY5BC,EAAYD,EAAS,UAAW,KAAM,SAAU,EAKpDD,EAAO,QAAUE,ICNjB,IAAIC,EAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "resolve", "headerDir", "main"]
|
|
7
|
+
}
|