@stdlib/math-base-napi-unary 0.0.4 → 0.0.8

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/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2021 The Stdlib Authors.
1
+ Copyright (c) 2016-2022 The Stdlib Authors.
package/README.md CHANGED
@@ -20,9 +20,9 @@ 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
- > C APIs for registering an N-API module exporting interfaces for invoking unary numerical functions.
25
+ > C APIs for registering a Node-API module exporting interfaces for invoking unary numerical functions.
26
26
 
27
27
  <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
28
28
 
@@ -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
@@ -142,11 +132,11 @@ static double identity( const double x ) {
142
132
  // ...
143
133
 
144
134
  /**
145
- * Receives JavaScript callback invocation data via N-API.
135
+ * Receives JavaScript callback invocation data.
146
136
  *
147
137
  * @param env environment under which the function is invoked
148
138
  * @param info callback data
149
- * @return N-API value
139
+ * @return Node-API value
150
140
  */
151
141
  napi_value addon( napi_env env, napi_callback_info info ) {
152
142
  return stdlib_math_base_napi_d_d( env, info, identity );
@@ -181,11 +171,11 @@ static float identityf( const float x ) {
181
171
  // ...
182
172
 
183
173
  /**
184
- * Receives JavaScript callback invocation data via N-API.
174
+ * Receives JavaScript callback invocation data.
185
175
  *
186
176
  * @param env environment under which the function is invoked
187
177
  * @param info callback data
188
- * @return N-API value
178
+ * @return Node-API value
189
179
  */
190
180
  napi_value addon( napi_env env, napi_callback_info info ) {
191
181
  return stdlib_math_base_napi_f_f( env, info, identityf );
@@ -204,6 +194,166 @@ 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
359
  Invokes a unary function accepting and returning 32-bit signed integers.
@@ -221,11 +371,11 @@ static int32_t identity( const int32_t x ) {
221
371
  // ...
222
372
 
223
373
  /**
224
- * Receives JavaScript callback invocation data via N-API.
374
+ * Receives JavaScript callback invocation data.
225
375
  *
226
376
  * @param env environment under which the function is invoked
227
377
  * @param info callback data
228
- * @return N-API value
378
+ * @return Node-API value
229
379
  */
230
380
  napi_value addon( napi_env env, napi_callback_info info ) {
231
381
  return stdlib_math_base_napi_i_i( env, info, identity );
@@ -246,7 +396,7 @@ void stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (
246
396
 
247
397
  #### STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn )
248
398
 
249
- Macro for registering an N-API module exporting an interface for invoking a unary function accepting and returning double-precision floating-point numbers.
399
+ Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision floating-point numbers.
250
400
 
251
401
  ```c
252
402
  static double scale( const double x ) {
@@ -255,7 +405,7 @@ static double scale( const double x ) {
255
405
 
256
406
  // ...
257
407
 
258
- // Register an N-API module:
408
+ // Register a Node-API module:
259
409
  STDLIB_MATH_BASE_NAPI_MODULE_D_D( scale );
260
410
  ```
261
411
 
@@ -263,11 +413,11 @@ The macro expects the following arguments:
263
413
 
264
414
  - **fcn**: `double (*fcn)( double )` unary function.
265
415
 
266
- When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring N-API module registration.
416
+ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
267
417
 
268
418
  #### STDLIB_MATH_BASE_NAPI_MODULE_F_F( fcn )
269
419
 
270
- Macro for registering an N-API module exporting an interface for invoking a unary function accepting and returning single-precision floating-point numbers.
420
+ Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning single-precision floating-point numbers.
271
421
 
272
422
  ```c
273
423
  static float scale( const float x ) {
@@ -276,7 +426,7 @@ static float scale( const float x ) {
276
426
 
277
427
  // ...
278
428
 
279
- // Register an N-API module:
429
+ // Register a Node-API module:
280
430
  STDLIB_MATH_BASE_NAPI_MODULE_F_F( scale );
281
431
  ```
282
432
 
@@ -284,11 +434,121 @@ The macro expects the following arguments:
284
434
 
285
435
  - **fcn**: `float (*fcn)( float )` unary function.
286
436
 
287
- When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring N-API module registration.
437
+ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
438
+
439
+ #### STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( fcn )
440
+
441
+ Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision complex floating-point numbers.
442
+
443
+ ```c
444
+ #include "stdlib/complex/float64.h"
445
+ #include "stdlib/complex/reim.h"
446
+
447
+ static stdlib_complex128_t scale( const stdlib_complex128_t x ) {
448
+ double re;
449
+ double im;
450
+
451
+ stdlib_reim( x, &re, &im );
452
+
453
+ re *= 10.0;
454
+ im *= 10.0;
455
+
456
+ return stdlib_complex128( re, im );
457
+ }
458
+
459
+ // ...
460
+
461
+ // Register a Node-API module:
462
+ STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( scale );
463
+ ```
464
+
465
+ The macro expects the following arguments:
466
+
467
+ - **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t )` unary function.
468
+
469
+ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
470
+
471
+ #### STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn )
472
+
473
+ 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.
474
+
475
+ ```c
476
+ #include "stdlib/complex/float64.h"
477
+
478
+ static double fcn( const stdlib_complex128_t x ) {
479
+ // ...
480
+ }
481
+
482
+ // ...
483
+
484
+ // Register a Node-API module:
485
+ STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn );
486
+ ```
487
+
488
+ The macro expects the following arguments:
489
+
490
+ - **fcn**: `double (*fcn)( stdlib_complex128_t )` unary function.
491
+
492
+ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
493
+
494
+ #### STDLIB_MATH_BASE_NAPI_MODULE_C_C( fcn )
495
+
496
+ Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning single-precision complex floating-point numbers.
497
+
498
+ ```c
499
+ #include "stdlib/complex/float32.h"
500
+ #include "stdlib/complex/reimf.h"
501
+
502
+ static stdlib_complex64_t scale( const stdlib_complex64_t x ) {
503
+ float re;
504
+ float im;
505
+
506
+ stdlib_reimf( x, &re, &im );
507
+
508
+ re *= 10.0f;
509
+ im *= 10.0f;
510
+
511
+ return stdlib_complex64( re, im );
512
+ }
513
+
514
+ // ...
515
+
516
+ // Register a Node-API module:
517
+ STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale );
518
+ ```
519
+
520
+ The macro expects the following arguments:
521
+
522
+ - **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t )` unary function.
523
+
524
+ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
525
+
526
+ #### STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn )
527
+
528
+ 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.
529
+
530
+ ```c
531
+ #include "stdlib/complex/float32.h"
532
+
533
+ static float fcn( const stdlib_complex64_t x ) {
534
+ // ...
535
+ }
536
+
537
+ // ...
538
+
539
+ // Register a Node-API module:
540
+ STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn );
541
+ ```
542
+
543
+ The macro expects the following arguments:
544
+
545
+ - **fcn**: `float (*fcn)( stdlib_complex64_t )` unary function.
546
+
547
+ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
288
548
 
289
549
  #### STDLIB_MATH_BASE_NAPI_MODULE_I_I( fcn )
290
550
 
291
- Macro for registering an N-API module exporting an interface for invoking a unary function accepting and returning 32-bit signed integers.
551
+ Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 32-bit signed integers.
292
552
 
293
553
  ```c
294
554
  #include <stdint.h>
@@ -299,7 +559,7 @@ static int32_t scale( const int32_t x ) {
299
559
 
300
560
  // ...
301
561
 
302
- // Register an N-API module:
562
+ // Register a Node-API module:
303
563
  STDLIB_MATH_BASE_NAPI_MODULE_I_I( scale );
304
564
  ```
305
565
 
@@ -307,7 +567,7 @@ The macro expects the following arguments:
307
567
 
308
568
  - **fcn**: `int32_t (*fcn)( int32_t )` unary function.
309
569
 
310
- When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring N-API module registration.
570
+ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
311
571
 
312
572
  </section>
313
573
 
@@ -321,7 +581,7 @@ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro inc
321
581
 
322
582
  - The C-API functions expect that the callback `info` argument provides access to the following JavaScript arguments:
323
583
 
324
- - `x`: input value.
584
+ - **x**: input value.
325
585
 
326
586
  </section>
327
587
 
@@ -347,6 +607,14 @@ When used, this macro should be used **instead of** `NAPI_MODULE`. The macro inc
347
607
 
348
608
  <!-- /.references -->
349
609
 
610
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
611
+
612
+ <section class="related">
613
+
614
+ </section>
615
+
616
+ <!-- /.related -->
617
+
350
618
  <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
351
619
 
352
620
 
@@ -360,6 +628,10 @@ This package is part of [stdlib][stdlib], a standard library for JavaScript and
360
628
 
361
629
  For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
362
630
 
631
+ #### Community
632
+
633
+ [![Chat][chat-image]][chat-url]
634
+
363
635
  ---
364
636
 
365
637
  ## License
@@ -369,7 +641,7 @@ See [LICENSE][stdlib-license].
369
641
 
370
642
  ## Copyright
371
643
 
372
- Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
644
+ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
373
645
 
374
646
  </section>
375
647
 
@@ -388,9 +660,23 @@ Copyright &copy; 2016-2021. The Stdlib [Authors][stdlib-authors].
388
660
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-napi-unary/main.svg
389
661
  [coverage-url]: https://codecov.io/github/stdlib-js/math-base-napi-unary?branch=main
390
662
 
391
- [dependencies-image]: https://img.shields.io/david/stdlib-js/math-base-napi-unary
663
+ <!--
664
+
665
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/math-base-napi-unary.svg
392
666
  [dependencies-url]: https://david-dm.org/stdlib-js/math-base-napi-unary/main
393
667
 
668
+ -->
669
+
670
+ [umd]: https://github.com/umdjs/umd
671
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
672
+
673
+ [deno-url]: https://github.com/stdlib-js/math-base-napi-unary/tree/deno
674
+ [umd-url]: https://github.com/stdlib-js/math-base-napi-unary/tree/umd
675
+ [esm-url]: https://github.com/stdlib-js/math-base-napi-unary/tree/esm
676
+
677
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
678
+ [chat-url]: https://gitter.im/stdlib-js/stdlib/
679
+
394
680
  [stdlib]: https://github.com/stdlib-js/stdlib
395
681
 
396
682
  [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors