@stdlib/math-base-napi-ternary 0.2.1 → 0.3.1
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 +591 -17
- package/include/stdlib/math/base/napi/ternary/ccc_c.h +101 -0
- package/include/stdlib/math/base/napi/ternary/ddd_d.h +81 -0
- package/include/stdlib/math/base/napi/ternary/did_d.h +84 -0
- package/include/stdlib/math/base/napi/ternary/dii_d.h +84 -0
- package/include/stdlib/math/base/napi/ternary/fff_f.h +81 -0
- package/include/stdlib/math/base/napi/ternary/fif_f.h +84 -0
- package/include/stdlib/math/base/napi/ternary/fii_f.h +84 -0
- package/include/stdlib/math/base/napi/ternary/iid_d.h +84 -0
- package/include/stdlib/math/base/napi/ternary/iii_d.h +84 -0
- package/include/stdlib/math/base/napi/ternary/zzz_z.h +101 -0
- package/include/stdlib/math/base/napi/ternary.h +11 -103
- package/manifest.json +50 -36
- package/package.json +6 -2
- package/src/ccc_c.c +230 -0
- package/src/ddd_d.c +97 -0
- package/src/did_d.c +98 -0
- package/src/dii_d.c +98 -0
- package/src/{main.c → fff_f.c} +1 -78
- package/src/fif_f.c +98 -0
- package/src/fii_f.c +98 -0
- package/src/iid_d.c +98 -0
- package/src/iii_d.c +98 -0
- package/src/zzz_z.c +230 -0
- package/include.gypi +0 -53
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -127,6 +127,126 @@ console.log( headerDir );
|
|
|
127
127
|
#include "stdlib/math/base/napi/ternary.h"
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
+
<!-- NOTE: keep in alphabetical order according to the suffix XXX_X -->
|
|
131
|
+
|
|
132
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_CCC_C( fcn )
|
|
133
|
+
|
|
134
|
+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning single-precision complex floating-point numbers.
|
|
135
|
+
|
|
136
|
+
```c
|
|
137
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
138
|
+
#include "stdlib/complex/float32/reim.h"
|
|
139
|
+
|
|
140
|
+
static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y, const stdlib_complex64_t z ) {
|
|
141
|
+
float xre;
|
|
142
|
+
float xim;
|
|
143
|
+
float yre;
|
|
144
|
+
float yim;
|
|
145
|
+
float zre;
|
|
146
|
+
float zim;
|
|
147
|
+
float re;
|
|
148
|
+
float im;
|
|
149
|
+
|
|
150
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
151
|
+
stdlib_complex64_reim( y, &yre, &yim );
|
|
152
|
+
stdlib_complex64_reim( z, &zre, &zim );
|
|
153
|
+
|
|
154
|
+
re = xre + yre + zre;
|
|
155
|
+
im = xim + yim + zim;
|
|
156
|
+
|
|
157
|
+
return stdlib_complex64( re, im );
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ...
|
|
161
|
+
|
|
162
|
+
// Register a Node-API module:
|
|
163
|
+
STDLIB_MATH_BASE_NAPI_MODULE_CCC_C( add );
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
The macro expects the following arguments:
|
|
167
|
+
|
|
168
|
+
- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t, stdlib_complex64_t )` ternary function.
|
|
169
|
+
|
|
170
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
171
|
+
|
|
172
|
+
#### stdlib_math_base_napi_ccc_c( env, info, fcn )
|
|
173
|
+
|
|
174
|
+
Invokes a ternary function accepting and returning single-precision complex floating-point numbers.
|
|
175
|
+
|
|
176
|
+
```c
|
|
177
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
178
|
+
#include "stdlib/complex/float32/reim.h"
|
|
179
|
+
#include <node_api.h>
|
|
180
|
+
|
|
181
|
+
// ...
|
|
182
|
+
|
|
183
|
+
static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y, const stdlib_complex64_t z ) {
|
|
184
|
+
float xre;
|
|
185
|
+
float xim;
|
|
186
|
+
float yre;
|
|
187
|
+
float yim;
|
|
188
|
+
float zre;
|
|
189
|
+
float zim;
|
|
190
|
+
float re;
|
|
191
|
+
float im;
|
|
192
|
+
|
|
193
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
194
|
+
stdlib_complex64_reim( y, &yre, &yim );
|
|
195
|
+
stdlib_complex64_reim( z, &zre, &zim );
|
|
196
|
+
|
|
197
|
+
re = xre + yre + zre;
|
|
198
|
+
im = xim + yim + zim;
|
|
199
|
+
|
|
200
|
+
return stdlib_complex64( re, im );
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ...
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Receives JavaScript callback invocation data.
|
|
207
|
+
*
|
|
208
|
+
* @param env environment under which the function is invoked
|
|
209
|
+
* @param info callback data
|
|
210
|
+
* @return Node-API value
|
|
211
|
+
*/
|
|
212
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
213
|
+
return stdlib_math_base_napi_ccc_c( env, info, add );
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ...
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
The function accepts the following arguments:
|
|
220
|
+
|
|
221
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
222
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
223
|
+
- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t, stdlib_complex64_t )` ternary function.
|
|
224
|
+
|
|
225
|
+
```c
|
|
226
|
+
void stdlib_math_base_napi_ccc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t, stdlib_complex64_t ) );
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( fcn )
|
|
230
|
+
|
|
231
|
+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning double-precision floating-point numbers.
|
|
232
|
+
|
|
233
|
+
```c
|
|
234
|
+
static double add( const double x, const double y, const double z ) {
|
|
235
|
+
return x + y + z;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// ...
|
|
239
|
+
|
|
240
|
+
// Register a Node-API module:
|
|
241
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( add );
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
The macro expects the following arguments:
|
|
245
|
+
|
|
246
|
+
- **fcn**: `double (*fcn)( double, double, double )` ternary function.
|
|
247
|
+
|
|
248
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
249
|
+
|
|
130
250
|
#### stdlib_math_base_napi_ddd_d( env, info, fcn )
|
|
131
251
|
|
|
132
252
|
Invokes a ternary function accepting and returning double-precision floating-point numbers.
|
|
@@ -166,6 +286,153 @@ The function accepts the following arguments:
|
|
|
166
286
|
void stdlib_math_base_napi_ddd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double, double ) );
|
|
167
287
|
```
|
|
168
288
|
|
|
289
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_DID_D( fcn )
|
|
290
|
+
|
|
291
|
+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting a double-precision floating-point number, a signed 32-bit integer, and a double-precision floating-point number and returning a double-precision floating-point number.
|
|
292
|
+
|
|
293
|
+
```c
|
|
294
|
+
#include <stdint.h>
|
|
295
|
+
|
|
296
|
+
static double fcn( const double x, const int32_t y, const double z ) {
|
|
297
|
+
// ...
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// ...
|
|
301
|
+
|
|
302
|
+
// Register a Node-API module:
|
|
303
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DID_D( fcn );
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
The macro expects the following arguments:
|
|
307
|
+
|
|
308
|
+
- **fcn**: `double (*fcn)( double, int32_t, double )` ternary function.
|
|
309
|
+
|
|
310
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
311
|
+
|
|
312
|
+
#### stdlib_math_base_napi_did_d( env, info, fcn )
|
|
313
|
+
|
|
314
|
+
Invokes a ternary function accepting a double-precision floating-point number, a signed 32-bit integer, and a double-precision floating-point number and returning a double-precision floating-point number.
|
|
315
|
+
|
|
316
|
+
```c
|
|
317
|
+
#include <node_api.h>
|
|
318
|
+
#include <stdint.h>
|
|
319
|
+
|
|
320
|
+
// ...
|
|
321
|
+
|
|
322
|
+
static double fcn( const double x, const int32_t y, const double z ) {
|
|
323
|
+
// ...
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// ...
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Receives JavaScript callback invocation data.
|
|
330
|
+
*
|
|
331
|
+
* @param env environment under which the function is invoked
|
|
332
|
+
* @param info callback data
|
|
333
|
+
* @return Node-API value
|
|
334
|
+
*/
|
|
335
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
336
|
+
return stdlib_math_base_napi_did_d( env, info, fcn );
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// ...
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
The function accepts the following arguments:
|
|
343
|
+
|
|
344
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
345
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
346
|
+
- **fcn**: `[in] double (*fcn)( double, int32_t, double )` ternary function.
|
|
347
|
+
|
|
348
|
+
```c
|
|
349
|
+
void stdlib_math_base_napi_did_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, double ) );
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn )
|
|
353
|
+
|
|
354
|
+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number.
|
|
355
|
+
|
|
356
|
+
```c
|
|
357
|
+
#include <stdint.h>
|
|
358
|
+
|
|
359
|
+
static double fcn( const double x, const int32_t y, const int32_t z ) {
|
|
360
|
+
// ...
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// ...
|
|
364
|
+
|
|
365
|
+
// Register a Node-API module:
|
|
366
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DII_D( fcn );
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
The macro expects the following arguments:
|
|
370
|
+
|
|
371
|
+
- **fcn**: `double (*fcn)( double, int32_t, int32_t )` ternary function.
|
|
372
|
+
|
|
373
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
374
|
+
|
|
375
|
+
#### stdlib_math_base_napi_dii_d( env, info, fcn )
|
|
376
|
+
|
|
377
|
+
Invokes a ternary function accepting a double-precision floating-point number and two signed 32-bit integers and returning a double-precision floating-point number.
|
|
378
|
+
|
|
379
|
+
```c
|
|
380
|
+
#include <node_api.h>
|
|
381
|
+
#include <stdint.h>
|
|
382
|
+
|
|
383
|
+
// ...
|
|
384
|
+
|
|
385
|
+
static double fcn( const double x, const int32_t y, const int32_t z ) {
|
|
386
|
+
// ...
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// ...
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Receives JavaScript callback invocation data.
|
|
393
|
+
*
|
|
394
|
+
* @param env environment under which the function is invoked
|
|
395
|
+
* @param info callback data
|
|
396
|
+
* @return Node-API value
|
|
397
|
+
*/
|
|
398
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
399
|
+
return stdlib_math_base_napi_dii_d( env, info, fcn );
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// ...
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
The function accepts the following arguments:
|
|
406
|
+
|
|
407
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
408
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
409
|
+
- **fcn**: `[in] double (*fcn)( double, int32_t, int32_t )` ternary function.
|
|
410
|
+
|
|
411
|
+
```c
|
|
412
|
+
void stdlib_math_base_napi_dii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t ) );
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( fcn )
|
|
416
|
+
|
|
417
|
+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning single-precision floating-point numbers.
|
|
418
|
+
|
|
419
|
+
```c
|
|
420
|
+
static float addf( const float x, const float y, const float z ) {
|
|
421
|
+
return x + y + z;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// ...
|
|
425
|
+
|
|
426
|
+
// Register a Node-API module:
|
|
427
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( addf );
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
The macro expects the following arguments:
|
|
431
|
+
|
|
432
|
+
- **fcn**: `float (*fcn)( float, float, float )` ternary function.
|
|
433
|
+
|
|
434
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
435
|
+
|
|
169
436
|
#### stdlib_math_base_napi_fff_f( env, info, fcn )
|
|
170
437
|
|
|
171
438
|
Invokes a ternary function accepting and returning single-precision floating-point numbers.
|
|
@@ -205,48 +472,355 @@ The function accepts the following arguments:
|
|
|
205
472
|
void stdlib_math_base_napi_fff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float ) );
|
|
206
473
|
```
|
|
207
474
|
|
|
208
|
-
####
|
|
475
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_FIF_F( fcn )
|
|
209
476
|
|
|
210
|
-
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning
|
|
477
|
+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting a single-precision floating-point number, a signed 32-bit integer, and a single-precision floating-point number and returning a single-precision floating-point number.
|
|
211
478
|
|
|
212
479
|
```c
|
|
213
|
-
|
|
214
|
-
|
|
480
|
+
#include <stdint.h>
|
|
481
|
+
|
|
482
|
+
static float fcn( const float x, const int32_t y, const float z ) {
|
|
483
|
+
// ...
|
|
215
484
|
}
|
|
216
485
|
|
|
217
486
|
// ...
|
|
218
487
|
|
|
219
488
|
// Register a Node-API module:
|
|
220
|
-
|
|
489
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FIF_F( fcn );
|
|
221
490
|
```
|
|
222
491
|
|
|
223
492
|
The macro expects the following arguments:
|
|
224
493
|
|
|
225
|
-
- **fcn**: `
|
|
494
|
+
- **fcn**: `float (*fcn)( float, int32_t, float )` ternary function.
|
|
226
495
|
|
|
227
496
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
228
497
|
|
|
229
|
-
####
|
|
498
|
+
#### stdlib_math_base_napi_fif_f( env, info, fcn )
|
|
230
499
|
|
|
231
|
-
|
|
500
|
+
Invokes a ternary function accepting a single-precision floating-point number, a signed 32-bit integer, and a single-precision floating-point number and returning a single-precision floating-point number.
|
|
232
501
|
|
|
233
502
|
```c
|
|
234
|
-
|
|
235
|
-
|
|
503
|
+
#include <node_api.h>
|
|
504
|
+
#include <stdint.h>
|
|
505
|
+
|
|
506
|
+
// ...
|
|
507
|
+
|
|
508
|
+
static float fcn( const float x, const int32_t y, const float z ) {
|
|
509
|
+
// ...
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// ...
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Receives JavaScript callback invocation data.
|
|
516
|
+
*
|
|
517
|
+
* @param env environment under which the function is invoked
|
|
518
|
+
* @param info callback data
|
|
519
|
+
* @return Node-API value
|
|
520
|
+
*/
|
|
521
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
522
|
+
return stdlib_math_base_napi_fif_f( env, info, fcn );
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// ...
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
The function accepts the following arguments:
|
|
529
|
+
|
|
530
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
531
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
532
|
+
- **fcn**: `[in] float (*fcn)( float, int32_t, float )` ternary function.
|
|
533
|
+
|
|
534
|
+
```c
|
|
535
|
+
void stdlib_math_base_napi_fif_f( napi_env env, napi_callback_info info, float (*fcn)( float, int32_t, float ) );
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_FII_F( fcn )
|
|
539
|
+
|
|
540
|
+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting a single-precision floating-point number and two signed 32-bit integers and returning a single-precision floating-point number.
|
|
541
|
+
|
|
542
|
+
```c
|
|
543
|
+
#include <stdint.h>
|
|
544
|
+
|
|
545
|
+
static float fcn( const float x, const int32_t y, const int32_t z ) {
|
|
546
|
+
// ...
|
|
236
547
|
}
|
|
237
548
|
|
|
238
549
|
// ...
|
|
239
550
|
|
|
240
551
|
// Register a Node-API module:
|
|
241
|
-
|
|
552
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FII_F( fcn );
|
|
242
553
|
```
|
|
243
554
|
|
|
244
555
|
The macro expects the following arguments:
|
|
245
556
|
|
|
246
|
-
- **fcn**: `float (*fcn)( float,
|
|
557
|
+
- **fcn**: `float (*fcn)( float, int32_t, int32_t )` ternary function.
|
|
558
|
+
|
|
559
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
560
|
+
|
|
561
|
+
#### stdlib_math_base_napi_fii_f( env, info, fcn )
|
|
562
|
+
|
|
563
|
+
Invokes a ternary function accepting a single-precision floating-point number and two signed 32-bit integers and returning a single-precision floating-point number.
|
|
564
|
+
|
|
565
|
+
```c
|
|
566
|
+
#include <node_api.h>
|
|
567
|
+
#include <stdint.h>
|
|
568
|
+
|
|
569
|
+
// ...
|
|
570
|
+
|
|
571
|
+
static float fcn( const float x, const int32_t y, const int32_t z ) {
|
|
572
|
+
// ...
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// ...
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Receives JavaScript callback invocation data.
|
|
579
|
+
*
|
|
580
|
+
* @param env environment under which the function is invoked
|
|
581
|
+
* @param info callback data
|
|
582
|
+
* @return Node-API value
|
|
583
|
+
*/
|
|
584
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
585
|
+
return stdlib_math_base_napi_fii_f( env, info, fcn );
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// ...
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
The function accepts the following arguments:
|
|
592
|
+
|
|
593
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
594
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
595
|
+
- **fcn**: `[in] float (*fcn)( float, int32_t, int32_t )` ternary function.
|
|
596
|
+
|
|
597
|
+
```c
|
|
598
|
+
void stdlib_math_base_napi_fii_f( napi_env env, napi_callback_info info, float (*fcn)( float, int32_t, int32_t ) );
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_IID_D( fcn )
|
|
602
|
+
|
|
603
|
+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting two signed 32-bit integers and a double-precision floating-point number and returning a double-precision floating-point number.
|
|
604
|
+
|
|
605
|
+
```c
|
|
606
|
+
#include <stdint.h>
|
|
607
|
+
|
|
608
|
+
static double fcn( const int32_t x, const int32_t y, const double z ) {
|
|
609
|
+
// ...
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// ...
|
|
613
|
+
|
|
614
|
+
// Register a Node-API module:
|
|
615
|
+
STDLIB_MATH_BASE_NAPI_MODULE_IID_D( fcn );
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
The macro expects the following arguments:
|
|
619
|
+
|
|
620
|
+
- **fcn**: `double (*fcn)( int32_t, int32_t, double )` ternary function.
|
|
621
|
+
|
|
622
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
623
|
+
|
|
624
|
+
#### stdlib_math_base_napi_iid_d( env, info, fcn )
|
|
625
|
+
|
|
626
|
+
Invokes a ternary function accepting two signed 32-bit integers and a double-precision floating-point number and returning a double-precision floating-point number.
|
|
627
|
+
|
|
628
|
+
```c
|
|
629
|
+
#include <node_api.h>
|
|
630
|
+
#include <stdint.h>
|
|
631
|
+
|
|
632
|
+
// ...
|
|
633
|
+
|
|
634
|
+
static double fcn( const int32_t x, const int32_t y, const double z ) {
|
|
635
|
+
// ...
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// ...
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Receives JavaScript callback invocation data.
|
|
642
|
+
*
|
|
643
|
+
* @param env environment under which the function is invoked
|
|
644
|
+
* @param info callback data
|
|
645
|
+
* @return Node-API value
|
|
646
|
+
*/
|
|
647
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
648
|
+
return stdlib_math_base_napi_iid_d( env, info, fcn );
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// ...
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
The function accepts the following arguments:
|
|
655
|
+
|
|
656
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
657
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
658
|
+
- **fcn**: `[in] double (*fcn)( int32_t, int32_t, double )` ternary function.
|
|
659
|
+
|
|
660
|
+
```c
|
|
661
|
+
void stdlib_math_base_napi_iid_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t, double ) );
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_III_D( fcn )
|
|
665
|
+
|
|
666
|
+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting three signed 32-bit integers and returning a double-precision floating-point number.
|
|
667
|
+
|
|
668
|
+
```c
|
|
669
|
+
#include <stdint.h>
|
|
670
|
+
|
|
671
|
+
static double fcn( const int32_t x, const int32_t y, const int32_t z ) {
|
|
672
|
+
// ...
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// ...
|
|
676
|
+
|
|
677
|
+
// Register a Node-API module:
|
|
678
|
+
STDLIB_MATH_BASE_NAPI_MODULE_III_D( fcn );
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
The macro expects the following arguments:
|
|
682
|
+
|
|
683
|
+
- **fcn**: `double (*fcn)( int32_t, int32_t, int32_t )` ternary function.
|
|
247
684
|
|
|
248
685
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
249
686
|
|
|
687
|
+
#### stdlib_math_base_napi_iii_d( env, info, fcn )
|
|
688
|
+
|
|
689
|
+
Invokes a ternary function accepting three signed 32-bit integers and returning a double-precision floating-point number.
|
|
690
|
+
|
|
691
|
+
```c
|
|
692
|
+
#include <node_api.h>
|
|
693
|
+
#include <stdint.h>
|
|
694
|
+
|
|
695
|
+
// ...
|
|
696
|
+
|
|
697
|
+
static double fcn( const int32_t x, const int32_t y, const int32_t z ) {
|
|
698
|
+
// ...
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// ...
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Receives JavaScript callback invocation data.
|
|
705
|
+
*
|
|
706
|
+
* @param env environment under which the function is invoked
|
|
707
|
+
* @param info callback data
|
|
708
|
+
* @return Node-API value
|
|
709
|
+
*/
|
|
710
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
711
|
+
return stdlib_math_base_napi_iii_d( env, info, fcn );
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// ...
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
The function accepts the following arguments:
|
|
718
|
+
|
|
719
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
720
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
721
|
+
- **fcn**: `[in] double (*fcn)( int32_t, int32_t, int32_t )` ternary function.
|
|
722
|
+
|
|
723
|
+
```c
|
|
724
|
+
void stdlib_math_base_napi_iii_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t, int32_t ) );
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_ZZZ_Z( fcn )
|
|
728
|
+
|
|
729
|
+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning double-precision complex floating-point numbers.
|
|
730
|
+
|
|
731
|
+
```c
|
|
732
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
733
|
+
#include "stdlib/complex/float64/reim.h"
|
|
734
|
+
|
|
735
|
+
static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y, const stdlib_complex128_t z ) {
|
|
736
|
+
double xre;
|
|
737
|
+
double xim;
|
|
738
|
+
double yre;
|
|
739
|
+
double yim;
|
|
740
|
+
double zre;
|
|
741
|
+
double zim;
|
|
742
|
+
double re;
|
|
743
|
+
double im;
|
|
744
|
+
|
|
745
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
746
|
+
stdlib_complex128_reim( y, &yre, &yim );
|
|
747
|
+
stdlib_complex128_reim( z, &zre, &zim );
|
|
748
|
+
|
|
749
|
+
re = xre + yre + zre;
|
|
750
|
+
im = xim + yim + zim;
|
|
751
|
+
|
|
752
|
+
return stdlib_complex128( re, im );
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
// ...
|
|
756
|
+
|
|
757
|
+
// Register a Node-API module:
|
|
758
|
+
STDLIB_MATH_BASE_NAPI_MODULE_ZZZ_Z( add );
|
|
759
|
+
```
|
|
760
|
+
|
|
761
|
+
The macro expects the following arguments:
|
|
762
|
+
|
|
763
|
+
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t, stdlib_complex128_t )` ternary function.
|
|
764
|
+
|
|
765
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
766
|
+
|
|
767
|
+
#### stdlib_math_base_napi_zzz_z( env, info, fcn )
|
|
768
|
+
|
|
769
|
+
Invokes a ternary function accepting and returning double-precision complex floating-point numbers.
|
|
770
|
+
|
|
771
|
+
```c
|
|
772
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
773
|
+
#include "stdlib/complex/float64/reim.h"
|
|
774
|
+
#include <node_api.h>
|
|
775
|
+
|
|
776
|
+
// ...
|
|
777
|
+
|
|
778
|
+
static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y, const stdlib_complex128_t z ) {
|
|
779
|
+
double xre;
|
|
780
|
+
double xim;
|
|
781
|
+
double yre;
|
|
782
|
+
double yim;
|
|
783
|
+
double zre;
|
|
784
|
+
double zim;
|
|
785
|
+
double re;
|
|
786
|
+
double im;
|
|
787
|
+
|
|
788
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
789
|
+
stdlib_complex128_reim( y, &yre, &yim );
|
|
790
|
+
stdlib_complex128_reim( z, &zre, &zim );
|
|
791
|
+
|
|
792
|
+
re = xre + yre + zre;
|
|
793
|
+
im = xim + yim + zim;
|
|
794
|
+
|
|
795
|
+
return stdlib_complex128( re, im );
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// ...
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Receives JavaScript callback invocation data.
|
|
802
|
+
*
|
|
803
|
+
* @param env environment under which the function is invoked
|
|
804
|
+
* @param info callback data
|
|
805
|
+
* @return Node-API value
|
|
806
|
+
*/
|
|
807
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
808
|
+
return stdlib_math_base_napi_zzz_z( env, info, add );
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// ...
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
The function accepts the following arguments:
|
|
815
|
+
|
|
816
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
817
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
818
|
+
- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t, stdlib_complex128_t )` ternary function.
|
|
819
|
+
|
|
820
|
+
```c
|
|
821
|
+
void stdlib_math_base_napi_zzz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t, stdlib_complex128_t ) );
|
|
822
|
+
```
|
|
823
|
+
|
|
250
824
|
</section>
|
|
251
825
|
|
|
252
826
|
<!-- /.usage -->
|
|
@@ -321,7 +895,7 @@ See [LICENSE][stdlib-license].
|
|
|
321
895
|
|
|
322
896
|
## Copyright
|
|
323
897
|
|
|
324
|
-
Copyright © 2016-
|
|
898
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
325
899
|
|
|
326
900
|
</section>
|
|
327
901
|
|
|
@@ -334,8 +908,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
334
908
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/math-base-napi-ternary.svg
|
|
335
909
|
[npm-url]: https://npmjs.org/package/@stdlib/math-base-napi-ternary
|
|
336
910
|
|
|
337
|
-
[test-image]: https://github.com/stdlib-js/math-base-napi-ternary/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
338
|
-
[test-url]: https://github.com/stdlib-js/math-base-napi-ternary/actions/workflows/test.yml?query=branch:v0.
|
|
911
|
+
[test-image]: https://github.com/stdlib-js/math-base-napi-ternary/actions/workflows/test.yml/badge.svg?branch=v0.3.1
|
|
912
|
+
[test-url]: https://github.com/stdlib-js/math-base-napi-ternary/actions/workflows/test.yml?query=branch:v0.3.1
|
|
339
913
|
|
|
340
914
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-napi-ternary/main.svg
|
|
341
915
|
[coverage-url]: https://codecov.io/github/stdlib-js/math-base-napi-ternary?branch=main
|
|
@@ -347,8 +921,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
347
921
|
|
|
348
922
|
-->
|
|
349
923
|
|
|
350
|
-
[chat-image]: https://img.shields.io/
|
|
351
|
-
[chat-url]: https://
|
|
924
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
925
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
352
926
|
|
|
353
927
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
354
928
|
|