@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.
@@ -19,6 +19,8 @@
19
19
  #ifndef STDLIB_MATH_BASE_NAPI_BINARY_H
20
20
  #define STDLIB_MATH_BASE_NAPI_BINARY_H
21
21
 
22
+ #include "stdlib/complex/float32.h"
23
+ #include "stdlib/complex/float64.h"
22
24
  #include <node_api.h>
23
25
  #include <assert.h>
24
26
 
@@ -102,6 +104,392 @@
102
104
  }; \
103
105
  NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ff_f_init )
104
106
 
107
+ /**
108
+ * Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning double-precision complex floating-point numbers.
109
+ *
110
+ * @param fcn binary function
111
+ *
112
+ * @example
113
+ * #include "stdlib/complex/float64.h"
114
+ * #include "stdlib/complex/reim.h"
115
+ *
116
+ * static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y ) {
117
+ * double xre;
118
+ * double xim;
119
+ * double yre;
120
+ * double yim;
121
+ * double re;
122
+ * double im;
123
+ *
124
+ * stdlib_reim( x, &xre, &xim );
125
+ * stdlib_reim( y, &yre, &yim );
126
+ *
127
+ * re = xre + yre;
128
+ * im = xim + yim;
129
+ *
130
+ * return stdlib_complex128( re, im );
131
+ * }
132
+ *
133
+ * // ...
134
+ *
135
+ * // Register a Node-API module:
136
+ * STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( add );
137
+ */
138
+ #define STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( fcn ) \
139
+ static napi_value stdlib_math_base_napi_zz_z_wrapper( \
140
+ napi_env env, \
141
+ napi_callback_info info \
142
+ ) { \
143
+ return stdlib_math_base_napi_zz_z( env, info, fcn ); \
144
+ }; \
145
+ static napi_value stdlib_math_base_napi_zz_z_init( \
146
+ napi_env env, \
147
+ napi_value exports \
148
+ ) { \
149
+ napi_value fcn; \
150
+ napi_status status = napi_create_function( \
151
+ env, \
152
+ "exports", \
153
+ NAPI_AUTO_LENGTH, \
154
+ stdlib_math_base_napi_zz_z_wrapper, \
155
+ NULL, \
156
+ &fcn \
157
+ ); \
158
+ assert( status == napi_ok ); \
159
+ return fcn; \
160
+ }; \
161
+ NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zz_z_init )
162
+
163
+ /**
164
+ * Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning single-precision complex floating-point numbers.
165
+ *
166
+ * @param fcn binary function
167
+ *
168
+ * @example
169
+ * #include "stdlib/complex/float32.h"
170
+ * #include "stdlib/complex/reimf.h"
171
+ *
172
+ * static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y ) {
173
+ * float xre;
174
+ * float xim;
175
+ * float yre;
176
+ * float yim;
177
+ * float re;
178
+ * float im;
179
+ *
180
+ * stdlib_reimf( x, &xre, &xim );
181
+ * stdlib_reimf( y, &yre, &yim );
182
+ *
183
+ * re = xre + yre;
184
+ * im = xim + yim;
185
+ *
186
+ * return stdlib_complex64( re, im );
187
+ * }
188
+ *
189
+ * // ...
190
+ *
191
+ * // Register a Node-API module:
192
+ * STDLIB_MATH_BASE_NAPI_MODULE_CC_C( add );
193
+ */
194
+ #define STDLIB_MATH_BASE_NAPI_MODULE_CC_C( fcn ) \
195
+ static napi_value stdlib_math_base_napi_cc_c_wrapper( \
196
+ napi_env env, \
197
+ napi_callback_info info \
198
+ ) { \
199
+ return stdlib_math_base_napi_cc_c( env, info, fcn ); \
200
+ }; \
201
+ static napi_value stdlib_math_base_napi_cc_c_init( \
202
+ napi_env env, \
203
+ napi_value exports \
204
+ ) { \
205
+ napi_value fcn; \
206
+ napi_status status = napi_create_function( \
207
+ env, \
208
+ "exports", \
209
+ NAPI_AUTO_LENGTH, \
210
+ stdlib_math_base_napi_cc_c_wrapper, \
211
+ NULL, \
212
+ &fcn \
213
+ ); \
214
+ assert( status == napi_ok ); \
215
+ return fcn; \
216
+ }; \
217
+ NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_cc_c_init )
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
+
105
493
  /*
106
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.
107
495
  */
@@ -119,6 +507,46 @@ napi_value stdlib_math_base_napi_dd_d( napi_env env, napi_callback_info info, do
119
507
  */
120
508
  napi_value stdlib_math_base_napi_ff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float ) );
121
509
 
510
+ /**
511
+ * Invokes a binary function accepting and returning double-precision complex floating-point numbers.
512
+ */
513
+ napi_value stdlib_math_base_napi_zz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t ) );
514
+
515
+ /**
516
+ * Invokes a binary function accepting and returning single-precision complex floating-point numbers.
517
+ */
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 ) );
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
+
122
550
  #ifdef __cplusplus
123
551
  }
124
552
  #endif
package/lib/index.js CHANGED
@@ -31,9 +31,9 @@
31
31
 
32
32
  // MODULES //
33
33
 
34
- var headerDir = require( './main.js' );
34
+ var main = require( './main.js' );
35
35
 
36
36
 
37
37
  // EXPORTS //
38
38
 
39
- module.exports = headerDir;
39
+ module.exports = main;
package/manifest.json CHANGED
@@ -32,7 +32,12 @@
32
32
  ],
33
33
  "libraries": [],
34
34
  "libpath": [],
35
- "dependencies": []
35
+ "dependencies": [
36
+ "@stdlib/complex-float32",
37
+ "@stdlib/complex-float64",
38
+ "@stdlib/complex-reim",
39
+ "@stdlib/complex-reimf"
40
+ ]
36
41
  }
37
42
  ]
38
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/math-base-napi-binary",
3
- "version": "0.0.7",
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,16 +41,20 @@
41
41
  "url": "https://github.com/stdlib-js/stdlib/issues"
42
42
  },
43
43
  "dependencies": {
44
- "@stdlib/utils-library-manifest": "^0.0.x"
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"
45
49
  },
46
50
  "devDependencies": {
47
- "@stdlib/assert-is-browser": "^0.0.x",
48
- "@stdlib/bench": "^0.0.x",
49
- "@stdlib/math-base-assert-is-nan": "^0.0.x",
50
- "@stdlib/utils-try-require": "^0.0.x",
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",
51
55
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
52
56
  "istanbul": "^0.4.1",
53
- "tap-spec": "5.x.x"
57
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
54
58
  },
55
59
  "engines": {
56
60
  "node": ">=0.10.0",
@@ -80,9 +84,13 @@
80
84
  "map",
81
85
  "transform"
82
86
  ],
83
- "__stdlib__": {},
87
+ "__stdlib__": {
88
+ "envs": {
89
+ "browser": false
90
+ }
91
+ },
84
92
  "funding": {
85
- "type": "patreon",
86
- "url": "https://www.patreon.com/athan"
93
+ "type": "opencollective",
94
+ "url": "https://opencollective.com/stdlib"
87
95
  }
88
96
  }