@stdlib/math-base-napi-unary 0.2.3 → 0.2.4
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 +1 -1
- package/README.md +710 -144
- package/include/stdlib/math/base/napi/unary/b_b.h +84 -0
- package/include/stdlib/math/base/napi/unary/c_c.h +93 -0
- package/include/stdlib/math/base/napi/unary/c_f.h +84 -0
- package/include/stdlib/math/base/napi/unary/d_d.h +81 -0
- package/include/stdlib/math/base/napi/unary/d_f.h +81 -0
- package/include/stdlib/math/base/napi/unary/f_f.h +81 -0
- package/include/stdlib/math/base/napi/unary/f_i.h +84 -0
- package/include/stdlib/math/base/napi/unary/h_h.h +84 -0
- package/include/stdlib/math/base/napi/unary/i_d.h +84 -0
- package/include/stdlib/math/base/napi/unary/i_f.h +84 -0
- package/include/stdlib/math/base/napi/unary/i_i.h +84 -0
- package/include/stdlib/math/base/napi/unary/k_k.h +84 -0
- package/include/stdlib/math/base/napi/unary/s_s.h +84 -0
- package/include/stdlib/math/base/napi/unary/t_t.h +84 -0
- package/include/stdlib/math/base/napi/unary/u_u.h +84 -0
- package/include/stdlib/math/base/napi/unary/z_d.h +84 -0
- package/include/stdlib/math/base/napi/unary/z_z.h +93 -0
- package/include/stdlib/math/base/napi/unary.h +18 -406
- package/manifest.json +56 -37
- package/package.json +6 -3
- package/src/b_b.c +71 -0
- package/src/c_c.c +129 -0
- package/src/c_f.c +109 -0
- package/src/d_d.c +69 -0
- package/src/d_f.c +69 -0
- package/src/f_f.c +69 -0
- package/src/f_i.c +70 -0
- package/src/h_h.c +74 -0
- package/src/i_d.c +70 -0
- package/src/i_f.c +70 -0
- package/src/i_i.c +70 -0
- package/src/k_k.c +70 -0
- package/src/s_s.c +71 -0
- package/src/t_t.c +70 -0
- package/src/u_u.c +70 -0
- package/src/z_d.c +109 -0
- package/src/z_z.c +129 -0
- package/src/main.c +0 -601
package/README.md
CHANGED
|
@@ -127,16 +127,42 @@ console.log( headerDir );
|
|
|
127
127
|
#include "stdlib/math/base/napi/unary.h"
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
<!-- NOTE: keep in alphabetical order according to the suffix X_X -->
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_B_B( fcn )
|
|
133
|
+
|
|
134
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 8-bit unsigned integers.
|
|
135
|
+
|
|
136
|
+
```c
|
|
137
|
+
#include <stdint.h>
|
|
138
|
+
|
|
139
|
+
static uint8_t scale( const uint8_t x ) {
|
|
140
|
+
return x * 10;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ...
|
|
144
|
+
|
|
145
|
+
// Register a Node-API module:
|
|
146
|
+
STDLIB_MATH_BASE_NAPI_MODULE_B_B( scale );
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The macro expects the following arguments:
|
|
150
|
+
|
|
151
|
+
- **fcn**: `uint8_t (*fcn)( uint8_t )` unary function.
|
|
152
|
+
|
|
153
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
154
|
+
|
|
155
|
+
#### stdlib_math_base_napi_b_b( env, info, fcn )
|
|
156
|
+
|
|
157
|
+
Invokes a unary function accepting and returning unsigned 8-bit integers.
|
|
133
158
|
|
|
134
159
|
```c
|
|
135
160
|
#include <node_api.h>
|
|
161
|
+
#include <stdint.h>
|
|
136
162
|
|
|
137
163
|
// ...
|
|
138
164
|
|
|
139
|
-
static
|
|
165
|
+
static uint8_t identity( const uint8_t x ) {
|
|
140
166
|
return x;
|
|
141
167
|
}
|
|
142
168
|
|
|
@@ -150,7 +176,7 @@ static double identity( const double x ) {
|
|
|
150
176
|
* @return Node-API value
|
|
151
177
|
*/
|
|
152
178
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
153
|
-
return
|
|
179
|
+
return stdlib_math_base_napi_b_b( env, info, identity );
|
|
154
180
|
}
|
|
155
181
|
|
|
156
182
|
// ...
|
|
@@ -160,62 +186,55 @@ The function accepts the following arguments:
|
|
|
160
186
|
|
|
161
187
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
162
188
|
- **info**: `[in] napi_callback_info` callback data.
|
|
163
|
-
- **fcn**: `[in]
|
|
189
|
+
- **fcn**: `[in] uint8_t (*fcn)( uint8_t )` unary function.
|
|
164
190
|
|
|
165
191
|
```c
|
|
166
|
-
void
|
|
192
|
+
void stdlib_math_base_napi_b_b( napi_env env, napi_callback_info info, uint8_t (*fcn)( uint8_t ) );
|
|
167
193
|
```
|
|
168
194
|
|
|
169
|
-
####
|
|
195
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_C_C( fcn )
|
|
170
196
|
|
|
171
|
-
|
|
197
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning single-precision complex floating-point numbers.
|
|
172
198
|
|
|
173
199
|
```c
|
|
174
|
-
#include
|
|
200
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
201
|
+
#include "stdlib/complex/float32/reim.h"
|
|
175
202
|
|
|
176
|
-
|
|
203
|
+
static stdlib_complex64_t scale( const stdlib_complex64_t x ) {
|
|
204
|
+
float re;
|
|
205
|
+
float im;
|
|
177
206
|
|
|
178
|
-
|
|
179
|
-
return x;
|
|
180
|
-
}
|
|
207
|
+
stdlib_complex64_reim( x, &re, &im );
|
|
181
208
|
|
|
182
|
-
|
|
209
|
+
re *= 10.0f;
|
|
210
|
+
im *= 10.0f;
|
|
183
211
|
|
|
184
|
-
|
|
185
|
-
* Receives JavaScript callback invocation data.
|
|
186
|
-
*
|
|
187
|
-
* @param env environment under which the function is invoked
|
|
188
|
-
* @param info callback data
|
|
189
|
-
* @return Node-API value
|
|
190
|
-
*/
|
|
191
|
-
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
192
|
-
return stdlib_math_base_napi_f_f( env, info, identityf );
|
|
212
|
+
return stdlib_complex64( re, im );
|
|
193
213
|
}
|
|
194
214
|
|
|
195
215
|
// ...
|
|
216
|
+
|
|
217
|
+
// Register a Node-API module:
|
|
218
|
+
STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale );
|
|
196
219
|
```
|
|
197
220
|
|
|
198
|
-
The
|
|
221
|
+
The macro expects the following arguments:
|
|
199
222
|
|
|
200
|
-
- **
|
|
201
|
-
- **info**: `[in] napi_callback_info` callback data.
|
|
202
|
-
- **fcn**: `[in] float (*fcn)( float )` unary function.
|
|
223
|
+
- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t )` unary function.
|
|
203
224
|
|
|
204
|
-
|
|
205
|
-
void stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) );
|
|
206
|
-
```
|
|
225
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
207
226
|
|
|
208
|
-
####
|
|
227
|
+
#### stdlib_math_base_napi_c_c( env, info, fcn )
|
|
209
228
|
|
|
210
|
-
Invokes a unary function accepting and returning
|
|
229
|
+
Invokes a unary function accepting and returning single-precision complex floating-point numbers.
|
|
211
230
|
|
|
212
231
|
```c
|
|
213
|
-
#include "stdlib/complex/
|
|
232
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
214
233
|
#include <node_api.h>
|
|
215
234
|
|
|
216
235
|
// ...
|
|
217
236
|
|
|
218
|
-
static
|
|
237
|
+
static stdlib_complex64_t identity( const stdlib_complex64_t x ) {
|
|
219
238
|
return x;
|
|
220
239
|
}
|
|
221
240
|
|
|
@@ -229,7 +248,7 @@ static stdlib_complex128_t identity( const stdlib_complex128_t x ) {
|
|
|
229
248
|
* @return Node-API value
|
|
230
249
|
*/
|
|
231
250
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
232
|
-
return
|
|
251
|
+
return stdlib_math_base_napi_c_c( env, info, identity );
|
|
233
252
|
}
|
|
234
253
|
|
|
235
254
|
// ...
|
|
@@ -239,23 +258,46 @@ The function accepts the following arguments:
|
|
|
239
258
|
|
|
240
259
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
241
260
|
- **info**: `[in] napi_callback_info` callback data.
|
|
242
|
-
- **fcn**: `[in]
|
|
261
|
+
- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t )` unary function.
|
|
243
262
|
|
|
244
263
|
```c
|
|
245
|
-
void
|
|
264
|
+
void stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) );
|
|
246
265
|
```
|
|
247
266
|
|
|
248
|
-
####
|
|
267
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn )
|
|
249
268
|
|
|
250
|
-
|
|
269
|
+
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.
|
|
251
270
|
|
|
252
271
|
```c
|
|
253
|
-
#include "stdlib/complex/
|
|
272
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
273
|
+
|
|
274
|
+
static float fcn( const stdlib_complex64_t x ) {
|
|
275
|
+
// ...
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// ...
|
|
279
|
+
|
|
280
|
+
// Register a Node-API module:
|
|
281
|
+
STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn );
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
The macro expects the following arguments:
|
|
285
|
+
|
|
286
|
+
- **fcn**: `float (*fcn)( stdlib_complex64_t )` unary function.
|
|
287
|
+
|
|
288
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
289
|
+
|
|
290
|
+
#### stdlib_math_base_napi_c_f( env, info, fcn )
|
|
291
|
+
|
|
292
|
+
Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number.
|
|
293
|
+
|
|
294
|
+
```c
|
|
295
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
254
296
|
#include <node_api.h>
|
|
255
297
|
|
|
256
298
|
// ...
|
|
257
299
|
|
|
258
|
-
static
|
|
300
|
+
static float fcn( const stdlib_complex64_t x ) {
|
|
259
301
|
// ...
|
|
260
302
|
}
|
|
261
303
|
|
|
@@ -269,7 +311,7 @@ static double fcn( const stdlib_complex128_t x ) {
|
|
|
269
311
|
* @return Node-API value
|
|
270
312
|
*/
|
|
271
313
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
272
|
-
return
|
|
314
|
+
return stdlib_math_base_napi_c_f( env, info, fcn );
|
|
273
315
|
}
|
|
274
316
|
|
|
275
317
|
// ...
|
|
@@ -279,23 +321,43 @@ The function accepts the following arguments:
|
|
|
279
321
|
|
|
280
322
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
281
323
|
- **info**: `[in] napi_callback_info` callback data.
|
|
282
|
-
- **fcn**: `[in]
|
|
324
|
+
- **fcn**: `[in] float (*fcn)( stdlib_complex64_t )` unary function.
|
|
283
325
|
|
|
284
326
|
```c
|
|
285
|
-
void
|
|
327
|
+
void stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) );
|
|
286
328
|
```
|
|
287
329
|
|
|
288
|
-
####
|
|
330
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn )
|
|
289
331
|
|
|
290
|
-
|
|
332
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision floating-point numbers.
|
|
333
|
+
|
|
334
|
+
```c
|
|
335
|
+
static double scale( const double x ) {
|
|
336
|
+
return x * 10.0;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// ...
|
|
340
|
+
|
|
341
|
+
// Register a Node-API module:
|
|
342
|
+
STDLIB_MATH_BASE_NAPI_MODULE_D_D( scale );
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
The macro expects the following arguments:
|
|
346
|
+
|
|
347
|
+
- **fcn**: `double (*fcn)( double )` unary function.
|
|
348
|
+
|
|
349
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
350
|
+
|
|
351
|
+
#### stdlib_math_base_napi_d_d( env, info, fcn )
|
|
352
|
+
|
|
353
|
+
Invokes a unary function accepting and returning double-precision floating-point numbers.
|
|
291
354
|
|
|
292
355
|
```c
|
|
293
|
-
#include "stdlib/complex/float32/ctor.h"
|
|
294
356
|
#include <node_api.h>
|
|
295
357
|
|
|
296
358
|
// ...
|
|
297
359
|
|
|
298
|
-
static
|
|
360
|
+
static double identity( const double x ) {
|
|
299
361
|
return x;
|
|
300
362
|
}
|
|
301
363
|
|
|
@@ -309,7 +371,7 @@ static stdlib_complex64_t identity( const stdlib_complex64_t x ) {
|
|
|
309
371
|
* @return Node-API value
|
|
310
372
|
*/
|
|
311
373
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
312
|
-
return
|
|
374
|
+
return stdlib_math_base_napi_d_d( env, info, identity );
|
|
313
375
|
}
|
|
314
376
|
|
|
315
377
|
// ...
|
|
@@ -319,24 +381,44 @@ The function accepts the following arguments:
|
|
|
319
381
|
|
|
320
382
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
321
383
|
- **info**: `[in] napi_callback_info` callback data.
|
|
322
|
-
- **fcn**: `[in]
|
|
384
|
+
- **fcn**: `[in] double (*fcn)( double )` unary function.
|
|
323
385
|
|
|
324
386
|
```c
|
|
325
|
-
void
|
|
387
|
+
void stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, double (*fcn)( double ) );
|
|
326
388
|
```
|
|
327
389
|
|
|
328
|
-
####
|
|
390
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_D_F( fcn )
|
|
329
391
|
|
|
330
|
-
|
|
392
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a double-precision floating-point number and returning a single-precision floating-point number.
|
|
393
|
+
|
|
394
|
+
```c
|
|
395
|
+
static float fcn( const double x ) {
|
|
396
|
+
return (float)x;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// ...
|
|
400
|
+
|
|
401
|
+
// Register a Node-API module:
|
|
402
|
+
STDLIB_MATH_BASE_NAPI_MODULE_D_F( fcn );
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
The macro expects the following arguments:
|
|
406
|
+
|
|
407
|
+
- **fcn**: `float (*fcn)( double )` unary function.
|
|
408
|
+
|
|
409
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
410
|
+
|
|
411
|
+
#### stdlib_math_base_napi_d_f( env, info, fcn )
|
|
412
|
+
|
|
413
|
+
Invokes a unary function accepting a double-precision floating-point number and returning a single-precision floating-point number.
|
|
331
414
|
|
|
332
415
|
```c
|
|
333
|
-
#include "stdlib/complex/float32/ctor.h"
|
|
334
416
|
#include <node_api.h>
|
|
335
417
|
|
|
336
418
|
// ...
|
|
337
419
|
|
|
338
|
-
static float fcn( const
|
|
339
|
-
|
|
420
|
+
static float fcn( const double x ) {
|
|
421
|
+
return (float)x;
|
|
340
422
|
}
|
|
341
423
|
|
|
342
424
|
// ...
|
|
@@ -349,7 +431,7 @@ static float fcn( const stdlib_complex64_t x ) {
|
|
|
349
431
|
* @return Node-API value
|
|
350
432
|
*/
|
|
351
433
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
352
|
-
return
|
|
434
|
+
return stdlib_math_base_napi_d_f( env, info, fcn );
|
|
353
435
|
}
|
|
354
436
|
|
|
355
437
|
// ...
|
|
@@ -359,23 +441,43 @@ The function accepts the following arguments:
|
|
|
359
441
|
|
|
360
442
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
361
443
|
- **info**: `[in] napi_callback_info` callback data.
|
|
362
|
-
- **fcn**: `[in] float (*fcn)(
|
|
444
|
+
- **fcn**: `[in] float (*fcn)( double )` unary function.
|
|
363
445
|
|
|
364
446
|
```c
|
|
365
|
-
void
|
|
447
|
+
void stdlib_math_base_napi_d_f( napi_env env, napi_callback_info info, float (*fcn)( double ) );
|
|
366
448
|
```
|
|
367
449
|
|
|
368
|
-
####
|
|
450
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_F_F( fcn )
|
|
369
451
|
|
|
370
|
-
|
|
452
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning single-precision floating-point numbers.
|
|
453
|
+
|
|
454
|
+
```c
|
|
455
|
+
static float scale( const float x ) {
|
|
456
|
+
return x * 10.0f;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// ...
|
|
460
|
+
|
|
461
|
+
// Register a Node-API module:
|
|
462
|
+
STDLIB_MATH_BASE_NAPI_MODULE_F_F( scale );
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
The macro expects the following arguments:
|
|
466
|
+
|
|
467
|
+
- **fcn**: `float (*fcn)( float )` 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_f_f( env, info, fcn )
|
|
472
|
+
|
|
473
|
+
Invokes a unary function accepting and returning single-precision floating-point numbers.
|
|
371
474
|
|
|
372
475
|
```c
|
|
373
476
|
#include <node_api.h>
|
|
374
|
-
#include <stdint.h>
|
|
375
477
|
|
|
376
478
|
// ...
|
|
377
479
|
|
|
378
|
-
static
|
|
480
|
+
static float identityf( const float x ) {
|
|
379
481
|
return x;
|
|
380
482
|
}
|
|
381
483
|
|
|
@@ -389,7 +491,7 @@ static int32_t identity( const int32_t x ) {
|
|
|
389
491
|
* @return Node-API value
|
|
390
492
|
*/
|
|
391
493
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
392
|
-
return
|
|
494
|
+
return stdlib_math_base_napi_f_f( env, info, identityf );
|
|
393
495
|
}
|
|
394
496
|
|
|
395
497
|
// ...
|
|
@@ -399,15 +501,38 @@ The function accepts the following arguments:
|
|
|
399
501
|
|
|
400
502
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
401
503
|
- **info**: `[in] napi_callback_info` callback data.
|
|
402
|
-
- **fcn**: `[in]
|
|
504
|
+
- **fcn**: `[in] float (*fcn)( float )` unary function.
|
|
403
505
|
|
|
404
506
|
```c
|
|
405
|
-
void
|
|
507
|
+
void stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) );
|
|
406
508
|
```
|
|
407
509
|
|
|
408
|
-
####
|
|
510
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn )
|
|
409
511
|
|
|
410
|
-
|
|
512
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer.
|
|
513
|
+
|
|
514
|
+
```c
|
|
515
|
+
#include <stdint.h>
|
|
516
|
+
|
|
517
|
+
static int32_t fcn( const float x ) {
|
|
518
|
+
// ...
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
// ...
|
|
522
|
+
|
|
523
|
+
// Register a Node-API module:
|
|
524
|
+
STDLIB_MATH_BASE_NAPI_MODULE_F_I( fcn );
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
The macro expects the following arguments:
|
|
528
|
+
|
|
529
|
+
- **fcn**: `int32_t (*fcn)( float )` unary function.
|
|
530
|
+
|
|
531
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
532
|
+
|
|
533
|
+
#### stdlib_math_base_napi_f_i( env, info, fcn )
|
|
534
|
+
|
|
535
|
+
Invokes a unary function accepting a single-precision floating-point number and returning a signed 32-bit integer.
|
|
411
536
|
|
|
412
537
|
```c
|
|
413
538
|
#include <node_api.h>
|
|
@@ -415,8 +540,8 @@ Invokes a unary function accepting a signed 32-bit integer and returning a singl
|
|
|
415
540
|
|
|
416
541
|
// ...
|
|
417
542
|
|
|
418
|
-
static
|
|
419
|
-
|
|
543
|
+
static int32_t fcn( const float x ) {
|
|
544
|
+
// ...
|
|
420
545
|
}
|
|
421
546
|
|
|
422
547
|
// ...
|
|
@@ -429,7 +554,7 @@ static double scale( const int32_t x ) {
|
|
|
429
554
|
* @return Node-API value
|
|
430
555
|
*/
|
|
431
556
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
432
|
-
return
|
|
557
|
+
return stdlib_math_base_napi_f_i( env, info, fcn );
|
|
433
558
|
}
|
|
434
559
|
|
|
435
560
|
// ...
|
|
@@ -439,210 +564,651 @@ The function accepts the following arguments:
|
|
|
439
564
|
|
|
440
565
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
441
566
|
- **info**: `[in] napi_callback_info` callback data.
|
|
442
|
-
- **fcn**: `[in]
|
|
567
|
+
- **fcn**: `[in] int32_t (*fcn)( float )` unary function.
|
|
443
568
|
|
|
444
569
|
```c
|
|
445
|
-
void
|
|
570
|
+
void stdlib_math_base_napi_f_i( napi_env env, napi_callback_info info, int32_t (*fcn)( float ) );
|
|
446
571
|
```
|
|
447
572
|
|
|
448
|
-
####
|
|
573
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_H_H( fcn )
|
|
449
574
|
|
|
450
|
-
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning
|
|
575
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning half-precision floating-point numbers.
|
|
451
576
|
|
|
452
577
|
```c
|
|
453
|
-
|
|
454
|
-
|
|
578
|
+
#include "stdlib/number/float16/ctor.h"
|
|
579
|
+
|
|
580
|
+
static stdlib_float16_t identity( const stdlib_float16_t x ) {
|
|
581
|
+
return x;
|
|
455
582
|
}
|
|
456
583
|
|
|
457
584
|
// ...
|
|
458
585
|
|
|
459
586
|
// Register a Node-API module:
|
|
460
|
-
|
|
587
|
+
STDLIB_MATH_BASE_NAPI_MODULE_H_H( identity );
|
|
461
588
|
```
|
|
462
589
|
|
|
463
590
|
The macro expects the following arguments:
|
|
464
591
|
|
|
465
|
-
- **fcn**: `
|
|
592
|
+
- **fcn**: `stdlib_float16_t (*fcn)( stdlib_float16_t )` unary function.
|
|
466
593
|
|
|
467
594
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
468
595
|
|
|
469
|
-
####
|
|
596
|
+
#### stdlib_math_base_napi_h_h( env, info, fcn )
|
|
470
597
|
|
|
471
|
-
|
|
598
|
+
Invokes a unary function accepting and returning half-precision floating-point numbers.
|
|
472
599
|
|
|
473
600
|
```c
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
601
|
+
#include "stdlib/number/float16/ctor.h"
|
|
602
|
+
#include <node_api.h>
|
|
477
603
|
|
|
478
604
|
// ...
|
|
479
605
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
606
|
+
static stdlib_float16_t identity( const stdlib_float16_t x ) {
|
|
607
|
+
return x;
|
|
608
|
+
}
|
|
483
609
|
|
|
484
|
-
|
|
610
|
+
// ...
|
|
485
611
|
|
|
486
|
-
|
|
612
|
+
/**
|
|
613
|
+
* Receives JavaScript callback invocation data.
|
|
614
|
+
*
|
|
615
|
+
* @param env environment under which the function is invoked
|
|
616
|
+
* @param info callback data
|
|
617
|
+
* @return Node-API value
|
|
618
|
+
*/
|
|
619
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
620
|
+
return stdlib_math_base_napi_h_h( env, info, identity );
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
// ...
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
The function accepts the following arguments:
|
|
627
|
+
|
|
628
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
629
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
630
|
+
- **fcn**: `[in] stdlib_float16_t (*fcn)( stdlib_float16_t )` unary function.
|
|
631
|
+
|
|
632
|
+
```c
|
|
633
|
+
void stdlib_math_base_napi_h_h( napi_env env, napi_callback_info info, stdlib_float16_t (*fcn)( stdlib_float16_t ) );
|
|
634
|
+
```
|
|
635
|
+
|
|
636
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_I_D( fcn )
|
|
637
|
+
|
|
638
|
+
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.
|
|
639
|
+
|
|
640
|
+
```c
|
|
641
|
+
#include <stdint.h>
|
|
642
|
+
|
|
643
|
+
static double scale( const int32_t x ) {
|
|
644
|
+
return x * 10.0;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
// ...
|
|
648
|
+
|
|
649
|
+
// Register a Node-API module:
|
|
650
|
+
STDLIB_MATH_BASE_NAPI_MODULE_I_D( scale );
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
The macro expects the following arguments:
|
|
654
|
+
|
|
655
|
+
- **fcn**: `double (*fcn)( int32_t )` unary function.
|
|
487
656
|
|
|
488
657
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
489
658
|
|
|
490
|
-
####
|
|
659
|
+
#### stdlib_math_base_napi_i_d( env, info, fcn )
|
|
491
660
|
|
|
492
|
-
|
|
661
|
+
Invokes a unary function accepting a signed 32-bit integer and returning a double-precision floating-point number.
|
|
493
662
|
|
|
494
663
|
```c
|
|
495
|
-
#include
|
|
496
|
-
#include
|
|
664
|
+
#include <node_api.h>
|
|
665
|
+
#include <stdint.h>
|
|
497
666
|
|
|
498
|
-
|
|
499
|
-
double re;
|
|
500
|
-
double im;
|
|
667
|
+
// ...
|
|
501
668
|
|
|
502
|
-
|
|
669
|
+
static double scale( const int32_t x ) {
|
|
670
|
+
return x * 10.0;
|
|
671
|
+
}
|
|
503
672
|
|
|
504
|
-
|
|
505
|
-
im *= 10.0;
|
|
673
|
+
// ...
|
|
506
674
|
|
|
507
|
-
|
|
675
|
+
/**
|
|
676
|
+
* Receives JavaScript callback invocation data.
|
|
677
|
+
*
|
|
678
|
+
* @param env environment under which the function is invoked
|
|
679
|
+
* @param info callback data
|
|
680
|
+
* @return Node-API value
|
|
681
|
+
*/
|
|
682
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
683
|
+
return stdlib_math_base_napi_i_d( env, info, scale );
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
// ...
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
The function accepts the following arguments:
|
|
690
|
+
|
|
691
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
692
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
693
|
+
- **fcn**: `[in] double (*fcn)( int32_t )` unary function.
|
|
694
|
+
|
|
695
|
+
```c
|
|
696
|
+
void stdlib_math_base_napi_i_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) );
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn )
|
|
700
|
+
|
|
701
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number.
|
|
702
|
+
|
|
703
|
+
```c
|
|
704
|
+
#include <stdint.h>
|
|
705
|
+
|
|
706
|
+
static float fcn( const int32_t x ) {
|
|
707
|
+
// ...
|
|
508
708
|
}
|
|
509
709
|
|
|
510
710
|
// ...
|
|
511
711
|
|
|
512
712
|
// Register a Node-API module:
|
|
513
|
-
|
|
713
|
+
STDLIB_MATH_BASE_NAPI_MODULE_I_F( fcn );
|
|
514
714
|
```
|
|
515
715
|
|
|
516
716
|
The macro expects the following arguments:
|
|
517
717
|
|
|
518
|
-
- **fcn**: `
|
|
718
|
+
- **fcn**: `float (*fcn)( int32_t )` unary function.
|
|
519
719
|
|
|
520
720
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
521
721
|
|
|
522
|
-
####
|
|
722
|
+
#### stdlib_math_base_napi_i_f( env, info, fcn )
|
|
523
723
|
|
|
524
|
-
|
|
724
|
+
Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number.
|
|
525
725
|
|
|
526
726
|
```c
|
|
527
|
-
#include
|
|
727
|
+
#include <node_api.h>
|
|
728
|
+
#include <stdint.h>
|
|
528
729
|
|
|
529
|
-
|
|
730
|
+
// ...
|
|
731
|
+
|
|
732
|
+
static float fcn( const int32_t x ) {
|
|
530
733
|
// ...
|
|
531
734
|
}
|
|
532
735
|
|
|
533
736
|
// ...
|
|
534
737
|
|
|
738
|
+
/**
|
|
739
|
+
* Receives JavaScript callback invocation data.
|
|
740
|
+
*
|
|
741
|
+
* @param env environment under which the function is invoked
|
|
742
|
+
* @param info callback data
|
|
743
|
+
* @return Node-API value
|
|
744
|
+
*/
|
|
745
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
746
|
+
return stdlib_math_base_napi_i_f( env, info, fcn );
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// ...
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
The function accepts the following arguments:
|
|
753
|
+
|
|
754
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
755
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
756
|
+
- **fcn**: `[in] float (*fcn)( int32_t )` unary function.
|
|
757
|
+
|
|
758
|
+
```c
|
|
759
|
+
void stdlib_math_base_napi_i_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t ) );
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_I_I( fcn )
|
|
763
|
+
|
|
764
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 32-bit signed integers.
|
|
765
|
+
|
|
766
|
+
```c
|
|
767
|
+
#include <stdint.h>
|
|
768
|
+
|
|
769
|
+
static int32_t scale( const int32_t x ) {
|
|
770
|
+
return x * 10;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
// ...
|
|
774
|
+
|
|
535
775
|
// Register a Node-API module:
|
|
536
|
-
|
|
776
|
+
STDLIB_MATH_BASE_NAPI_MODULE_I_I( scale );
|
|
537
777
|
```
|
|
538
778
|
|
|
539
779
|
The macro expects the following arguments:
|
|
540
780
|
|
|
541
|
-
- **fcn**: `
|
|
781
|
+
- **fcn**: `int32_t (*fcn)( int32_t )` unary function.
|
|
542
782
|
|
|
543
783
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
544
784
|
|
|
545
|
-
####
|
|
785
|
+
#### stdlib_math_base_napi_i_i( env, info, fcn )
|
|
546
786
|
|
|
547
|
-
|
|
787
|
+
Invokes a unary function accepting and returning signed 32-bit integers.
|
|
548
788
|
|
|
549
789
|
```c
|
|
550
|
-
#include
|
|
551
|
-
#include
|
|
790
|
+
#include <node_api.h>
|
|
791
|
+
#include <stdint.h>
|
|
552
792
|
|
|
553
|
-
|
|
554
|
-
float re;
|
|
555
|
-
float im;
|
|
793
|
+
// ...
|
|
556
794
|
|
|
557
|
-
|
|
795
|
+
static int32_t identity( const int32_t x ) {
|
|
796
|
+
return x;
|
|
797
|
+
}
|
|
558
798
|
|
|
559
|
-
|
|
560
|
-
im *= 10.0f;
|
|
799
|
+
// ...
|
|
561
800
|
|
|
562
|
-
|
|
801
|
+
/**
|
|
802
|
+
* Receives JavaScript callback invocation data.
|
|
803
|
+
*
|
|
804
|
+
* @param env environment under which the function is invoked
|
|
805
|
+
* @param info callback data
|
|
806
|
+
* @return Node-API value
|
|
807
|
+
*/
|
|
808
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
809
|
+
return stdlib_math_base_napi_i_i( env, info, identity );
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
// ...
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
The function accepts the following arguments:
|
|
816
|
+
|
|
817
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
818
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
819
|
+
- **fcn**: `[in] int32_t (*fcn)( int32_t )` unary function.
|
|
820
|
+
|
|
821
|
+
```c
|
|
822
|
+
void stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) );
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_K_K( fcn )
|
|
826
|
+
|
|
827
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 16-bit signed integers.
|
|
828
|
+
|
|
829
|
+
```c
|
|
830
|
+
#include <stdint.h>
|
|
831
|
+
|
|
832
|
+
static int16_t scale( const int16_t x ) {
|
|
833
|
+
return x * 10;
|
|
563
834
|
}
|
|
564
835
|
|
|
565
836
|
// ...
|
|
566
837
|
|
|
567
838
|
// Register a Node-API module:
|
|
568
|
-
|
|
839
|
+
STDLIB_MATH_BASE_NAPI_MODULE_K_K( scale );
|
|
569
840
|
```
|
|
570
841
|
|
|
571
842
|
The macro expects the following arguments:
|
|
572
843
|
|
|
573
|
-
- **fcn**: `
|
|
844
|
+
- **fcn**: `int16_t (*fcn)( int16_t )` unary function.
|
|
574
845
|
|
|
575
846
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
576
847
|
|
|
577
|
-
####
|
|
848
|
+
#### stdlib_math_base_napi_k_k( env, info, fcn )
|
|
578
849
|
|
|
579
|
-
|
|
850
|
+
Invokes a unary function accepting and returning signed 16-bit integers.
|
|
580
851
|
|
|
581
852
|
```c
|
|
582
|
-
#include
|
|
853
|
+
#include <node_api.h>
|
|
854
|
+
#include <stdint.h>
|
|
583
855
|
|
|
584
|
-
|
|
585
|
-
|
|
856
|
+
// ...
|
|
857
|
+
|
|
858
|
+
static int16_t identity( const int16_t x ) {
|
|
859
|
+
return x;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// ...
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* Receives JavaScript callback invocation data.
|
|
866
|
+
*
|
|
867
|
+
* @param env environment under which the function is invoked
|
|
868
|
+
* @param info callback data
|
|
869
|
+
* @return Node-API value
|
|
870
|
+
*/
|
|
871
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
872
|
+
return stdlib_math_base_napi_k_k( env, info, identity );
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
// ...
|
|
876
|
+
```
|
|
877
|
+
|
|
878
|
+
The function accepts the following arguments:
|
|
879
|
+
|
|
880
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
881
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
882
|
+
- **fcn**: `[in] int16_t (*fcn)( int16_t )` unary function.
|
|
883
|
+
|
|
884
|
+
```c
|
|
885
|
+
void stdlib_math_base_napi_k_k( napi_env env, napi_callback_info info, int16_t (*fcn)( int16_t ) );
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_S_S( fcn )
|
|
889
|
+
|
|
890
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 8-bit signed integers.
|
|
891
|
+
|
|
892
|
+
```c
|
|
893
|
+
#include <stdint.h>
|
|
894
|
+
|
|
895
|
+
static int8_t scale( const int8_t x ) {
|
|
896
|
+
return x * 10;
|
|
586
897
|
}
|
|
587
898
|
|
|
588
899
|
// ...
|
|
589
900
|
|
|
590
901
|
// Register a Node-API module:
|
|
591
|
-
|
|
902
|
+
STDLIB_MATH_BASE_NAPI_MODULE_S_S( scale );
|
|
592
903
|
```
|
|
593
904
|
|
|
594
905
|
The macro expects the following arguments:
|
|
595
906
|
|
|
596
|
-
- **fcn**: `
|
|
907
|
+
- **fcn**: `int8_t (*fcn)( int8_t )` unary function.
|
|
597
908
|
|
|
598
909
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
599
910
|
|
|
600
|
-
####
|
|
911
|
+
#### stdlib_math_base_napi_s_s( env, info, fcn )
|
|
601
912
|
|
|
602
|
-
|
|
913
|
+
Invokes a unary function accepting and returning signed 8-bit integers.
|
|
603
914
|
|
|
604
915
|
```c
|
|
916
|
+
#include <node_api.h>
|
|
605
917
|
#include <stdint.h>
|
|
606
918
|
|
|
607
|
-
|
|
919
|
+
// ...
|
|
920
|
+
|
|
921
|
+
static int8_t identity( const int8_t x ) {
|
|
922
|
+
return x;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
// ...
|
|
926
|
+
|
|
927
|
+
/**
|
|
928
|
+
* Receives JavaScript callback invocation data.
|
|
929
|
+
*
|
|
930
|
+
* @param env environment under which the function is invoked
|
|
931
|
+
* @param info callback data
|
|
932
|
+
* @return Node-API value
|
|
933
|
+
*/
|
|
934
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
935
|
+
return stdlib_math_base_napi_s_s( env, info, identity );
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
// ...
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
The function accepts the following arguments:
|
|
942
|
+
|
|
943
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
944
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
945
|
+
- **fcn**: `[in] int8_t (*fcn)( int8_t )` unary function.
|
|
946
|
+
|
|
947
|
+
```c
|
|
948
|
+
void stdlib_math_base_napi_s_s( napi_env env, napi_callback_info info, int8_t (*fcn)( int8_t ) );
|
|
949
|
+
```
|
|
950
|
+
|
|
951
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_T_T( fcn )
|
|
952
|
+
|
|
953
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 16-bit unsigned integers.
|
|
954
|
+
|
|
955
|
+
```c
|
|
956
|
+
#include <stdint.h>
|
|
957
|
+
|
|
958
|
+
static uint16_t scale( const uint16_t x ) {
|
|
608
959
|
return x * 10;
|
|
609
960
|
}
|
|
610
961
|
|
|
611
962
|
// ...
|
|
612
963
|
|
|
613
964
|
// Register a Node-API module:
|
|
614
|
-
|
|
965
|
+
STDLIB_MATH_BASE_NAPI_MODULE_T_T( scale );
|
|
615
966
|
```
|
|
616
967
|
|
|
617
968
|
The macro expects the following arguments:
|
|
618
969
|
|
|
619
|
-
- **fcn**: `
|
|
970
|
+
- **fcn**: `uint16_t (*fcn)( uint16_t )` unary function.
|
|
620
971
|
|
|
621
972
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
622
973
|
|
|
623
|
-
####
|
|
974
|
+
#### stdlib_math_base_napi_t_t( env, info, fcn )
|
|
624
975
|
|
|
625
|
-
|
|
976
|
+
Invokes a unary function accepting and returning unsigned 16-bit integers.
|
|
626
977
|
|
|
627
978
|
```c
|
|
979
|
+
#include <node_api.h>
|
|
628
980
|
#include <stdint.h>
|
|
629
981
|
|
|
630
|
-
|
|
631
|
-
|
|
982
|
+
// ...
|
|
983
|
+
|
|
984
|
+
static uint16_t identity( const uint16_t x ) {
|
|
985
|
+
return x;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
// ...
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* Receives JavaScript callback invocation data.
|
|
992
|
+
*
|
|
993
|
+
* @param env environment under which the function is invoked
|
|
994
|
+
* @param info callback data
|
|
995
|
+
* @return Node-API value
|
|
996
|
+
*/
|
|
997
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
998
|
+
return stdlib_math_base_napi_t_t( env, info, identity );
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
// ...
|
|
1002
|
+
```
|
|
1003
|
+
|
|
1004
|
+
The function accepts the following arguments:
|
|
1005
|
+
|
|
1006
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1007
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1008
|
+
- **fcn**: `[in] uint16_t (*fcn)( uint16_t )` unary function.
|
|
1009
|
+
|
|
1010
|
+
```c
|
|
1011
|
+
void stdlib_math_base_napi_t_t( napi_env env, napi_callback_info info, uint16_t (*fcn)( uint16_t ) );
|
|
1012
|
+
```
|
|
1013
|
+
|
|
1014
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_U_U( fcn )
|
|
1015
|
+
|
|
1016
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning 32-bit unsigned integers.
|
|
1017
|
+
|
|
1018
|
+
```c
|
|
1019
|
+
#include <stdint.h>
|
|
1020
|
+
|
|
1021
|
+
static uint32_t scale( const uint32_t x ) {
|
|
1022
|
+
return x * 10;
|
|
632
1023
|
}
|
|
633
1024
|
|
|
634
1025
|
// ...
|
|
635
1026
|
|
|
636
1027
|
// Register a Node-API module:
|
|
637
|
-
|
|
1028
|
+
STDLIB_MATH_BASE_NAPI_MODULE_U_U( scale );
|
|
638
1029
|
```
|
|
639
1030
|
|
|
640
1031
|
The macro expects the following arguments:
|
|
641
1032
|
|
|
642
|
-
- **fcn**: `
|
|
1033
|
+
- **fcn**: `uint32_t (*fcn)( uint32_t )` unary function.
|
|
643
1034
|
|
|
644
1035
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
645
1036
|
|
|
1037
|
+
#### stdlib_math_base_napi_u_u( env, info, fcn )
|
|
1038
|
+
|
|
1039
|
+
Invokes a unary function accepting and returning unsigned 32-bit integers.
|
|
1040
|
+
|
|
1041
|
+
```c
|
|
1042
|
+
#include <node_api.h>
|
|
1043
|
+
#include <stdint.h>
|
|
1044
|
+
|
|
1045
|
+
// ...
|
|
1046
|
+
|
|
1047
|
+
static uint32_t identity( const uint32_t x ) {
|
|
1048
|
+
return x;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
// ...
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Receives JavaScript callback invocation data.
|
|
1055
|
+
*
|
|
1056
|
+
* @param env environment under which the function is invoked
|
|
1057
|
+
* @param info callback data
|
|
1058
|
+
* @return Node-API value
|
|
1059
|
+
*/
|
|
1060
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1061
|
+
return stdlib_math_base_napi_u_u( env, info, identity );
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
// ...
|
|
1065
|
+
```
|
|
1066
|
+
|
|
1067
|
+
The function accepts the following arguments:
|
|
1068
|
+
|
|
1069
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1070
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1071
|
+
- **fcn**: `[in] uint32_t (*fcn)( uint32_t )` unary function.
|
|
1072
|
+
|
|
1073
|
+
```c
|
|
1074
|
+
void stdlib_math_base_napi_u_u( napi_env env, napi_callback_info info, uint32_t (*fcn)( uint32_t ) );
|
|
1075
|
+
```
|
|
1076
|
+
|
|
1077
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn )
|
|
1078
|
+
|
|
1079
|
+
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.
|
|
1080
|
+
|
|
1081
|
+
```c
|
|
1082
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1083
|
+
|
|
1084
|
+
static double fcn( const stdlib_complex128_t x ) {
|
|
1085
|
+
// ...
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
// ...
|
|
1089
|
+
|
|
1090
|
+
// Register a Node-API module:
|
|
1091
|
+
STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn );
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
The macro expects the following arguments:
|
|
1095
|
+
|
|
1096
|
+
- **fcn**: `double (*fcn)( stdlib_complex128_t )` unary function.
|
|
1097
|
+
|
|
1098
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
1099
|
+
|
|
1100
|
+
#### stdlib_math_base_napi_z_d( env, info, fcn )
|
|
1101
|
+
|
|
1102
|
+
Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number.
|
|
1103
|
+
|
|
1104
|
+
```c
|
|
1105
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1106
|
+
#include <node_api.h>
|
|
1107
|
+
|
|
1108
|
+
// ...
|
|
1109
|
+
|
|
1110
|
+
static double fcn( const stdlib_complex128_t x ) {
|
|
1111
|
+
// ...
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
// ...
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Receives JavaScript callback invocation data.
|
|
1118
|
+
*
|
|
1119
|
+
* @param env environment under which the function is invoked
|
|
1120
|
+
* @param info callback data
|
|
1121
|
+
* @return Node-API value
|
|
1122
|
+
*/
|
|
1123
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1124
|
+
return stdlib_math_base_napi_z_d( env, info, fcn );
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// ...
|
|
1128
|
+
```
|
|
1129
|
+
|
|
1130
|
+
The function accepts the following arguments:
|
|
1131
|
+
|
|
1132
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1133
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1134
|
+
- **fcn**: `[in] double (*fcn)( stdlib_complex128_t )` unary function.
|
|
1135
|
+
|
|
1136
|
+
```c
|
|
1137
|
+
void stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) );
|
|
1138
|
+
```
|
|
1139
|
+
|
|
1140
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( fcn )
|
|
1141
|
+
|
|
1142
|
+
Macro for registering a Node-API module exporting an interface for invoking a unary function accepting and returning double-precision complex floating-point numbers.
|
|
1143
|
+
|
|
1144
|
+
```c
|
|
1145
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1146
|
+
#include "stdlib/complex/float64/reim.h"
|
|
1147
|
+
|
|
1148
|
+
static stdlib_complex128_t scale( const stdlib_complex128_t x ) {
|
|
1149
|
+
double re;
|
|
1150
|
+
double im;
|
|
1151
|
+
|
|
1152
|
+
stdlib_complex128_reim( x, &re, &im );
|
|
1153
|
+
|
|
1154
|
+
re *= 10.0;
|
|
1155
|
+
im *= 10.0;
|
|
1156
|
+
|
|
1157
|
+
return stdlib_complex128( re, im );
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
// ...
|
|
1161
|
+
|
|
1162
|
+
// Register a Node-API module:
|
|
1163
|
+
STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( scale );
|
|
1164
|
+
```
|
|
1165
|
+
|
|
1166
|
+
The macro expects the following arguments:
|
|
1167
|
+
|
|
1168
|
+
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t )` unary function.
|
|
1169
|
+
|
|
1170
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
1171
|
+
|
|
1172
|
+
#### stdlib_math_base_napi_z_z( env, info, fcn )
|
|
1173
|
+
|
|
1174
|
+
Invokes a unary function accepting and returning double-precision complex floating-point numbers.
|
|
1175
|
+
|
|
1176
|
+
```c
|
|
1177
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1178
|
+
#include <node_api.h>
|
|
1179
|
+
|
|
1180
|
+
// ...
|
|
1181
|
+
|
|
1182
|
+
static stdlib_complex128_t identity( const stdlib_complex128_t x ) {
|
|
1183
|
+
return x;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// ...
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* Receives JavaScript callback invocation data.
|
|
1190
|
+
*
|
|
1191
|
+
* @param env environment under which the function is invoked
|
|
1192
|
+
* @param info callback data
|
|
1193
|
+
* @return Node-API value
|
|
1194
|
+
*/
|
|
1195
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1196
|
+
return stdlib_math_base_napi_z_z( env, info, identity );
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// ...
|
|
1200
|
+
```
|
|
1201
|
+
|
|
1202
|
+
The function accepts the following arguments:
|
|
1203
|
+
|
|
1204
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1205
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1206
|
+
- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t )` unary function.
|
|
1207
|
+
|
|
1208
|
+
```c
|
|
1209
|
+
void stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) );
|
|
1210
|
+
```
|
|
1211
|
+
|
|
646
1212
|
</section>
|
|
647
1213
|
|
|
648
1214
|
<!-- /.usage -->
|
|
@@ -715,7 +1281,7 @@ See [LICENSE][stdlib-license].
|
|
|
715
1281
|
|
|
716
1282
|
## Copyright
|
|
717
1283
|
|
|
718
|
-
Copyright © 2016-
|
|
1284
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
719
1285
|
|
|
720
1286
|
</section>
|
|
721
1287
|
|
|
@@ -728,8 +1294,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
728
1294
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/math-base-napi-unary.svg
|
|
729
1295
|
[npm-url]: https://npmjs.org/package/@stdlib/math-base-napi-unary
|
|
730
1296
|
|
|
731
|
-
[test-image]: https://github.com/stdlib-js/math-base-napi-unary/actions/workflows/test.yml/badge.svg?branch=v0.2.
|
|
732
|
-
[test-url]: https://github.com/stdlib-js/math-base-napi-unary/actions/workflows/test.yml?query=branch:v0.2.
|
|
1297
|
+
[test-image]: https://github.com/stdlib-js/math-base-napi-unary/actions/workflows/test.yml/badge.svg?branch=v0.2.4
|
|
1298
|
+
[test-url]: https://github.com/stdlib-js/math-base-napi-unary/actions/workflows/test.yml?query=branch:v0.2.4
|
|
733
1299
|
|
|
734
1300
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-napi-unary/main.svg
|
|
735
1301
|
[coverage-url]: https://codecov.io/github/stdlib-js/math-base-napi-unary?branch=main
|
|
@@ -741,8 +1307,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
741
1307
|
|
|
742
1308
|
-->
|
|
743
1309
|
|
|
744
|
-
[chat-image]: https://img.shields.io/
|
|
745
|
-
[chat-url]: https://
|
|
1310
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
1311
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
746
1312
|
|
|
747
1313
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
748
1314
|
|