@stdlib/math-base-napi-unary 0.0.7 → 0.0.9

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/README.md CHANGED
@@ -20,7 +20,7 @@ limitations under the License.
20
20
 
21
21
  # unary
22
22
 
23
- [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url]
23
+ [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
24
24
 
25
25
  > C APIs for registering a Node-API module exporting interfaces for invoking unary numerical functions.
26
26
 
@@ -108,16 +108,6 @@ console.log( headerDir );
108
108
 
109
109
  <!-- C usage documentation. -->
110
110
 
111
- <section class="installation">
112
-
113
- ## Installation
114
-
115
- ```bash
116
- npm install @stdlib/math-base-napi-unary
117
- ```
118
-
119
- </section>
120
-
121
111
  <section class="usage">
122
112
 
123
113
  ### Usage
@@ -204,9 +194,169 @@ The function accepts the following arguments:
204
194
  void stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) );
205
195
  ```
206
196
 
197
+ #### stdlib_math_base_napi_z_z( env, info, fcn )
198
+
199
+ Invokes a unary function accepting and returning double-precision complex floating-point numbers.
200
+
201
+ ```c
202
+ #include "stdlib/complex/float64.h"
203
+ #include <node_api.h>
204
+
205
+ // ...
206
+
207
+ static stdlib_complex128_t identity( const stdlib_complex128_t x ) {
208
+ return x;
209
+ }
210
+
211
+ // ...
212
+
213
+ /**
214
+ * Receives JavaScript callback invocation data.
215
+ *
216
+ * @param env environment under which the function is invoked
217
+ * @param info callback data
218
+ * @return Node-API value
219
+ */
220
+ napi_value addon( napi_env env, napi_callback_info info ) {
221
+ return stdlib_math_base_napi_z_z( env, info, identity );
222
+ }
223
+
224
+ // ...
225
+ ```
226
+
227
+ The function accepts the following arguments:
228
+
229
+ - **env**: `[in] napi_env` environment under which the function is invoked.
230
+ - **info**: `[in] napi_callback_info` callback data.
231
+ - **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t )` unary function.
232
+
233
+ ```c
234
+ void stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) );
235
+ ```
236
+
237
+ #### stdlib_math_base_napi_z_d( env, info, fcn )
238
+
239
+ Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number.
240
+
241
+ ```c
242
+ #include "stdlib/complex/float64.h"
243
+ #include <node_api.h>
244
+
245
+ // ...
246
+
247
+ static double fcn( const stdlib_complex128_t x ) {
248
+ // ...
249
+ }
250
+
251
+ // ...
252
+
253
+ /**
254
+ * Receives JavaScript callback invocation data.
255
+ *
256
+ * @param env environment under which the function is invoked
257
+ * @param info callback data
258
+ * @return Node-API value
259
+ */
260
+ napi_value addon( napi_env env, napi_callback_info info ) {
261
+ return stdlib_math_base_napi_z_d( env, info, fcn );
262
+ }
263
+
264
+ // ...
265
+ ```
266
+
267
+ The function accepts the following arguments:
268
+
269
+ - **env**: `[in] napi_env` environment under which the function is invoked.
270
+ - **info**: `[in] napi_callback_info` callback data.
271
+ - **fcn**: `[in] double (*fcn)( stdlib_complex128_t )` unary function.
272
+
273
+ ```c
274
+ void stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) );
275
+ ```
276
+
277
+ #### stdlib_math_base_napi_c_c( env, info, fcn )
278
+
279
+ Invokes a unary function accepting and returning single-precision complex floating-point numbers.
280
+
281
+ ```c
282
+ #include "stdlib/complex/float32.h"
283
+ #include <node_api.h>
284
+
285
+ // ...
286
+
287
+ static stdlib_complex64_t identity( const stdlib_complex64_t x ) {
288
+ return x;
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_c_c( env, info, identity );
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 )` unary function.
312
+
313
+ ```c
314
+ void stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) );
315
+ ```
316
+
317
+ #### stdlib_math_base_napi_c_f( env, info, fcn )
318
+
319
+ Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number.
320
+
321
+ ```c
322
+ #include "stdlib/complex/float32.h"
323
+ #include <node_api.h>
324
+
325
+ // ...
326
+
327
+ static float fcn( const stdlib_complex64_t x ) {
328
+ // ...
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_c_f( env, info, fcn );
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] float (*fcn)( stdlib_complex64_t )` unary function.
352
+
353
+ ```c
354
+ void stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) );
355
+ ```
356
+
207
357
  #### stdlib_math_base_napi_i_i( env, info, fcn )
208
358
 
209
- Invokes a unary function accepting and returning 32-bit signed integers.
359
+ Invokes a unary function accepting and returning signed 32-bit integers.
210
360
 
211
361
  ```c
212
362
  #include <node_api.h>
@@ -244,6 +394,46 @@ The function accepts the following arguments:
244
394
  void stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) );
245
395
  ```
246
396
 
397
+ #### stdlib_math_base_napi_i_d( env, info, fcn )
398
+
399
+ Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number.
400
+
401
+ ```c
402
+ #include <node_api.h>
403
+ #include <stdint.h>
404
+
405
+ // ...
406
+
407
+ static double scale( const int32_t x ) {
408
+ return x * 10.0;
409
+ }
410
+
411
+ // ...
412
+
413
+ /**
414
+ * Receives JavaScript callback invocation data.
415
+ *
416
+ * @param env environment under which the function is invoked
417
+ * @param info callback data
418
+ * @return Node-API value
419
+ */
420
+ napi_value addon( napi_env env, napi_callback_info info ) {
421
+ return stdlib_math_base_napi_i_d( env, info, scale );
422
+ }
423
+
424
+ // ...
425
+ ```
426
+
427
+ The function accepts the following arguments:
428
+
429
+ - **env**: `[in] napi_env` environment under which the function is invoked.
430
+ - **info**: `[in] napi_callback_info` callback data.
431
+ - **fcn**: `[in] double (*fcn)( int32_t )` unary function.
432
+
433
+ ```c
434
+ void stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) );
435
+ ```
436
+
247
437
  #### STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn )
248
438
 
249
439
  Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision floating-point numbers.
@@ -286,6 +476,116 @@ The macro expects the following arguments:
286
476
 
287
477
  When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
288
478
 
479
+ #### STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( fcn )
480
+
481
+ Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision complex floating-point numbers.
482
+
483
+ ```c
484
+ #include "stdlib/complex/float64.h"
485
+ #include "stdlib/complex/reim.h"
486
+
487
+ static stdlib_complex128_t scale( const stdlib_complex128_t x ) {
488
+ double re;
489
+ double im;
490
+
491
+ stdlib_reim( x, &re, &im );
492
+
493
+ re *= 10.0;
494
+ im *= 10.0;
495
+
496
+ return stdlib_complex128( re, im );
497
+ }
498
+
499
+ // ...
500
+
501
+ // Register a Node-API module:
502
+ STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( scale );
503
+ ```
504
+
505
+ The macro expects the following arguments:
506
+
507
+ - **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t )` unary function.
508
+
509
+ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
510
+
511
+ #### STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn )
512
+
513
+ Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number.
514
+
515
+ ```c
516
+ #include "stdlib/complex/float64.h"
517
+
518
+ static double fcn( const stdlib_complex128_t x ) {
519
+ // ...
520
+ }
521
+
522
+ // ...
523
+
524
+ // Register a Node-API module:
525
+ STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn );
526
+ ```
527
+
528
+ The macro expects the following arguments:
529
+
530
+ - **fcn**: `double (*fcn)( stdlib_complex128_t )` unary function.
531
+
532
+ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
533
+
534
+ #### STDLIB_MATH_BASE_NAPI_MODULE_C_C( fcn )
535
+
536
+ Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning single-precision complex floating-point numbers.
537
+
538
+ ```c
539
+ #include "stdlib/complex/float32.h"
540
+ #include "stdlib/complex/reimf.h"
541
+
542
+ static stdlib_complex64_t scale( const stdlib_complex64_t x ) {
543
+ float re;
544
+ float im;
545
+
546
+ stdlib_reimf( x, &re, &im );
547
+
548
+ re *= 10.0f;
549
+ im *= 10.0f;
550
+
551
+ return stdlib_complex64( re, im );
552
+ }
553
+
554
+ // ...
555
+
556
+ // Register a Node-API module:
557
+ STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale );
558
+ ```
559
+
560
+ The macro expects the following arguments:
561
+
562
+ - **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t )` unary function.
563
+
564
+ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
565
+
566
+ #### STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn )
567
+
568
+ Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number.
569
+
570
+ ```c
571
+ #include "stdlib/complex/float32.h"
572
+
573
+ static float fcn( const stdlib_complex64_t x ) {
574
+ // ...
575
+ }
576
+
577
+ // ...
578
+
579
+ // Register a Node-API module:
580
+ STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn );
581
+ ```
582
+
583
+ The macro expects the following arguments:
584
+
585
+ - **fcn**: `float (*fcn)( stdlib_complex64_t )` unary function.
586
+
587
+ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
588
+
289
589
  #### STDLIB_MATH_BASE_NAPI_MODULE_I_I( fcn )
290
590
 
291
591
  Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 32-bit signed integers.
@@ -309,6 +609,29 @@ The macro expects the following arguments:
309
609
 
310
610
  When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
311
611
 
612
+ #### STDLIB_MATH_BASE_NAPI_MODULE_I_D( fcn )
613
+
614
+ Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a signed 32-bit integer and returning a double-precision floating-point number.
615
+
616
+ ```c
617
+ #include <stdint.h>
618
+
619
+ static double scale( const int32_t x ) {
620
+ return x * 10.0;
621
+ }
622
+
623
+ // ...
624
+
625
+ // Register a Node-API module:
626
+ STDLIB_MATH_BASE_NAPI_MODULE_I_D( scale );
627
+ ```
628
+
629
+ The macro expects the following arguments:
630
+
631
+ - **fcn**: `double (*fcn)( int32_t )` unary function.
632
+
633
+ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
634
+
312
635
  </section>
313
636
 
314
637
  <!-- /.usage -->
@@ -321,7 +644,7 @@ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro inc
321
644
 
322
645
  - The C-API functions expect that the callback `info` argument provides access to the following JavaScript arguments:
323
646
 
324
- - `x`: input value.
647
+ - **x**: input value.
325
648
 
326
649
  </section>
327
650
 
@@ -347,6 +670,14 @@ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro inc
347
670
 
348
671
  <!-- /.references -->
349
672
 
673
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
674
+
675
+ <section class="related">
676
+
677
+ </section>
678
+
679
+ <!-- /.related -->
680
+
350
681
  <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
351
682
 
352
683
 
@@ -373,7 +704,7 @@ See [LICENSE][stdlib-license].
373
704
 
374
705
  ## Copyright
375
706
 
376
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
707
+ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
377
708
 
378
709
  </section>
379
710
 
@@ -386,17 +717,21 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
386
717
  [npm-image]: http://img.shields.io/npm/v/@stdlib/math-base-napi-unary.svg
387
718
  [npm-url]: https://npmjs.org/package/@stdlib/math-base-napi-unary
388
719
 
389
- [test-image]: https://github.com/stdlib-js/math-base-napi-unary/actions/workflows/test.yml/badge.svg
390
- [test-url]: https://github.com/stdlib-js/math-base-napi-unary/actions/workflows/test.yml
720
+ [test-image]: https://github.com/stdlib-js/math-base-napi-unary/actions/workflows/test.yml/badge.svg?branch=v0.0.9
721
+ [test-url]: https://github.com/stdlib-js/math-base-napi-unary/actions/workflows/test.yml?query=branch:v0.0.9
391
722
 
392
723
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-napi-unary/main.svg
393
724
  [coverage-url]: https://codecov.io/github/stdlib-js/math-base-napi-unary?branch=main
394
725
 
726
+ <!--
727
+
395
728
  [dependencies-image]: https://img.shields.io/david/stdlib-js/math-base-napi-unary.svg
396
729
  [dependencies-url]: https://david-dm.org/stdlib-js/math-base-napi-unary/main
397
730
 
731
+ -->
732
+
398
733
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
399
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
734
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
400
735
 
401
736
  [stdlib]: https://github.com/stdlib-js/stdlib
402
737