@stdlib/math-base-napi-ternary 0.3.0 → 0.3.2
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 +537 -26
- 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 -150
- package/manifest.json +50 -36
- package/package.json +6 -7
- 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/fff_f.c +97 -0
- 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/src/main.c +0 -250
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,17 +286,41 @@ 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
|
|
|
169
|
-
####
|
|
289
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_DID_D( fcn )
|
|
170
290
|
|
|
171
|
-
|
|
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.
|
|
172
315
|
|
|
173
316
|
```c
|
|
174
317
|
#include <node_api.h>
|
|
318
|
+
#include <stdint.h>
|
|
175
319
|
|
|
176
320
|
// ...
|
|
177
321
|
|
|
178
|
-
static
|
|
179
|
-
|
|
322
|
+
static double fcn( const double x, const int32_t y, const double z ) {
|
|
323
|
+
// ...
|
|
180
324
|
}
|
|
181
325
|
|
|
182
326
|
// ...
|
|
@@ -189,7 +333,7 @@ static float addf( const float x, const float y, const float z ) {
|
|
|
189
333
|
* @return Node-API value
|
|
190
334
|
*/
|
|
191
335
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
192
|
-
return
|
|
336
|
+
return stdlib_math_base_napi_did_d( env, info, fcn );
|
|
193
337
|
}
|
|
194
338
|
|
|
195
339
|
// ...
|
|
@@ -199,12 +343,35 @@ The function accepts the following arguments:
|
|
|
199
343
|
|
|
200
344
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
201
345
|
- **info**: `[in] napi_callback_info` callback data.
|
|
202
|
-
- **fcn**: `[in]
|
|
346
|
+
- **fcn**: `[in] double (*fcn)( double, int32_t, double )` ternary function.
|
|
203
347
|
|
|
204
348
|
```c
|
|
205
|
-
void
|
|
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 );
|
|
206
367
|
```
|
|
207
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
|
+
|
|
208
375
|
#### stdlib_math_base_napi_dii_d( env, info, fcn )
|
|
209
376
|
|
|
210
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.
|
|
@@ -245,71 +412,415 @@ The function accepts the following arguments:
|
|
|
245
412
|
void stdlib_math_base_napi_dii_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t, int32_t ) );
|
|
246
413
|
```
|
|
247
414
|
|
|
248
|
-
####
|
|
415
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( fcn )
|
|
249
416
|
|
|
250
|
-
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning
|
|
417
|
+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning single-precision floating-point numbers.
|
|
251
418
|
|
|
252
419
|
```c
|
|
253
|
-
static
|
|
420
|
+
static float addf( const float x, const float y, const float z ) {
|
|
254
421
|
return x + y + z;
|
|
255
422
|
}
|
|
256
423
|
|
|
257
424
|
// ...
|
|
258
425
|
|
|
259
426
|
// Register a Node-API module:
|
|
260
|
-
|
|
427
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( addf );
|
|
261
428
|
```
|
|
262
429
|
|
|
263
430
|
The macro expects the following arguments:
|
|
264
431
|
|
|
265
|
-
- **fcn**: `
|
|
432
|
+
- **fcn**: `float (*fcn)( float, float, float )` ternary function.
|
|
266
433
|
|
|
267
434
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
268
435
|
|
|
269
|
-
####
|
|
436
|
+
#### stdlib_math_base_napi_fff_f( env, info, fcn )
|
|
270
437
|
|
|
271
|
-
|
|
438
|
+
Invokes a ternary function accepting and returning single-precision floating-point numbers.
|
|
272
439
|
|
|
273
440
|
```c
|
|
441
|
+
#include <node_api.h>
|
|
442
|
+
|
|
443
|
+
// ...
|
|
444
|
+
|
|
274
445
|
static float addf( const float x, const float y, const float z ) {
|
|
275
446
|
return x + y + z;
|
|
276
447
|
}
|
|
277
448
|
|
|
278
449
|
// ...
|
|
279
450
|
|
|
451
|
+
/**
|
|
452
|
+
* Receives JavaScript callback invocation data.
|
|
453
|
+
*
|
|
454
|
+
* @param env environment under which the function is invoked
|
|
455
|
+
* @param info callback data
|
|
456
|
+
* @return Node-API value
|
|
457
|
+
*/
|
|
458
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
459
|
+
return stdlib_math_base_napi_fff_f( env, info, addf );
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// ...
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
The function accepts the following arguments:
|
|
466
|
+
|
|
467
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
468
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
469
|
+
- **fcn**: `[in] float (*fcn)( float, float, float )` ternary function.
|
|
470
|
+
|
|
471
|
+
```c
|
|
472
|
+
void stdlib_math_base_napi_fff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float, float ) );
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_FIF_F( fcn )
|
|
476
|
+
|
|
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.
|
|
478
|
+
|
|
479
|
+
```c
|
|
480
|
+
#include <stdint.h>
|
|
481
|
+
|
|
482
|
+
static float fcn( const float x, const int32_t y, const float z ) {
|
|
483
|
+
// ...
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// ...
|
|
487
|
+
|
|
280
488
|
// Register a Node-API module:
|
|
281
|
-
|
|
489
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FIF_F( fcn );
|
|
282
490
|
```
|
|
283
491
|
|
|
284
492
|
The macro expects the following arguments:
|
|
285
493
|
|
|
286
|
-
- **fcn**: `float (*fcn)( float,
|
|
494
|
+
- **fcn**: `float (*fcn)( float, int32_t, float )` ternary function.
|
|
287
495
|
|
|
288
496
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
289
497
|
|
|
290
|
-
####
|
|
498
|
+
#### stdlib_math_base_napi_fif_f( env, info, fcn )
|
|
291
499
|
|
|
292
|
-
|
|
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.
|
|
293
501
|
|
|
294
502
|
```c
|
|
503
|
+
#include <node_api.h>
|
|
295
504
|
#include <stdint.h>
|
|
296
505
|
|
|
297
|
-
|
|
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 ) {
|
|
298
546
|
// ...
|
|
299
547
|
}
|
|
300
548
|
|
|
301
549
|
// ...
|
|
302
550
|
|
|
303
551
|
// Register a Node-API module:
|
|
304
|
-
|
|
552
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FII_F( fcn );
|
|
305
553
|
```
|
|
306
554
|
|
|
307
555
|
The macro expects the following arguments:
|
|
308
556
|
|
|
309
|
-
- **fcn**: `
|
|
557
|
+
- **fcn**: `float (*fcn)( float, int32_t, int32_t )` ternary function.
|
|
310
558
|
|
|
311
559
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
312
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.
|
|
684
|
+
|
|
685
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
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
|
+
|
|
313
824
|
</section>
|
|
314
825
|
|
|
315
826
|
<!-- /.usage -->
|
|
@@ -384,7 +895,7 @@ See [LICENSE][stdlib-license].
|
|
|
384
895
|
|
|
385
896
|
## Copyright
|
|
386
897
|
|
|
387
|
-
Copyright © 2016-
|
|
898
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
388
899
|
|
|
389
900
|
</section>
|
|
390
901
|
|
|
@@ -397,8 +908,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
397
908
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/math-base-napi-ternary.svg
|
|
398
909
|
[npm-url]: https://npmjs.org/package/@stdlib/math-base-napi-ternary
|
|
399
910
|
|
|
400
|
-
[test-image]: https://github.com/stdlib-js/math-base-napi-ternary/actions/workflows/test.yml/badge.svg?branch=v0.3.
|
|
401
|
-
[test-url]: https://github.com/stdlib-js/math-base-napi-ternary/actions/workflows/test.yml?query=branch:v0.3.
|
|
911
|
+
[test-image]: https://github.com/stdlib-js/math-base-napi-ternary/actions/workflows/test.yml/badge.svg?branch=v0.3.2
|
|
912
|
+
[test-url]: https://github.com/stdlib-js/math-base-napi-ternary/actions/workflows/test.yml?query=branch:v0.3.2
|
|
402
913
|
|
|
403
914
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-napi-ternary/main.svg
|
|
404
915
|
[coverage-url]: https://codecov.io/github/stdlib-js/math-base-napi-ternary?branch=main
|
|
@@ -410,8 +921,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
410
921
|
|
|
411
922
|
-->
|
|
412
923
|
|
|
413
|
-
[chat-image]: https://img.shields.io/
|
|
414
|
-
[chat-url]: https://
|
|
924
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
925
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
415
926
|
|
|
416
927
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
417
928
|
|