@stdlib/math-base-napi-binary 0.0.8 → 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 +383 -11
- 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 +304 -0
- package/lib/index.js +2 -2
- package/package.json +18 -14
- package/src/main.c +600 -0
- package/docs/types/test.ts +0 -28
|
@@ -216,6 +216,280 @@
|
|
|
216
216
|
}; \
|
|
217
217
|
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_cc_c_init )
|
|
218
218
|
|
|
219
|
+
/**
|
|
220
|
+
* 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.
|
|
221
|
+
*
|
|
222
|
+
* @param fcn binary function
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* #include <stdint.h>
|
|
226
|
+
*
|
|
227
|
+
* static double mul( const double x, const int32_t n ) {
|
|
228
|
+
* return x * n;
|
|
229
|
+
* }
|
|
230
|
+
*
|
|
231
|
+
* // ...
|
|
232
|
+
*
|
|
233
|
+
* // Register a Node-API module:
|
|
234
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_DI_D( mul );
|
|
235
|
+
*/
|
|
236
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_DI_D( fcn ) \
|
|
237
|
+
static napi_value stdlib_math_base_napi_di_d_wrapper( \
|
|
238
|
+
napi_env env, \
|
|
239
|
+
napi_callback_info info \
|
|
240
|
+
) { \
|
|
241
|
+
return stdlib_math_base_napi_di_d( env, info, fcn ); \
|
|
242
|
+
}; \
|
|
243
|
+
static napi_value stdlib_math_base_napi_di_d_init( \
|
|
244
|
+
napi_env env, \
|
|
245
|
+
napi_value exports \
|
|
246
|
+
) { \
|
|
247
|
+
napi_value fcn; \
|
|
248
|
+
napi_status status = napi_create_function( \
|
|
249
|
+
env, \
|
|
250
|
+
"exports", \
|
|
251
|
+
NAPI_AUTO_LENGTH, \
|
|
252
|
+
stdlib_math_base_napi_di_d_wrapper, \
|
|
253
|
+
NULL, \
|
|
254
|
+
&fcn \
|
|
255
|
+
); \
|
|
256
|
+
assert( status == napi_ok ); \
|
|
257
|
+
return fcn; \
|
|
258
|
+
}; \
|
|
259
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_di_d_init )
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* 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.
|
|
263
|
+
*
|
|
264
|
+
* @param fcn binary function
|
|
265
|
+
*
|
|
266
|
+
* @example
|
|
267
|
+
* #include <stdint.h>
|
|
268
|
+
*
|
|
269
|
+
* static float mulf( const float x, const int32_t n ) {
|
|
270
|
+
* return x * n;
|
|
271
|
+
* }
|
|
272
|
+
*
|
|
273
|
+
* // ...
|
|
274
|
+
*
|
|
275
|
+
* // Register a Node-API module:
|
|
276
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_FI_F( mulf );
|
|
277
|
+
*/
|
|
278
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_FI_F( fcn ) \
|
|
279
|
+
static napi_value stdlib_math_base_napi_fi_f_wrapper( \
|
|
280
|
+
napi_env env, \
|
|
281
|
+
napi_callback_info info \
|
|
282
|
+
) { \
|
|
283
|
+
return stdlib_math_base_napi_fi_f( env, info, fcn ); \
|
|
284
|
+
}; \
|
|
285
|
+
static napi_value stdlib_math_base_napi_fi_f_init( \
|
|
286
|
+
napi_env env, \
|
|
287
|
+
napi_value exports \
|
|
288
|
+
) { \
|
|
289
|
+
napi_value fcn; \
|
|
290
|
+
napi_status status = napi_create_function( \
|
|
291
|
+
env, \
|
|
292
|
+
"exports", \
|
|
293
|
+
NAPI_AUTO_LENGTH, \
|
|
294
|
+
stdlib_math_base_napi_fi_f_wrapper, \
|
|
295
|
+
NULL, \
|
|
296
|
+
&fcn \
|
|
297
|
+
); \
|
|
298
|
+
assert( status == napi_ok ); \
|
|
299
|
+
return fcn; \
|
|
300
|
+
}; \
|
|
301
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_fi_f_init )
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* 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.
|
|
305
|
+
*
|
|
306
|
+
* @param fcn binary function
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* #include "stdlib/complex/float64.h"
|
|
310
|
+
* #include "stdlib/complex/reim.h"
|
|
311
|
+
* #include <stdint.h>
|
|
312
|
+
*
|
|
313
|
+
* static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t n ) {
|
|
314
|
+
* double re;
|
|
315
|
+
* double im;
|
|
316
|
+
*
|
|
317
|
+
* stdlib_reim( x, &re, &im );
|
|
318
|
+
* return stdlib_complex128( re*n, im*n );
|
|
319
|
+
* }
|
|
320
|
+
*
|
|
321
|
+
* // ...
|
|
322
|
+
*
|
|
323
|
+
* // Register a Node-API module:
|
|
324
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( mul );
|
|
325
|
+
*/
|
|
326
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( fcn ) \
|
|
327
|
+
static napi_value stdlib_math_base_napi_zi_z_wrapper( \
|
|
328
|
+
napi_env env, \
|
|
329
|
+
napi_callback_info info \
|
|
330
|
+
) { \
|
|
331
|
+
return stdlib_math_base_napi_zi_z( env, info, fcn ); \
|
|
332
|
+
}; \
|
|
333
|
+
static napi_value stdlib_math_base_napi_zi_z_init( \
|
|
334
|
+
napi_env env, \
|
|
335
|
+
napi_value exports \
|
|
336
|
+
) { \
|
|
337
|
+
napi_value fcn; \
|
|
338
|
+
napi_status status = napi_create_function( \
|
|
339
|
+
env, \
|
|
340
|
+
"exports", \
|
|
341
|
+
NAPI_AUTO_LENGTH, \
|
|
342
|
+
stdlib_math_base_napi_zi_z_wrapper, \
|
|
343
|
+
NULL, \
|
|
344
|
+
&fcn \
|
|
345
|
+
); \
|
|
346
|
+
assert( status == napi_ok ); \
|
|
347
|
+
return fcn; \
|
|
348
|
+
}; \
|
|
349
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zi_z_init )
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* 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.
|
|
353
|
+
*
|
|
354
|
+
* @param fcn binary function
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* #include "stdlib/complex/float32.h"
|
|
358
|
+
* #include "stdlib/complex/reimf.h"
|
|
359
|
+
* #include <stdint.h>
|
|
360
|
+
*
|
|
361
|
+
* static stdlib_complex64_t mul( const stdlib_complex64_t x, const int32_t n ) {
|
|
362
|
+
* float re;
|
|
363
|
+
* float im;
|
|
364
|
+
*
|
|
365
|
+
* stdlib_reimf( x, &re, &im );
|
|
366
|
+
* return stdlib_complex64( re*n, im*n );
|
|
367
|
+
* }
|
|
368
|
+
*
|
|
369
|
+
* // ...
|
|
370
|
+
*
|
|
371
|
+
* // Register a Node-API module:
|
|
372
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_CI_C( mul );
|
|
373
|
+
*/
|
|
374
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_CI_C( fcn ) \
|
|
375
|
+
static napi_value stdlib_math_base_napi_ci_c_wrapper( \
|
|
376
|
+
napi_env env, \
|
|
377
|
+
napi_callback_info info \
|
|
378
|
+
) { \
|
|
379
|
+
return stdlib_math_base_napi_ci_c( env, info, fcn ); \
|
|
380
|
+
}; \
|
|
381
|
+
static napi_value stdlib_math_base_napi_ci_c_init( \
|
|
382
|
+
napi_env env, \
|
|
383
|
+
napi_value exports \
|
|
384
|
+
) { \
|
|
385
|
+
napi_value fcn; \
|
|
386
|
+
napi_status status = napi_create_function( \
|
|
387
|
+
env, \
|
|
388
|
+
"exports", \
|
|
389
|
+
NAPI_AUTO_LENGTH, \
|
|
390
|
+
stdlib_math_base_napi_ci_c_wrapper, \
|
|
391
|
+
NULL, \
|
|
392
|
+
&fcn \
|
|
393
|
+
); \
|
|
394
|
+
assert( status == napi_ok ); \
|
|
395
|
+
return fcn; \
|
|
396
|
+
}; \
|
|
397
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ci_c_init )
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* 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.
|
|
401
|
+
*
|
|
402
|
+
* @param fcn binary function
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* #include "stdlib/complex/float64.h"
|
|
406
|
+
* #include "stdlib/complex/reim.h"
|
|
407
|
+
*
|
|
408
|
+
* static stdlib_complex128_t mul( const stdlib_complex128_t x, const double n ) {
|
|
409
|
+
* double re;
|
|
410
|
+
* double im;
|
|
411
|
+
*
|
|
412
|
+
* stdlib_reim( x, &re, &im );
|
|
413
|
+
* return stdlib_complex128( re*n, im*n );
|
|
414
|
+
* }
|
|
415
|
+
*
|
|
416
|
+
* // ...
|
|
417
|
+
*
|
|
418
|
+
* // Register a Node-API module:
|
|
419
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( mul );
|
|
420
|
+
*/
|
|
421
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( fcn ) \
|
|
422
|
+
static napi_value stdlib_math_base_napi_zd_z_wrapper( \
|
|
423
|
+
napi_env env, \
|
|
424
|
+
napi_callback_info info \
|
|
425
|
+
) { \
|
|
426
|
+
return stdlib_math_base_napi_zd_z( env, info, fcn ); \
|
|
427
|
+
}; \
|
|
428
|
+
static napi_value stdlib_math_base_napi_zd_z_init( \
|
|
429
|
+
napi_env env, \
|
|
430
|
+
napi_value exports \
|
|
431
|
+
) { \
|
|
432
|
+
napi_value fcn; \
|
|
433
|
+
napi_status status = napi_create_function( \
|
|
434
|
+
env, \
|
|
435
|
+
"exports", \
|
|
436
|
+
NAPI_AUTO_LENGTH, \
|
|
437
|
+
stdlib_math_base_napi_zd_z_wrapper, \
|
|
438
|
+
NULL, \
|
|
439
|
+
&fcn \
|
|
440
|
+
); \
|
|
441
|
+
assert( status == napi_ok ); \
|
|
442
|
+
return fcn; \
|
|
443
|
+
}; \
|
|
444
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zd_z_init )
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* 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.
|
|
448
|
+
*
|
|
449
|
+
* @param fcn binary function
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
* #include "stdlib/complex/float32.h"
|
|
453
|
+
* #include "stdlib/complex/reimf.h"
|
|
454
|
+
*
|
|
455
|
+
* static stdlib_complex64_t mul( const stdlib_complex64_t x, const float n ) {
|
|
456
|
+
* float re;
|
|
457
|
+
* float im;
|
|
458
|
+
*
|
|
459
|
+
* stdlib_reimf( x, &re, &im );
|
|
460
|
+
* return stdlib_complex64( re*n, im*n );
|
|
461
|
+
* }
|
|
462
|
+
*
|
|
463
|
+
* // ...
|
|
464
|
+
*
|
|
465
|
+
* // Register a Node-API module:
|
|
466
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_CF_C( mul );
|
|
467
|
+
*/
|
|
468
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_CF_C( fcn ) \
|
|
469
|
+
static napi_value stdlib_math_base_napi_cf_c_wrapper( \
|
|
470
|
+
napi_env env, \
|
|
471
|
+
napi_callback_info info \
|
|
472
|
+
) { \
|
|
473
|
+
return stdlib_math_base_napi_cf_c( env, info, fcn ); \
|
|
474
|
+
}; \
|
|
475
|
+
static napi_value stdlib_math_base_napi_cf_c_init( \
|
|
476
|
+
napi_env env, \
|
|
477
|
+
napi_value exports \
|
|
478
|
+
) { \
|
|
479
|
+
napi_value fcn; \
|
|
480
|
+
napi_status status = napi_create_function( \
|
|
481
|
+
env, \
|
|
482
|
+
"exports", \
|
|
483
|
+
NAPI_AUTO_LENGTH, \
|
|
484
|
+
stdlib_math_base_napi_cf_c_wrapper, \
|
|
485
|
+
NULL, \
|
|
486
|
+
&fcn \
|
|
487
|
+
); \
|
|
488
|
+
assert( status == napi_ok ); \
|
|
489
|
+
return fcn; \
|
|
490
|
+
}; \
|
|
491
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_cf_c_init )
|
|
492
|
+
|
|
219
493
|
/*
|
|
220
494
|
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
221
495
|
*/
|
|
@@ -243,6 +517,36 @@ napi_value stdlib_math_base_napi_zz_z( napi_env env, napi_callback_info info, st
|
|
|
243
517
|
*/
|
|
244
518
|
napi_value stdlib_math_base_napi_cc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t ) );
|
|
245
519
|
|
|
520
|
+
/**
|
|
521
|
+
* 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.
|
|
522
|
+
*/
|
|
523
|
+
napi_value stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) );
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* 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.
|
|
527
|
+
*/
|
|
528
|
+
napi_value stdlib_math_base_napi_fi_f( napi_env env, napi_callback_info info, float (*fcn)( float, int32_t ) );
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* 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.
|
|
532
|
+
*/
|
|
533
|
+
napi_value stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t ) );
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* 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.
|
|
537
|
+
*/
|
|
538
|
+
napi_value stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) );
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Invokes 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.
|
|
542
|
+
*/
|
|
543
|
+
napi_value stdlib_math_base_napi_zd_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, double ) );
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Invokes 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.
|
|
547
|
+
*/
|
|
548
|
+
napi_value stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, float ) );
|
|
549
|
+
|
|
246
550
|
#ifdef __cplusplus
|
|
247
551
|
}
|
|
248
552
|
#endif
|
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/math-base-napi-binary",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "C APIs for registering a Node-API module exporting an interface for invoking a binary numerical function.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -41,20 +41,20 @@
|
|
|
41
41
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@stdlib/complex-float32": "^0.0
|
|
45
|
-
"@stdlib/complex-float64": "^0.0
|
|
46
|
-
"@stdlib/complex-reim": "^0.0
|
|
47
|
-
"@stdlib/complex-reimf": "^0.0
|
|
48
|
-
"@stdlib/utils-library-manifest": "^0.0
|
|
44
|
+
"@stdlib/complex-float32": "^0.1.0",
|
|
45
|
+
"@stdlib/complex-float64": "^0.1.0",
|
|
46
|
+
"@stdlib/complex-reim": "^0.1.0",
|
|
47
|
+
"@stdlib/complex-reimf": "^0.1.0",
|
|
48
|
+
"@stdlib/utils-library-manifest": "^0.1.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@stdlib/assert-is-browser": "^0.0
|
|
52
|
-
"@stdlib/bench": "^0.0
|
|
53
|
-
"@stdlib/math-base-assert-is-nan": "^0.0
|
|
54
|
-
"@stdlib/utils-try-require": "^0.0
|
|
51
|
+
"@stdlib/assert-is-browser": "^0.1.0",
|
|
52
|
+
"@stdlib/bench": "^0.1.0",
|
|
53
|
+
"@stdlib/math-base-assert-is-nan": "^0.1.0",
|
|
54
|
+
"@stdlib/utils-try-require": "^0.1.0",
|
|
55
55
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
56
56
|
"istanbul": "^0.4.1",
|
|
57
|
-
"tap-
|
|
57
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
|
|
58
58
|
},
|
|
59
59
|
"engines": {
|
|
60
60
|
"node": ">=0.10.0",
|
|
@@ -84,9 +84,13 @@
|
|
|
84
84
|
"map",
|
|
85
85
|
"transform"
|
|
86
86
|
],
|
|
87
|
-
"__stdlib__": {
|
|
87
|
+
"__stdlib__": {
|
|
88
|
+
"envs": {
|
|
89
|
+
"browser": false
|
|
90
|
+
}
|
|
91
|
+
},
|
|
88
92
|
"funding": {
|
|
89
|
-
"type": "
|
|
90
|
-
"url": "https://
|
|
93
|
+
"type": "opencollective",
|
|
94
|
+
"url": "https://opencollective.com/stdlib"
|
|
91
95
|
}
|
|
92
96
|
}
|