@stdlib/math-base-napi-binary 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 +1065 -284
- package/include/stdlib/math/base/napi/binary/bb_b.h +84 -0
- package/include/stdlib/math/base/napi/binary/cc_c.h +98 -0
- package/include/stdlib/math/base/napi/binary/cf_c.h +89 -0
- package/include/stdlib/math/base/napi/binary/ci_c.h +91 -0
- package/include/stdlib/math/base/napi/binary/dd_d.h +81 -0
- package/include/stdlib/math/base/napi/binary/di_d.h +84 -0
- package/include/stdlib/math/base/napi/binary/dz_z.h +89 -0
- package/include/stdlib/math/base/napi/binary/fc_c.h +89 -0
- package/include/stdlib/math/base/napi/binary/ff_f.h +81 -0
- package/include/stdlib/math/base/napi/binary/fi_f.h +84 -0
- package/include/stdlib/math/base/napi/binary/id_d.h +84 -0
- package/include/stdlib/math/base/napi/binary/ii_d.h +84 -0
- package/include/stdlib/math/base/napi/binary/ii_f.h +84 -0
- package/include/stdlib/math/base/napi/binary/ii_i.h +84 -0
- package/include/stdlib/math/base/napi/binary/kk_k.h +84 -0
- package/include/stdlib/math/base/napi/binary/ll_d.h +84 -0
- package/include/stdlib/math/base/napi/binary/ss_s.h +84 -0
- package/include/stdlib/math/base/napi/binary/tt_t.h +84 -0
- package/include/stdlib/math/base/napi/binary/uu_u.h +84 -0
- package/include/stdlib/math/base/napi/binary/zd_z.h +89 -0
- package/include/stdlib/math/base/napi/binary/zi_z.h +91 -0
- package/include/stdlib/math/base/napi/binary/zz_z.h +98 -0
- package/include/stdlib/math/base/napi/binary.h +23 -621
- package/manifest.json +56 -36
- package/package.json +5 -10
- package/src/bb_b.c +84 -0
- package/src/cc_c.c +179 -0
- package/src/cf_c.c +143 -0
- package/src/ci_c.c +143 -0
- package/src/dd_d.c +83 -0
- package/src/di_d.c +84 -0
- package/src/dz_z.c +142 -0
- package/src/fc_c.c +142 -0
- package/src/ff_f.c +83 -0
- package/src/fi_f.c +84 -0
- package/src/id_d.c +84 -0
- package/src/ii_d.c +84 -0
- package/src/ii_f.c +84 -0
- package/src/ii_i.c +84 -0
- package/src/kk_k.c +84 -0
- package/src/ll_d.c +84 -0
- package/src/ss_s.c +84 -0
- package/src/tt_t.c +84 -0
- package/src/uu_u.c +84 -0
- package/src/zd_z.c +142 -0
- package/src/zi_z.c +143 -0
- package/src/zz_z.c +179 -0
- package/src/main.c +0 -1187
package/README.md
CHANGED
|
@@ -127,55 +127,42 @@ console.log( headerDir );
|
|
|
127
127
|
#include "stdlib/math/base/napi/binary.h"
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
<!-- NOTE: please keep in alphabetical order according to suffix XX_X -->
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_BB_B( fcn )
|
|
133
133
|
|
|
134
|
-
|
|
135
|
-
#include <node_api.h>
|
|
134
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning unsigned 8-bit integers.
|
|
136
135
|
|
|
137
|
-
|
|
136
|
+
```c
|
|
137
|
+
#include <stdint.h>
|
|
138
138
|
|
|
139
|
-
static
|
|
139
|
+
static uint8_t add( const uint8_t x, const uint8_t y ) {
|
|
140
140
|
return x + y;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
// ...
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
*
|
|
148
|
-
* @param env environment under which the function is invoked
|
|
149
|
-
* @param info callback data
|
|
150
|
-
* @return Node-API value
|
|
151
|
-
*/
|
|
152
|
-
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
153
|
-
return stdlib_math_base_napi_dd_d( env, info, add );
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// ...
|
|
145
|
+
// Register a Node-API module:
|
|
146
|
+
STDLIB_MATH_BASE_NAPI_MODULE_BB_B( add );
|
|
157
147
|
```
|
|
158
148
|
|
|
159
|
-
The
|
|
149
|
+
The macro expects the following arguments:
|
|
160
150
|
|
|
161
|
-
- **
|
|
162
|
-
- **info**: `[in] napi_callback_info` callback data.
|
|
163
|
-
- **fcn**: `[in] double (*fcn)( double, double )` binary function.
|
|
151
|
+
- **fcn**: `uint8_t (*fcn)( uint8_t, uint8_t )` binary function.
|
|
164
152
|
|
|
165
|
-
|
|
166
|
-
void stdlib_math_base_napi_dd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double ) );
|
|
167
|
-
```
|
|
153
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
168
154
|
|
|
169
|
-
####
|
|
155
|
+
#### stdlib_math_base_napi_bb_b( env, info, fcn )
|
|
170
156
|
|
|
171
|
-
Invokes a binary function accepting and returning
|
|
157
|
+
Invokes a binary function accepting and returning unsigned 8-bit integers.
|
|
172
158
|
|
|
173
159
|
```c
|
|
174
160
|
#include <node_api.h>
|
|
161
|
+
#include <stdint.h>
|
|
175
162
|
|
|
176
163
|
// ...
|
|
177
164
|
|
|
178
|
-
static
|
|
165
|
+
static uint8_t add( const uint8_t x, const uint8_t y ) {
|
|
179
166
|
return x + y;
|
|
180
167
|
}
|
|
181
168
|
|
|
@@ -189,7 +176,7 @@ static float addf( const float x, const float y ) {
|
|
|
189
176
|
* @return Node-API value
|
|
190
177
|
*/
|
|
191
178
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
192
|
-
return
|
|
179
|
+
return stdlib_math_base_napi_bb_b( env, info, add );
|
|
193
180
|
}
|
|
194
181
|
|
|
195
182
|
// ...
|
|
@@ -199,66 +186,48 @@ The function accepts the following arguments:
|
|
|
199
186
|
|
|
200
187
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
201
188
|
- **info**: `[in] napi_callback_info` callback data.
|
|
202
|
-
- **fcn**: `[in]
|
|
189
|
+
- **fcn**: `[in] uint8_t (*fcn)( uint8_t, uint8_t )` binary function.
|
|
203
190
|
|
|
204
|
-
|
|
205
|
-
void
|
|
206
|
-
```
|
|
207
|
-
````
|
|
191
|
+
```c
|
|
192
|
+
void stdlib_math_base_napi_bb_b( napi_env env, napi_callback_info info, uint8_t (*fcn)( uint8_t, uint8_t ) );
|
|
193
|
+
```
|
|
208
194
|
|
|
209
|
-
####
|
|
195
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_CC_C( fcn )
|
|
210
196
|
|
|
211
|
-
|
|
197
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning single-precision complex floating-point numbers.
|
|
212
198
|
|
|
213
199
|
```c
|
|
214
|
-
#include "stdlib/complex/
|
|
215
|
-
#include "stdlib/complex/
|
|
216
|
-
#include <node_api.h>
|
|
217
|
-
|
|
218
|
-
// ...
|
|
200
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
201
|
+
#include "stdlib/complex/float32/reim.h"
|
|
219
202
|
|
|
220
|
-
static
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
203
|
+
static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y ) {
|
|
204
|
+
float xre;
|
|
205
|
+
float xim;
|
|
206
|
+
float yre;
|
|
207
|
+
float yim;
|
|
208
|
+
float re;
|
|
209
|
+
float im;
|
|
227
210
|
|
|
228
|
-
|
|
229
|
-
|
|
211
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
212
|
+
stdlib_complex64_reim( y, &yre, &yim );
|
|
230
213
|
|
|
231
214
|
re = xre + yre;
|
|
232
215
|
im = xim + yim;
|
|
233
216
|
|
|
234
|
-
return
|
|
217
|
+
return stdlib_complex64( re, im );
|
|
235
218
|
}
|
|
236
219
|
|
|
237
220
|
// ...
|
|
238
221
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
*
|
|
242
|
-
* @param env environment under which the function is invoked
|
|
243
|
-
* @param info callback data
|
|
244
|
-
* @return Node-API value
|
|
245
|
-
*/
|
|
246
|
-
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
247
|
-
return stdlib_math_base_napi_zz_z( env, info, add );
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// ...
|
|
222
|
+
// Register a Node-API module:
|
|
223
|
+
STDLIB_MATH_BASE_NAPI_MODULE_CC_C( add );
|
|
251
224
|
```
|
|
252
225
|
|
|
253
|
-
The
|
|
226
|
+
The macro expects the following arguments:
|
|
254
227
|
|
|
255
|
-
- **
|
|
256
|
-
- **info**: `[in] napi_callback_info` callback data.
|
|
257
|
-
- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t )` binary function.
|
|
228
|
+
- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t )` binary function.
|
|
258
229
|
|
|
259
|
-
|
|
260
|
-
void stdlib_math_base_napi_zz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t ) );
|
|
261
|
-
```
|
|
230
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
262
231
|
|
|
263
232
|
#### stdlib_math_base_napi_cc_c( env, info, fcn )
|
|
264
233
|
|
|
@@ -314,18 +283,63 @@ The function accepts the following arguments:
|
|
|
314
283
|
void stdlib_math_base_napi_cc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t ) );
|
|
315
284
|
```
|
|
316
285
|
|
|
317
|
-
####
|
|
286
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_CF_C( fcn )
|
|
318
287
|
|
|
319
|
-
|
|
288
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number.
|
|
289
|
+
|
|
290
|
+
```c
|
|
291
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
292
|
+
#include "stdlib/complex/float32/reim.h"
|
|
293
|
+
|
|
294
|
+
static stdlib_complex64_t add( const stdlib_complex64_t x, const float y ) {
|
|
295
|
+
float xre;
|
|
296
|
+
float xim;
|
|
297
|
+
float re;
|
|
298
|
+
float im;
|
|
299
|
+
|
|
300
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
301
|
+
|
|
302
|
+
re = xre * y;
|
|
303
|
+
im = xim * y;
|
|
304
|
+
|
|
305
|
+
return stdlib_complex64( re, im );
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// ...
|
|
309
|
+
|
|
310
|
+
// Register a Node-API module:
|
|
311
|
+
STDLIB_MATH_BASE_NAPI_MODULE_CF_C( add );
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
The macro expects the following arguments:
|
|
315
|
+
|
|
316
|
+
- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, float )` binary function.
|
|
317
|
+
|
|
318
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
319
|
+
|
|
320
|
+
#### stdlib_math_base_napi_cf_c( env, info, fcn )
|
|
321
|
+
|
|
322
|
+
Invokes a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number.
|
|
320
323
|
|
|
321
324
|
```c
|
|
325
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
326
|
+
#include "stdlib/complex/float32/reim.h"
|
|
322
327
|
#include <node_api.h>
|
|
323
|
-
#include <stdint.h>
|
|
324
328
|
|
|
325
329
|
// ...
|
|
326
330
|
|
|
327
|
-
static
|
|
328
|
-
|
|
331
|
+
static stdlib_complex64_t mul( const stdlib_complex64_t x, const float y ) {
|
|
332
|
+
float xre;
|
|
333
|
+
float xim;
|
|
334
|
+
float re;
|
|
335
|
+
float im;
|
|
336
|
+
|
|
337
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
338
|
+
|
|
339
|
+
re = xre * y;
|
|
340
|
+
im = xim * y;
|
|
341
|
+
|
|
342
|
+
return stdlib_complex64( re, im );
|
|
329
343
|
}
|
|
330
344
|
|
|
331
345
|
// ...
|
|
@@ -338,7 +352,7 @@ static double mul( const double x, const int32_t y ) {
|
|
|
338
352
|
* @return Node-API value
|
|
339
353
|
*/
|
|
340
354
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
341
|
-
return
|
|
355
|
+
return stdlib_math_base_napi_cf_c( env, info, mul );
|
|
342
356
|
}
|
|
343
357
|
|
|
344
358
|
// ...
|
|
@@ -348,64 +362,71 @@ The function accepts the following arguments:
|
|
|
348
362
|
|
|
349
363
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
350
364
|
- **info**: `[in] napi_callback_info` callback data.
|
|
351
|
-
- **fcn**: `[in]
|
|
365
|
+
- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t, float )` binary function.
|
|
352
366
|
|
|
353
367
|
```c
|
|
354
|
-
void
|
|
368
|
+
void stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, float ) );
|
|
355
369
|
```
|
|
356
370
|
|
|
357
|
-
####
|
|
371
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_CI_C( fcn )
|
|
358
372
|
|
|
359
|
-
|
|
373
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number.
|
|
360
374
|
|
|
361
375
|
```c
|
|
362
|
-
#include
|
|
376
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
377
|
+
#include "stdlib/complex/float32/reim.h"
|
|
363
378
|
#include <stdint.h>
|
|
364
379
|
|
|
365
|
-
|
|
380
|
+
static stdlib_complex64_t add( const stdlib_complex64_t x, const int32_t y ) {
|
|
381
|
+
float xre;
|
|
382
|
+
float xim;
|
|
383
|
+
float re;
|
|
384
|
+
float im;
|
|
366
385
|
|
|
367
|
-
|
|
368
|
-
return x * y;
|
|
369
|
-
}
|
|
386
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
370
387
|
|
|
371
|
-
|
|
388
|
+
re = xre * y;
|
|
389
|
+
im = xim * y;
|
|
372
390
|
|
|
373
|
-
|
|
374
|
-
* Receives JavaScript callback invocation data.
|
|
375
|
-
*
|
|
376
|
-
* @param env environment under which the function is invoked
|
|
377
|
-
* @param info callback data
|
|
378
|
-
* @return Node-API value
|
|
379
|
-
*/
|
|
380
|
-
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
381
|
-
return stdlib_math_base_napi_ii_i( env, info, mul );
|
|
391
|
+
return stdlib_complex64( re, im );
|
|
382
392
|
}
|
|
383
393
|
|
|
384
394
|
// ...
|
|
395
|
+
|
|
396
|
+
// Register a Node-API module:
|
|
397
|
+
STDLIB_MATH_BASE_NAPI_MODULE_CI_C( add );
|
|
385
398
|
```
|
|
386
399
|
|
|
387
|
-
The
|
|
400
|
+
The macro expects the following arguments:
|
|
388
401
|
|
|
389
|
-
- **
|
|
390
|
-
- **info**: `[in] napi_callback_info` callback data.
|
|
391
|
-
- **fcn**: `[in] int32_t (*fcn)( int32_t, int32_t )` binary function.
|
|
402
|
+
- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t )` binary function.
|
|
392
403
|
|
|
393
|
-
|
|
394
|
-
void stdlib_math_base_napi_ii_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t, int32_t ) );
|
|
395
|
-
```
|
|
404
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
396
405
|
|
|
397
|
-
####
|
|
406
|
+
#### stdlib_math_base_napi_ci_c( env, info, fcn )
|
|
398
407
|
|
|
399
|
-
Invokes a binary function accepting signed 32-bit
|
|
408
|
+
Invokes a binary function accepting a single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number.
|
|
400
409
|
|
|
401
410
|
```c
|
|
411
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
412
|
+
#include "stdlib/complex/float32/reim.h"
|
|
402
413
|
#include <node_api.h>
|
|
403
414
|
#include <stdint.h>
|
|
404
415
|
|
|
405
416
|
// ...
|
|
406
417
|
|
|
407
|
-
static
|
|
408
|
-
|
|
418
|
+
static stdlib_complex64_t mul( const stdlib_complex64_t x, const int32_t y ) {
|
|
419
|
+
float xre;
|
|
420
|
+
float xim;
|
|
421
|
+
float re;
|
|
422
|
+
float im;
|
|
423
|
+
|
|
424
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
425
|
+
|
|
426
|
+
re = xre * y;
|
|
427
|
+
im = xim * y;
|
|
428
|
+
|
|
429
|
+
return stdlib_complex64( re, im );
|
|
409
430
|
}
|
|
410
431
|
|
|
411
432
|
// ...
|
|
@@ -418,7 +439,7 @@ static double mul( const int32_t x, const int32_t y ) {
|
|
|
418
439
|
* @return Node-API value
|
|
419
440
|
*/
|
|
420
441
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
421
|
-
return
|
|
442
|
+
return stdlib_math_base_napi_ci_c( env, info, mul );
|
|
422
443
|
}
|
|
423
444
|
|
|
424
445
|
// ...
|
|
@@ -428,24 +449,44 @@ The function accepts the following arguments:
|
|
|
428
449
|
|
|
429
450
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
430
451
|
- **info**: `[in] napi_callback_info` callback data.
|
|
431
|
-
- **fcn**: `[in]
|
|
452
|
+
- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t )` binary function.
|
|
432
453
|
|
|
433
454
|
```c
|
|
434
|
-
void
|
|
455
|
+
void stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) );
|
|
435
456
|
```
|
|
436
457
|
|
|
437
|
-
####
|
|
458
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_DD_D( fcn )
|
|
438
459
|
|
|
439
|
-
|
|
460
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning double-precision floating-point numbers.
|
|
461
|
+
|
|
462
|
+
```c
|
|
463
|
+
static double add( const double x, const double y ) {
|
|
464
|
+
return x + y;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// ...
|
|
468
|
+
|
|
469
|
+
// Register a Node-API module:
|
|
470
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DD_D( add );
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
The macro expects the following arguments:
|
|
474
|
+
|
|
475
|
+
- **fcn**: `double (*fcn)( double, double )` binary function.
|
|
476
|
+
|
|
477
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
478
|
+
|
|
479
|
+
#### stdlib_math_base_napi_dd_d( env, info, fcn )
|
|
480
|
+
|
|
481
|
+
Invokes a binary function accepting and returning double-precision floating-point numbers.
|
|
440
482
|
|
|
441
483
|
```c
|
|
442
484
|
#include <node_api.h>
|
|
443
|
-
#include <stdint.h>
|
|
444
485
|
|
|
445
486
|
// ...
|
|
446
487
|
|
|
447
|
-
static
|
|
448
|
-
return x
|
|
488
|
+
static double add( const double x, const double y ) {
|
|
489
|
+
return x + y;
|
|
449
490
|
}
|
|
450
491
|
|
|
451
492
|
// ...
|
|
@@ -458,7 +499,7 @@ static float mulf( const float x, const int32_t y ) {
|
|
|
458
499
|
* @return Node-API value
|
|
459
500
|
*/
|
|
460
501
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
461
|
-
return
|
|
502
|
+
return stdlib_math_base_napi_dd_d( env, info, add );
|
|
462
503
|
}
|
|
463
504
|
|
|
464
505
|
// ...
|
|
@@ -468,36 +509,47 @@ The function accepts the following arguments:
|
|
|
468
509
|
|
|
469
510
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
470
511
|
- **info**: `[in] napi_callback_info` callback data.
|
|
471
|
-
- **fcn**: `[in]
|
|
512
|
+
- **fcn**: `[in] double (*fcn)( double, double )` binary function.
|
|
472
513
|
|
|
473
514
|
```c
|
|
474
|
-
void
|
|
515
|
+
void stdlib_math_base_napi_dd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double ) );
|
|
475
516
|
```
|
|
476
517
|
|
|
477
|
-
####
|
|
518
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_DI_D( fcn )
|
|
478
519
|
|
|
479
|
-
|
|
520
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number.
|
|
480
521
|
|
|
481
522
|
```c
|
|
482
|
-
#include "stdlib/complex/float64/ctor.h"
|
|
483
|
-
#include "stdlib/complex/float64/reim.h"
|
|
484
|
-
#include <node_api.h>
|
|
485
523
|
#include <stdint.h>
|
|
486
524
|
|
|
525
|
+
static double mul( const double x, const int32_t y ) {
|
|
526
|
+
return x * y;
|
|
527
|
+
}
|
|
528
|
+
|
|
487
529
|
// ...
|
|
488
530
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
double re;
|
|
493
|
-
double im;
|
|
531
|
+
// Register a Node-API module:
|
|
532
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DI_D( mul );
|
|
533
|
+
```
|
|
494
534
|
|
|
495
|
-
|
|
535
|
+
The macro expects the following arguments:
|
|
496
536
|
|
|
497
|
-
|
|
498
|
-
im = xim * y;
|
|
537
|
+
- **fcn**: `double (*fcn)( double, int32_t )` binary function.
|
|
499
538
|
|
|
500
|
-
|
|
539
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
540
|
+
|
|
541
|
+
#### stdlib_math_base_napi_di_d( env, info, fcn )
|
|
542
|
+
|
|
543
|
+
Invokes a binary function accepting a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number.
|
|
544
|
+
|
|
545
|
+
```c
|
|
546
|
+
#include <node_api.h>
|
|
547
|
+
#include <stdint.h>
|
|
548
|
+
|
|
549
|
+
// ...
|
|
550
|
+
|
|
551
|
+
static double mul( const double x, const int32_t y ) {
|
|
552
|
+
return x * y;
|
|
501
553
|
}
|
|
502
554
|
|
|
503
555
|
// ...
|
|
@@ -510,7 +562,7 @@ static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) {
|
|
|
510
562
|
* @return Node-API value
|
|
511
563
|
*/
|
|
512
564
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
513
|
-
return
|
|
565
|
+
return stdlib_math_base_napi_di_d( env, info, mul );
|
|
514
566
|
}
|
|
515
567
|
|
|
516
568
|
// ...
|
|
@@ -520,36 +572,69 @@ The function accepts the following arguments:
|
|
|
520
572
|
|
|
521
573
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
522
574
|
- **info**: `[in] napi_callback_info` callback data.
|
|
523
|
-
- **fcn**: `[in]
|
|
575
|
+
- **fcn**: `[in] double (*fcn)( double, int32_t )` binary function.
|
|
524
576
|
|
|
525
577
|
```c
|
|
526
|
-
void
|
|
578
|
+
void stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) );
|
|
527
579
|
```
|
|
528
580
|
|
|
529
|
-
####
|
|
581
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_DZ_Z( fcn )
|
|
530
582
|
|
|
531
|
-
|
|
583
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number.
|
|
532
584
|
|
|
533
585
|
```c
|
|
534
586
|
#include "stdlib/complex/float64/ctor.h"
|
|
535
|
-
#include "stdlib/complex/
|
|
587
|
+
#include "stdlib/complex/float64/reim.h"
|
|
588
|
+
|
|
589
|
+
static stdlib_complex128_t mul( const double y, const stdlib_complex128_t x ) {
|
|
590
|
+
double xre;
|
|
591
|
+
double xim;
|
|
592
|
+
double re;
|
|
593
|
+
double im;
|
|
594
|
+
|
|
595
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
596
|
+
|
|
597
|
+
re = xre * y;
|
|
598
|
+
im = xim * y;
|
|
599
|
+
|
|
600
|
+
return stdlib_complex128( re, im );
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
// ...
|
|
604
|
+
|
|
605
|
+
// Register a Node-API module:
|
|
606
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DZ_Z( mul );
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
The macro expects the following arguments:
|
|
610
|
+
|
|
611
|
+
- **fcn**: `stdlib_complex128_t (*fcn)( double, stdlib_complex128_t )` binary function.
|
|
612
|
+
|
|
613
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
614
|
+
|
|
615
|
+
#### stdlib_math_base_napi_dz_z( env, info, fcn )
|
|
616
|
+
|
|
617
|
+
Invokes a binary function accepting a double-precision floating-point number and a double-precision complex floating-point number and returning a double-precision complex floating-point number.
|
|
618
|
+
|
|
619
|
+
```c
|
|
620
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
621
|
+
#include "stdlib/complex/float64/reim.h"
|
|
536
622
|
#include <node_api.h>
|
|
537
|
-
#include <stdint.h>
|
|
538
623
|
|
|
539
624
|
// ...
|
|
540
625
|
|
|
541
|
-
static
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
626
|
+
static stdlib_complex128_t mul( const double y, const stdlib_complex128_t x ) {
|
|
627
|
+
double xre;
|
|
628
|
+
double xim;
|
|
629
|
+
double re;
|
|
630
|
+
double im;
|
|
546
631
|
|
|
547
|
-
|
|
632
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
548
633
|
|
|
549
634
|
re = xre * y;
|
|
550
635
|
im = xim * y;
|
|
551
636
|
|
|
552
|
-
return
|
|
637
|
+
return stdlib_complex128( re, im );
|
|
553
638
|
}
|
|
554
639
|
|
|
555
640
|
// ...
|
|
@@ -562,7 +647,7 @@ static stdlib_complex64_t mul( const stdlib_complex64_t x, const int32_t y ) {
|
|
|
562
647
|
* @return Node-API value
|
|
563
648
|
*/
|
|
564
649
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
565
|
-
return
|
|
650
|
+
return stdlib_math_base_napi_dz_z( env, info, mul );
|
|
566
651
|
}
|
|
567
652
|
|
|
568
653
|
// ...
|
|
@@ -572,74 +657,96 @@ The function accepts the following arguments:
|
|
|
572
657
|
|
|
573
658
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
574
659
|
- **info**: `[in] napi_callback_info` callback data.
|
|
575
|
-
- **fcn**: `[in]
|
|
660
|
+
- **fcn**: `[in] stdlib_complex128_t (*fcn)( double, stdlib_complex128_t )` binary function.
|
|
576
661
|
|
|
577
662
|
```c
|
|
578
|
-
void
|
|
663
|
+
void stdlib_math_base_napi_dz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( double, stdlib_complex128_t ) );
|
|
579
664
|
```
|
|
580
665
|
|
|
581
|
-
####
|
|
666
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_FC_C( fcn )
|
|
582
667
|
|
|
583
|
-
Macro for registering a Node-API module exporting an interface
|
|
668
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number.
|
|
584
669
|
|
|
585
670
|
```c
|
|
586
|
-
|
|
587
|
-
|
|
671
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
672
|
+
#include "stdlib/complex/float32/reim.h"
|
|
673
|
+
|
|
674
|
+
static stdlib_complex64_t mul( const float y, const stdlib_complex64_t x ) {
|
|
675
|
+
float xre;
|
|
676
|
+
float xim;
|
|
677
|
+
float re;
|
|
678
|
+
float im;
|
|
679
|
+
|
|
680
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
681
|
+
|
|
682
|
+
re = xre * y;
|
|
683
|
+
im = xim * y;
|
|
684
|
+
|
|
685
|
+
return stdlib_complex64( re, im );
|
|
588
686
|
}
|
|
589
687
|
|
|
590
688
|
// ...
|
|
591
689
|
|
|
592
690
|
// Register a Node-API module:
|
|
593
|
-
|
|
691
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FC_C( mul );
|
|
594
692
|
```
|
|
595
693
|
|
|
596
694
|
The macro expects the following arguments:
|
|
597
695
|
|
|
598
|
-
- **fcn**: `
|
|
696
|
+
- **fcn**: `stdlib_complex64_t (*fcn)( float, stdlib_complex64_t )` binary function.
|
|
599
697
|
|
|
600
698
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
601
699
|
|
|
602
|
-
####
|
|
700
|
+
#### stdlib_math_base_napi_fc_c( env, info, fcn )
|
|
603
701
|
|
|
604
|
-
|
|
702
|
+
Invokes a binary function accepting a single-precision floating-point number and a single-precision complex floating-point number and returning a single-precision complex floating-point number.
|
|
605
703
|
|
|
606
704
|
```c
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
705
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
706
|
+
#include "stdlib/complex/float32/reim.h"
|
|
707
|
+
#include <node_api.h>
|
|
610
708
|
|
|
611
709
|
// ...
|
|
612
710
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
711
|
+
static stdlib_complex64_t mul( const float y, const stdlib_complex64_t x ) {
|
|
712
|
+
float xre;
|
|
713
|
+
float xim;
|
|
714
|
+
float re;
|
|
715
|
+
float im;
|
|
618
716
|
|
|
619
|
-
|
|
717
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
620
718
|
|
|
621
|
-
|
|
719
|
+
re = xre * y;
|
|
720
|
+
im = xim * y;
|
|
622
721
|
|
|
623
|
-
|
|
722
|
+
return stdlib_complex64( re, im );
|
|
723
|
+
}
|
|
624
724
|
|
|
625
|
-
|
|
725
|
+
// ...
|
|
626
726
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
727
|
+
/**
|
|
728
|
+
* Receives JavaScript callback invocation data.
|
|
729
|
+
*
|
|
730
|
+
* @param env environment under which the function is invoked
|
|
731
|
+
* @param info callback data
|
|
732
|
+
* @return Node-API value
|
|
733
|
+
*/
|
|
734
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
735
|
+
return stdlib_math_base_napi_fc_c( env, info, mul );
|
|
630
736
|
}
|
|
631
737
|
|
|
632
738
|
// ...
|
|
633
|
-
|
|
634
|
-
// Register a Node-API module:
|
|
635
|
-
STDLIB_MATH_BASE_NAPI_MODULE_II_D( add );
|
|
636
739
|
```
|
|
637
740
|
|
|
638
|
-
The
|
|
741
|
+
The function accepts the following arguments:
|
|
639
742
|
|
|
640
|
-
- **
|
|
743
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
744
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
745
|
+
- **fcn**: `[in] stdlib_complex64_t (*fcn)( float, stdlib_complex64_t )` binary function.
|
|
641
746
|
|
|
642
|
-
|
|
747
|
+
```c
|
|
748
|
+
void stdlib_math_base_napi_fc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( float, stdlib_complex64_t ) );
|
|
749
|
+
```
|
|
643
750
|
|
|
644
751
|
#### STDLIB_MATH_BASE_NAPI_MODULE_FF_F( fcn )
|
|
645
752
|
|
|
@@ -662,136 +769,684 @@ The macro expects the following arguments:
|
|
|
662
769
|
|
|
663
770
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
664
771
|
|
|
665
|
-
####
|
|
772
|
+
#### stdlib_math_base_napi_ff_f( env, info, fcn )
|
|
666
773
|
|
|
667
|
-
|
|
774
|
+
Invokes a binary function accepting and returning single-precision floating-point numbers.
|
|
668
775
|
|
|
669
776
|
```c
|
|
670
|
-
#include
|
|
671
|
-
#include "stdlib/complex/float64/reim.h"
|
|
777
|
+
#include <node_api.h>
|
|
672
778
|
|
|
673
|
-
|
|
674
|
-
double xre;
|
|
675
|
-
double xim;
|
|
676
|
-
double yre;
|
|
677
|
-
double yim;
|
|
678
|
-
double re;
|
|
679
|
-
double im;
|
|
779
|
+
// ...
|
|
680
780
|
|
|
681
|
-
|
|
682
|
-
|
|
781
|
+
static float addf( const float x, const float y ) {
|
|
782
|
+
return x + y;
|
|
783
|
+
}
|
|
683
784
|
|
|
684
|
-
|
|
685
|
-
im = xim + yim;
|
|
785
|
+
// ...
|
|
686
786
|
|
|
687
|
-
|
|
787
|
+
/**
|
|
788
|
+
* Receives JavaScript callback invocation data.
|
|
789
|
+
*
|
|
790
|
+
* @param env environment under which the function is invoked
|
|
791
|
+
* @param info callback data
|
|
792
|
+
* @return Node-API value
|
|
793
|
+
*/
|
|
794
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
795
|
+
return stdlib_math_base_napi_ff_f( env, info, addf );
|
|
688
796
|
}
|
|
689
797
|
|
|
690
798
|
// ...
|
|
691
|
-
|
|
692
|
-
// Register a Node-API module:
|
|
693
|
-
STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( add );
|
|
694
799
|
```
|
|
695
800
|
|
|
696
|
-
The
|
|
697
|
-
|
|
698
|
-
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t )` binary function.
|
|
699
|
-
|
|
700
|
-
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
701
|
-
|
|
702
|
-
#### STDLIB_MATH_BASE_NAPI_MODULE_CC_C( fcn )
|
|
801
|
+
The function accepts the following arguments:
|
|
703
802
|
|
|
704
|
-
|
|
803
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
804
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
805
|
+
- **fcn**: `[in] float (*fcn)( float, float )` binary function.
|
|
705
806
|
|
|
706
807
|
```c
|
|
707
|
-
|
|
708
|
-
|
|
808
|
+
void stdlib_math_base_napi_ff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float ) );
|
|
809
|
+
```
|
|
709
810
|
|
|
710
|
-
|
|
711
|
-
float xre;
|
|
712
|
-
float xim;
|
|
713
|
-
float yre;
|
|
714
|
-
float yim;
|
|
715
|
-
float re;
|
|
716
|
-
float im;
|
|
811
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_FI_F( fcn )
|
|
717
812
|
|
|
718
|
-
|
|
719
|
-
stdlib_complex64_reim( y, &yre, &yim );
|
|
813
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number.
|
|
720
814
|
|
|
721
|
-
|
|
722
|
-
|
|
815
|
+
```c
|
|
816
|
+
#include <stdint.h>
|
|
723
817
|
|
|
724
|
-
|
|
818
|
+
static float mulf( const float x, const int32_t y ) {
|
|
819
|
+
return x * y;
|
|
725
820
|
}
|
|
726
821
|
|
|
727
822
|
// ...
|
|
728
823
|
|
|
729
824
|
// Register a Node-API module:
|
|
730
|
-
|
|
825
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FI_F( mulf );
|
|
731
826
|
```
|
|
732
827
|
|
|
733
828
|
The macro expects the following arguments:
|
|
734
829
|
|
|
735
|
-
- **fcn**: `
|
|
830
|
+
- **fcn**: `float (*fcn)( float, int32_t )` binary function.
|
|
736
831
|
|
|
737
832
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
738
833
|
|
|
739
|
-
####
|
|
834
|
+
#### stdlib_math_base_napi_fi_f( env, info, fcn )
|
|
740
835
|
|
|
741
|
-
|
|
836
|
+
Invokes a binary function accepting a single-precision floating-point number and a signed 32-bit integer and returning a single-precision floating-point number.
|
|
742
837
|
|
|
743
838
|
```c
|
|
839
|
+
#include <node_api.h>
|
|
744
840
|
#include <stdint.h>
|
|
745
841
|
|
|
746
|
-
|
|
842
|
+
// ...
|
|
843
|
+
|
|
844
|
+
static float mulf( const float x, const int32_t y ) {
|
|
747
845
|
return x * y;
|
|
748
846
|
}
|
|
749
847
|
|
|
750
848
|
// ...
|
|
751
849
|
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
850
|
+
/**
|
|
851
|
+
* Receives JavaScript callback invocation data.
|
|
852
|
+
*
|
|
853
|
+
* @param env environment under which the function is invoked
|
|
854
|
+
* @param info callback data
|
|
855
|
+
* @return Node-API value
|
|
856
|
+
*/
|
|
857
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
858
|
+
return stdlib_math_base_napi_fi_f( env, info, mulf );
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
// ...
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
The function accepts the following arguments:
|
|
865
|
+
|
|
866
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
867
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
868
|
+
- **fcn**: `[in] float (*fcn)( float, int32_t )` binary function.
|
|
869
|
+
|
|
870
|
+
```c
|
|
871
|
+
void stdlib_math_base_napi_fi_f( napi_env env, napi_callback_info info, float (*fcn)( float, int32_t ) );
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_ID_D( fcn )
|
|
875
|
+
|
|
876
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number.
|
|
877
|
+
|
|
878
|
+
```c
|
|
879
|
+
#include <stdint.h>
|
|
880
|
+
|
|
881
|
+
static double mul( const int32_t x, const double y ) {
|
|
882
|
+
return x * y;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
// ...
|
|
886
|
+
|
|
887
|
+
// Register a Node-API module:
|
|
888
|
+
STDLIB_MATH_BASE_NAPI_MODULE_ID_D( mul );
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
The macro expects the following arguments:
|
|
892
|
+
|
|
893
|
+
- **fcn**: `double (*fcn)( int32_t, double )` binary function.
|
|
894
|
+
|
|
895
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
896
|
+
|
|
897
|
+
#### stdlib_math_base_napi_id_d( env, info, fcn )
|
|
898
|
+
|
|
899
|
+
Invokes a binary function accepting a signed 32-bit integer and a double-precision floating-point number and returning a double-precision floating-point number.
|
|
900
|
+
|
|
901
|
+
```c
|
|
902
|
+
#include <node_api.h>
|
|
903
|
+
#include <stdint.h>
|
|
904
|
+
|
|
905
|
+
// ...
|
|
906
|
+
|
|
907
|
+
static double mul( const int32_t x, const double y ) {
|
|
908
|
+
return x * y;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
// ...
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Receives JavaScript callback invocation data.
|
|
915
|
+
*
|
|
916
|
+
* @param env environment under which the function is invoked
|
|
917
|
+
* @param info callback data
|
|
918
|
+
* @return Node-API value
|
|
919
|
+
*/
|
|
920
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
921
|
+
return stdlib_math_base_napi_id_d( env, info, mul );
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
// ...
|
|
925
|
+
```
|
|
926
|
+
|
|
927
|
+
The function accepts the following arguments:
|
|
928
|
+
|
|
929
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
930
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
931
|
+
- **fcn**: `[in] double (*fcn)( int32_t, double )` binary function.
|
|
932
|
+
|
|
933
|
+
```c
|
|
934
|
+
void stdlib_math_base_napi_id_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, double ) );
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_II_D( fcn )
|
|
938
|
+
|
|
939
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting signed 32-bit integers and returning a double-precision floating-point number.
|
|
940
|
+
|
|
941
|
+
```c
|
|
942
|
+
#include <stdint.h>
|
|
943
|
+
|
|
944
|
+
static double add( const int32_t x, const int32_t y ) {
|
|
945
|
+
return x + y;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
// ...
|
|
949
|
+
|
|
950
|
+
// Register a Node-API module:
|
|
951
|
+
STDLIB_MATH_BASE_NAPI_MODULE_II_D( add );
|
|
952
|
+
```
|
|
953
|
+
|
|
954
|
+
The macro expects the following arguments:
|
|
955
|
+
|
|
956
|
+
- **fcn**: `double (*fcn)( int32_t, int32_t )` binary function.
|
|
957
|
+
|
|
958
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
959
|
+
|
|
960
|
+
#### stdlib_math_base_napi_ii_d( env, info, fcn )
|
|
961
|
+
|
|
962
|
+
Invokes a binary function accepting signed 32-bit integers and returning a double-precision floating-point number.
|
|
963
|
+
|
|
964
|
+
```c
|
|
965
|
+
#include <node_api.h>
|
|
966
|
+
#include <stdint.h>
|
|
967
|
+
|
|
968
|
+
// ...
|
|
969
|
+
|
|
970
|
+
static double mul( const int32_t x, const int32_t y ) {
|
|
971
|
+
return x * y;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
// ...
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* Receives JavaScript callback invocation data.
|
|
978
|
+
*
|
|
979
|
+
* @param env environment under which the function is invoked
|
|
980
|
+
* @param info callback data
|
|
981
|
+
* @return Node-API value
|
|
982
|
+
*/
|
|
983
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
984
|
+
return stdlib_math_base_napi_ii_d( env, info, mul );
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
// ...
|
|
988
|
+
```
|
|
989
|
+
|
|
990
|
+
The function accepts the following arguments:
|
|
991
|
+
|
|
992
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
993
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
994
|
+
- **fcn**: `[in] double (*fcn)( int32_t, int32_t )` binary function.
|
|
995
|
+
|
|
996
|
+
```c
|
|
997
|
+
void stdlib_math_base_napi_ii_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t ) );
|
|
998
|
+
```
|
|
999
|
+
|
|
1000
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn )
|
|
1001
|
+
|
|
1002
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting signed 32-bit integers and returning a single-precision floating-point number.
|
|
1003
|
+
|
|
1004
|
+
```c
|
|
1005
|
+
#include <stdint.h>
|
|
1006
|
+
|
|
1007
|
+
static float fcn( const int32_t x, const int32_t y ) {
|
|
1008
|
+
// ...
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
// ...
|
|
1012
|
+
|
|
1013
|
+
// Register a Node-API module:
|
|
1014
|
+
STDLIB_MATH_BASE_NAPI_MODULE_II_F( fcn );
|
|
1015
|
+
```
|
|
1016
|
+
|
|
1017
|
+
The macro expects the following arguments:
|
|
1018
|
+
|
|
1019
|
+
- **fcn**: `float (*fcn)( int32_t, int32_t )` binary function.
|
|
1020
|
+
|
|
1021
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
1022
|
+
|
|
1023
|
+
#### stdlib_math_base_napi_ii_f( env, info, fcn )
|
|
1024
|
+
|
|
1025
|
+
Invokes a binary function accepting signed 32-bit integers and returning a single-precision floating-point number.
|
|
1026
|
+
|
|
1027
|
+
```c
|
|
1028
|
+
#include <node_api.h>
|
|
1029
|
+
#include <stdint.h>
|
|
1030
|
+
|
|
1031
|
+
// ...
|
|
1032
|
+
|
|
1033
|
+
static float fcn( const int32_t x, const int32_t y ) {
|
|
1034
|
+
// ...
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
// ...
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Receives JavaScript callback invocation data.
|
|
1041
|
+
*
|
|
1042
|
+
* @param env environment under which the function is invoked
|
|
1043
|
+
* @param info callback data
|
|
1044
|
+
* @return Node-API value
|
|
1045
|
+
*/
|
|
1046
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1047
|
+
return stdlib_math_base_napi_ii_f( env, info, fcn );
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// ...
|
|
1051
|
+
```
|
|
1052
|
+
|
|
1053
|
+
The function accepts the following arguments:
|
|
1054
|
+
|
|
1055
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1056
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1057
|
+
- **fcn**: `[in] float (*fcn)( int32_t, int32_t )` binary function.
|
|
1058
|
+
|
|
1059
|
+
```c
|
|
1060
|
+
void stdlib_math_base_napi_ii_f( napi_env env, napi_callback_info info, float (*fcn)( int32_t, int32_t ) );
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_II_I( fcn )
|
|
1064
|
+
|
|
1065
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning signed 32-bit integers.
|
|
1066
|
+
|
|
1067
|
+
```c
|
|
1068
|
+
#include <stdint.h>
|
|
1069
|
+
|
|
1070
|
+
static int32_t add( const int32_t x, const int32_t y ) {
|
|
1071
|
+
return x + y;
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
// ...
|
|
1075
|
+
|
|
1076
|
+
// Register a Node-API module:
|
|
1077
|
+
STDLIB_MATH_BASE_NAPI_MODULE_II_I( add );
|
|
1078
|
+
```
|
|
1079
|
+
|
|
1080
|
+
The macro expects the following arguments:
|
|
1081
|
+
|
|
1082
|
+
- **fcn**: `int32_t (*fcn)( int32_t, int32_t )` binary function.
|
|
1083
|
+
|
|
1084
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
1085
|
+
|
|
1086
|
+
#### stdlib_math_base_napi_ii_i( env, info, fcn )
|
|
1087
|
+
|
|
1088
|
+
Invokes a binary function accepting and returning signed 32-bit integers.
|
|
1089
|
+
|
|
1090
|
+
```c
|
|
1091
|
+
#include <node_api.h>
|
|
1092
|
+
#include <stdint.h>
|
|
1093
|
+
|
|
1094
|
+
// ...
|
|
1095
|
+
|
|
1096
|
+
static int32_t mul( const int32_t x, const int32_t y ) {
|
|
1097
|
+
return x * y;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
// ...
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* Receives JavaScript callback invocation data.
|
|
1104
|
+
*
|
|
1105
|
+
* @param env environment under which the function is invoked
|
|
1106
|
+
* @param info callback data
|
|
1107
|
+
* @return Node-API value
|
|
1108
|
+
*/
|
|
1109
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1110
|
+
return stdlib_math_base_napi_ii_i( env, info, mul );
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
// ...
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1116
|
+
The function accepts the following arguments:
|
|
1117
|
+
|
|
1118
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1119
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1120
|
+
- **fcn**: `[in] int32_t (*fcn)( int32_t, int32_t )` binary function.
|
|
1121
|
+
|
|
1122
|
+
```c
|
|
1123
|
+
void stdlib_math_base_napi_ii_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t, int32_t ) );
|
|
1124
|
+
```
|
|
1125
|
+
|
|
1126
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_KK_K( fcn )
|
|
1127
|
+
|
|
1128
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning signed 16-bit integers.
|
|
1129
|
+
|
|
1130
|
+
```c
|
|
1131
|
+
#include <stdint.h>
|
|
1132
|
+
|
|
1133
|
+
static int16_t add( const int16_t x, const int16_t y ) {
|
|
1134
|
+
return x + y;
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
// ...
|
|
1138
|
+
|
|
1139
|
+
// Register a Node-API module:
|
|
1140
|
+
STDLIB_MATH_BASE_NAPI_MODULE_KK_K( add );
|
|
1141
|
+
```
|
|
1142
|
+
|
|
1143
|
+
The macro expects the following arguments:
|
|
1144
|
+
|
|
1145
|
+
- **fcn**: `int16_t (*fcn)( int16_t, int16_t )` binary function.
|
|
1146
|
+
|
|
1147
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
1148
|
+
|
|
1149
|
+
#### stdlib_math_base_napi_kk_k( env, info, fcn )
|
|
1150
|
+
|
|
1151
|
+
Invokes a binary function accepting and returning signed 16-bit integers.
|
|
1152
|
+
|
|
1153
|
+
```c
|
|
1154
|
+
#include <node_api.h>
|
|
1155
|
+
#include <stdint.h>
|
|
1156
|
+
|
|
1157
|
+
// ...
|
|
1158
|
+
|
|
1159
|
+
static int16_t add( const int16_t x, const int16_t y ) {
|
|
1160
|
+
return x + y;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
// ...
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Receives JavaScript callback invocation data.
|
|
1167
|
+
*
|
|
1168
|
+
* @param env environment under which the function is invoked
|
|
1169
|
+
* @param info callback data
|
|
1170
|
+
* @return Node-API value
|
|
1171
|
+
*/
|
|
1172
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1173
|
+
return stdlib_math_base_napi_kk_k( env, info, add );
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
// ...
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
The function accepts the following arguments:
|
|
1180
|
+
|
|
1181
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1182
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1183
|
+
- **fcn**: `[in] int16_t (*fcn)( int16_t, int16_t )` binary function.
|
|
1184
|
+
|
|
1185
|
+
```c
|
|
1186
|
+
void stdlib_math_base_napi_kk_k( napi_env env, napi_callback_info info, int16_t (*fcn)( int16_t, int16_t ) );
|
|
1187
|
+
```
|
|
1188
|
+
|
|
1189
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_LL_D( fcn )
|
|
1190
|
+
|
|
1191
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting signed 64-bit integers and returning a double-precision floating-point number.
|
|
1192
|
+
|
|
1193
|
+
```c
|
|
1194
|
+
#include <stdint.h>
|
|
1195
|
+
|
|
1196
|
+
static double fcn( const int64_t x, const int64_t y ) {
|
|
1197
|
+
// ...
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
// ...
|
|
1201
|
+
|
|
1202
|
+
// Register a Node-API module:
|
|
1203
|
+
STDLIB_MATH_BASE_NAPI_MODULE_LL_D( fcn );
|
|
1204
|
+
```
|
|
1205
|
+
|
|
1206
|
+
The macro expects the following arguments:
|
|
1207
|
+
|
|
1208
|
+
- **fcn**: `double (*fcn)( int64_t, int64_t )` binary function.
|
|
1209
|
+
|
|
1210
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
1211
|
+
|
|
1212
|
+
#### stdlib_math_base_napi_ll_d( env, info, fcn )
|
|
1213
|
+
|
|
1214
|
+
Invokes a binary function accepting signed 64-bit integers and returning a double-precision floating-point number.
|
|
1215
|
+
|
|
1216
|
+
```c
|
|
1217
|
+
#include <node_api.h>
|
|
1218
|
+
#include <stdint.h>
|
|
1219
|
+
|
|
1220
|
+
// ...
|
|
1221
|
+
|
|
1222
|
+
static double fcn( const int64_t x, const int64_t y ) {
|
|
1223
|
+
// ...
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
// ...
|
|
1227
|
+
|
|
1228
|
+
/**
|
|
1229
|
+
* Receives JavaScript callback invocation data.
|
|
1230
|
+
*
|
|
1231
|
+
* @param env environment under which the function is invoked
|
|
1232
|
+
* @param info callback data
|
|
1233
|
+
* @return Node-API value
|
|
1234
|
+
*/
|
|
1235
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1236
|
+
return stdlib_math_base_napi_ll_d( env, info, fcn );
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
// ...
|
|
1240
|
+
```
|
|
1241
|
+
|
|
1242
|
+
The function accepts the following arguments:
|
|
1243
|
+
|
|
1244
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1245
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1246
|
+
- **fcn**: `[in] double (*fcn)( int64_t, int64_t )` binary function.
|
|
1247
|
+
|
|
1248
|
+
```c
|
|
1249
|
+
void stdlib_math_base_napi_ll_d( napi_env env, napi_callback_info info, double (*fcn)( int64_t, int64_t ) );
|
|
1250
|
+
```
|
|
1251
|
+
|
|
1252
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_SS_S( fcn )
|
|
1253
|
+
|
|
1254
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning signed 8-bit integers.
|
|
1255
|
+
|
|
1256
|
+
```c
|
|
1257
|
+
#include <stdint.h>
|
|
1258
|
+
|
|
1259
|
+
static int8_t add( const int8_t x, const int8_t y ) {
|
|
1260
|
+
return x + y;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
// ...
|
|
1264
|
+
|
|
1265
|
+
// Register a Node-API module:
|
|
1266
|
+
STDLIB_MATH_BASE_NAPI_MODULE_SS_S( add );
|
|
1267
|
+
```
|
|
1268
|
+
|
|
1269
|
+
The macro expects the following arguments:
|
|
1270
|
+
|
|
1271
|
+
- **fcn**: `int8_t (*fcn)( int8_t, int8_t )` binary function.
|
|
1272
|
+
|
|
1273
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
1274
|
+
|
|
1275
|
+
#### stdlib_math_base_napi_ss_s( env, info, fcn )
|
|
1276
|
+
|
|
1277
|
+
Invokes a binary function accepting and returning signed 8-bit integers.
|
|
1278
|
+
|
|
1279
|
+
```c
|
|
1280
|
+
#include <node_api.h>
|
|
1281
|
+
#include <stdint.h>
|
|
1282
|
+
|
|
1283
|
+
// ...
|
|
1284
|
+
|
|
1285
|
+
static int8_t add( const int8_t x, const int8_t y ) {
|
|
1286
|
+
return x + y;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
// ...
|
|
1290
|
+
|
|
1291
|
+
/**
|
|
1292
|
+
* Receives JavaScript callback invocation data.
|
|
1293
|
+
*
|
|
1294
|
+
* @param env environment under which the function is invoked
|
|
1295
|
+
* @param info callback data
|
|
1296
|
+
* @return Node-API value
|
|
1297
|
+
*/
|
|
1298
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1299
|
+
return stdlib_math_base_napi_ss_s( env, info, add );
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
// ...
|
|
1303
|
+
```
|
|
1304
|
+
|
|
1305
|
+
The function accepts the following arguments:
|
|
1306
|
+
|
|
1307
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1308
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1309
|
+
- **fcn**: `[in] int8_t (*fcn)( int8_t, int8_t )` binary function.
|
|
1310
|
+
|
|
1311
|
+
```c
|
|
1312
|
+
void stdlib_math_base_napi_ss_s( napi_env env, napi_callback_info info, int8_t (*fcn)( int8_t, int8_t ) );
|
|
1313
|
+
```
|
|
1314
|
+
|
|
1315
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_TT_T( fcn )
|
|
1316
|
+
|
|
1317
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning unsigned 16-bit integers.
|
|
1318
|
+
|
|
1319
|
+
```c
|
|
1320
|
+
#include <stdint.h>
|
|
1321
|
+
|
|
1322
|
+
static uint16_t add( const uint16_t x, const uint16_t y ) {
|
|
1323
|
+
return x + y;
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
// ...
|
|
1327
|
+
|
|
1328
|
+
// Register a Node-API module:
|
|
1329
|
+
STDLIB_MATH_BASE_NAPI_MODULE_TT_T( add );
|
|
1330
|
+
```
|
|
1331
|
+
|
|
1332
|
+
The macro expects the following arguments:
|
|
1333
|
+
|
|
1334
|
+
- **fcn**: `uint16_t (*fcn)( uint16_t, uint16_t )` binary function.
|
|
1335
|
+
|
|
1336
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
1337
|
+
|
|
1338
|
+
#### stdlib_math_base_napi_tt_t( env, info, fcn )
|
|
1339
|
+
|
|
1340
|
+
Invokes a binary function accepting and returning unsigned 16-bit integers.
|
|
1341
|
+
|
|
1342
|
+
```c
|
|
1343
|
+
#include <node_api.h>
|
|
1344
|
+
#include <stdint.h>
|
|
1345
|
+
|
|
1346
|
+
// ...
|
|
1347
|
+
|
|
1348
|
+
static uint16_t add( const uint16_t x, const uint16_t y ) {
|
|
1349
|
+
return x + y;
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
// ...
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* Receives JavaScript callback invocation data.
|
|
1356
|
+
*
|
|
1357
|
+
* @param env environment under which the function is invoked
|
|
1358
|
+
* @param info callback data
|
|
1359
|
+
* @return Node-API value
|
|
1360
|
+
*/
|
|
1361
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1362
|
+
return stdlib_math_base_napi_tt_t( env, info, add );
|
|
1363
|
+
}
|
|
761
1364
|
|
|
762
|
-
|
|
1365
|
+
// ...
|
|
1366
|
+
```
|
|
763
1367
|
|
|
764
|
-
|
|
1368
|
+
The function accepts the following arguments:
|
|
1369
|
+
|
|
1370
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1371
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1372
|
+
- **fcn**: `[in] uint16_t (*fcn)( uint16_t, uint16_t )` binary function.
|
|
1373
|
+
|
|
1374
|
+
```c
|
|
1375
|
+
void stdlib_math_base_napi_tt_t( napi_env env, napi_callback_info info, uint16_t (*fcn)( uint16_t, uint16_t ) );
|
|
1376
|
+
```
|
|
1377
|
+
|
|
1378
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_UU_U( fcn )
|
|
1379
|
+
|
|
1380
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning unsigned 32-bit integers.
|
|
765
1381
|
|
|
766
1382
|
```c
|
|
767
1383
|
#include <stdint.h>
|
|
768
1384
|
|
|
769
|
-
static
|
|
770
|
-
return x
|
|
1385
|
+
static uint32_t add( const uint32_t x, const uint32_t y ) {
|
|
1386
|
+
return x + y;
|
|
771
1387
|
}
|
|
772
1388
|
|
|
773
1389
|
// ...
|
|
774
1390
|
|
|
775
1391
|
// Register a Node-API module:
|
|
776
|
-
|
|
1392
|
+
STDLIB_MATH_BASE_NAPI_MODULE_UU_U( add );
|
|
777
1393
|
```
|
|
778
1394
|
|
|
779
1395
|
The macro expects the following arguments:
|
|
780
1396
|
|
|
781
|
-
- **fcn**: `
|
|
1397
|
+
- **fcn**: `uint32_t (*fcn)( uint32_t, uint32_t )` binary function.
|
|
782
1398
|
|
|
783
1399
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
784
1400
|
|
|
785
|
-
####
|
|
1401
|
+
#### stdlib_math_base_napi_uu_u( env, info, fcn )
|
|
786
1402
|
|
|
787
|
-
|
|
1403
|
+
Invokes a binary function accepting and returning unsigned 32-bit integers.
|
|
1404
|
+
|
|
1405
|
+
```c
|
|
1406
|
+
#include <node_api.h>
|
|
1407
|
+
#include <stdint.h>
|
|
1408
|
+
|
|
1409
|
+
// ...
|
|
1410
|
+
|
|
1411
|
+
static uint32_t add( const uint32_t x, const uint32_t y ) {
|
|
1412
|
+
return x + y;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
// ...
|
|
1416
|
+
|
|
1417
|
+
/**
|
|
1418
|
+
* Receives JavaScript callback invocation data.
|
|
1419
|
+
*
|
|
1420
|
+
* @param env environment under which the function is invoked
|
|
1421
|
+
* @param info callback data
|
|
1422
|
+
* @return Node-API value
|
|
1423
|
+
*/
|
|
1424
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1425
|
+
return stdlib_math_base_napi_uu_u( env, info, add );
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
// ...
|
|
1429
|
+
```
|
|
1430
|
+
|
|
1431
|
+
The function accepts the following arguments:
|
|
1432
|
+
|
|
1433
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1434
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1435
|
+
- **fcn**: `[in] uint32_t (*fcn)( uint32_t, uint32_t )` binary function.
|
|
1436
|
+
|
|
1437
|
+
```c
|
|
1438
|
+
void stdlib_math_base_napi_uu_u( napi_env env, napi_callback_info info, uint32_t (*fcn)( uint32_t, uint32_t ) );
|
|
1439
|
+
```
|
|
1440
|
+
|
|
1441
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( fcn )
|
|
1442
|
+
|
|
1443
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number.
|
|
788
1444
|
|
|
789
1445
|
```c
|
|
790
1446
|
#include "stdlib/complex/float64/ctor.h"
|
|
791
1447
|
#include "stdlib/complex/float64/reim.h"
|
|
792
|
-
#include <stdint.h>
|
|
793
1448
|
|
|
794
|
-
static stdlib_complex128_t mul( const stdlib_complex128_t x, const
|
|
1449
|
+
static stdlib_complex128_t mul( const stdlib_complex128_t x, const double y ) {
|
|
795
1450
|
double xre;
|
|
796
1451
|
double xim;
|
|
797
1452
|
double re;
|
|
@@ -808,59 +1463,76 @@ static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) {
|
|
|
808
1463
|
// ...
|
|
809
1464
|
|
|
810
1465
|
// Register a Node-API module:
|
|
811
|
-
|
|
1466
|
+
STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( mul );
|
|
812
1467
|
```
|
|
813
1468
|
|
|
814
1469
|
The macro expects the following arguments:
|
|
815
1470
|
|
|
816
|
-
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t,
|
|
1471
|
+
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, double )` binary function.
|
|
817
1472
|
|
|
818
1473
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
819
1474
|
|
|
820
|
-
####
|
|
1475
|
+
#### stdlib_math_base_napi_zd_z( env, info, fcn )
|
|
821
1476
|
|
|
822
|
-
|
|
1477
|
+
Invokes a binary function accepting a double-precision complex floating-point number and a double-precision floating-point number and returning a double-precision complex floating-point number.
|
|
823
1478
|
|
|
824
1479
|
```c
|
|
825
|
-
#include "stdlib/complex/
|
|
826
|
-
#include "stdlib/complex/
|
|
827
|
-
#include <
|
|
1480
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1481
|
+
#include "stdlib/complex/float64/reim.h"
|
|
1482
|
+
#include <node_api.h>
|
|
828
1483
|
|
|
829
|
-
|
|
830
|
-
float xre;
|
|
831
|
-
float xim;
|
|
832
|
-
float re;
|
|
833
|
-
float im;
|
|
1484
|
+
// ...
|
|
834
1485
|
|
|
835
|
-
|
|
1486
|
+
static stdlib_complex128_t mul( const stdlib_complex128_t x, const double y ) {
|
|
1487
|
+
double xre;
|
|
1488
|
+
double xim;
|
|
1489
|
+
double re;
|
|
1490
|
+
double im;
|
|
1491
|
+
|
|
1492
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
836
1493
|
|
|
837
1494
|
re = xre * y;
|
|
838
1495
|
im = xim * y;
|
|
839
1496
|
|
|
840
|
-
return
|
|
1497
|
+
return stdlib_complex128( re, im );
|
|
841
1498
|
}
|
|
842
1499
|
|
|
843
1500
|
// ...
|
|
844
1501
|
|
|
845
|
-
|
|
846
|
-
|
|
1502
|
+
/**
|
|
1503
|
+
* Receives JavaScript callback invocation data.
|
|
1504
|
+
*
|
|
1505
|
+
* @param env environment under which the function is invoked
|
|
1506
|
+
* @param info callback data
|
|
1507
|
+
* @return Node-API value
|
|
1508
|
+
*/
|
|
1509
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1510
|
+
return stdlib_math_base_napi_zd_z( env, info, mul );
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
// ...
|
|
847
1514
|
```
|
|
848
1515
|
|
|
849
|
-
The
|
|
1516
|
+
The function accepts the following arguments:
|
|
850
1517
|
|
|
851
|
-
- **
|
|
1518
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1519
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1520
|
+
- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, double )` binary function.
|
|
852
1521
|
|
|
853
|
-
|
|
1522
|
+
```c
|
|
1523
|
+
void stdlib_math_base_napi_zd_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, double ) );
|
|
1524
|
+
```
|
|
854
1525
|
|
|
855
|
-
####
|
|
1526
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( fcn )
|
|
856
1527
|
|
|
857
|
-
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a
|
|
1528
|
+
Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a signed 32-bit and returning a double-precision complex floating-point number.
|
|
858
1529
|
|
|
859
1530
|
```c
|
|
860
1531
|
#include "stdlib/complex/float64/ctor.h"
|
|
861
1532
|
#include "stdlib/complex/float64/reim.h"
|
|
1533
|
+
#include <stdint.h>
|
|
862
1534
|
|
|
863
|
-
static stdlib_complex128_t mul( const stdlib_complex128_t x, const
|
|
1535
|
+
static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) {
|
|
864
1536
|
double xre;
|
|
865
1537
|
double xim;
|
|
866
1538
|
double re;
|
|
@@ -877,49 +1549,158 @@ static stdlib_complex128_t mul( const stdlib_complex128_t x, const double y ) {
|
|
|
877
1549
|
// ...
|
|
878
1550
|
|
|
879
1551
|
// Register a Node-API module:
|
|
880
|
-
|
|
1552
|
+
STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( mul );
|
|
881
1553
|
```
|
|
882
1554
|
|
|
883
1555
|
The macro expects the following arguments:
|
|
884
1556
|
|
|
885
|
-
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t,
|
|
1557
|
+
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t )` binary function.
|
|
886
1558
|
|
|
887
1559
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
888
1560
|
|
|
889
|
-
####
|
|
1561
|
+
#### stdlib_math_base_napi_zi_z( env, info, fcn )
|
|
890
1562
|
|
|
891
|
-
|
|
1563
|
+
Invokes a binary function accepting a double-precision complex floating-point number and a signed 32-bit integer and returning a double-precision complex floating-point number.
|
|
892
1564
|
|
|
893
1565
|
```c
|
|
894
|
-
#include "stdlib/complex/
|
|
895
|
-
#include "stdlib/complex/
|
|
1566
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1567
|
+
#include "stdlib/complex/float64/reim.h"
|
|
1568
|
+
#include <node_api.h>
|
|
1569
|
+
#include <stdint.h>
|
|
896
1570
|
|
|
897
|
-
|
|
898
|
-
float xre;
|
|
899
|
-
float xim;
|
|
900
|
-
float re;
|
|
901
|
-
float im;
|
|
1571
|
+
// ...
|
|
902
1572
|
|
|
903
|
-
|
|
1573
|
+
static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) {
|
|
1574
|
+
double xre;
|
|
1575
|
+
double xim;
|
|
1576
|
+
double re;
|
|
1577
|
+
double im;
|
|
1578
|
+
|
|
1579
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
904
1580
|
|
|
905
1581
|
re = xre * y;
|
|
906
1582
|
im = xim * y;
|
|
907
1583
|
|
|
908
|
-
return
|
|
1584
|
+
return stdlib_complex128( re, im );
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
// ...
|
|
1588
|
+
|
|
1589
|
+
/**
|
|
1590
|
+
* Receives JavaScript callback invocation data.
|
|
1591
|
+
*
|
|
1592
|
+
* @param env environment under which the function is invoked
|
|
1593
|
+
* @param info callback data
|
|
1594
|
+
* @return Node-API value
|
|
1595
|
+
*/
|
|
1596
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1597
|
+
return stdlib_math_base_napi_zi_z( env, info, mul );
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
// ...
|
|
1601
|
+
```
|
|
1602
|
+
|
|
1603
|
+
The function accepts the following arguments:
|
|
1604
|
+
|
|
1605
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1606
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1607
|
+
- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t )` binary function.
|
|
1608
|
+
|
|
1609
|
+
```c
|
|
1610
|
+
void stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t ) );
|
|
1611
|
+
```
|
|
1612
|
+
|
|
1613
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( fcn )
|
|
1614
|
+
|
|
1615
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning double-precision complex floating-point numbers.
|
|
1616
|
+
|
|
1617
|
+
```c
|
|
1618
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1619
|
+
#include "stdlib/complex/float64/reim.h"
|
|
1620
|
+
|
|
1621
|
+
static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y ) {
|
|
1622
|
+
double xre;
|
|
1623
|
+
double xim;
|
|
1624
|
+
double yre;
|
|
1625
|
+
double yim;
|
|
1626
|
+
double re;
|
|
1627
|
+
double im;
|
|
1628
|
+
|
|
1629
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
1630
|
+
stdlib_complex128_reim( y, &yre, &yim );
|
|
1631
|
+
|
|
1632
|
+
re = xre + yre;
|
|
1633
|
+
im = xim + yim;
|
|
1634
|
+
|
|
1635
|
+
return stdlib_complex128( re, im );
|
|
909
1636
|
}
|
|
910
1637
|
|
|
911
1638
|
// ...
|
|
912
1639
|
|
|
913
1640
|
// Register a Node-API module:
|
|
914
|
-
|
|
1641
|
+
STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( add );
|
|
915
1642
|
```
|
|
916
1643
|
|
|
917
1644
|
The macro expects the following arguments:
|
|
918
1645
|
|
|
919
|
-
- **fcn**: `
|
|
1646
|
+
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t )` binary function.
|
|
920
1647
|
|
|
921
1648
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
922
1649
|
|
|
1650
|
+
#### stdlib_math_base_napi_zz_z( env, info, fcn )
|
|
1651
|
+
|
|
1652
|
+
Invokes a binary function accepting and returning double-precision complex floating-point numbers.
|
|
1653
|
+
|
|
1654
|
+
```c
|
|
1655
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1656
|
+
#include "stdlib/complex/float64/reim.h"
|
|
1657
|
+
#include <node_api.h>
|
|
1658
|
+
|
|
1659
|
+
// ...
|
|
1660
|
+
|
|
1661
|
+
static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y ) {
|
|
1662
|
+
double xre;
|
|
1663
|
+
double xim;
|
|
1664
|
+
double yre;
|
|
1665
|
+
double yim;
|
|
1666
|
+
double re;
|
|
1667
|
+
double im;
|
|
1668
|
+
|
|
1669
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
1670
|
+
stdlib_complex128_reim( y, &yre, &yim );
|
|
1671
|
+
|
|
1672
|
+
re = xre + yre;
|
|
1673
|
+
im = xim + yim;
|
|
1674
|
+
|
|
1675
|
+
return stdlib_complex128( re, im );
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
// ...
|
|
1679
|
+
|
|
1680
|
+
/**
|
|
1681
|
+
* Receives JavaScript callback invocation data.
|
|
1682
|
+
*
|
|
1683
|
+
* @param env environment under which the function is invoked
|
|
1684
|
+
* @param info callback data
|
|
1685
|
+
* @return Node-API value
|
|
1686
|
+
*/
|
|
1687
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
1688
|
+
return stdlib_math_base_napi_zz_z( env, info, add );
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
// ...
|
|
1692
|
+
```
|
|
1693
|
+
|
|
1694
|
+
The function accepts the following arguments:
|
|
1695
|
+
|
|
1696
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
1697
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
1698
|
+
- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t )` binary function.
|
|
1699
|
+
|
|
1700
|
+
```c
|
|
1701
|
+
void stdlib_math_base_napi_zz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t ) );
|
|
1702
|
+
```
|
|
1703
|
+
|
|
923
1704
|
</section>
|
|
924
1705
|
|
|
925
1706
|
<!-- /.usage -->
|
|
@@ -993,7 +1774,7 @@ See [LICENSE][stdlib-license].
|
|
|
993
1774
|
|
|
994
1775
|
## Copyright
|
|
995
1776
|
|
|
996
|
-
Copyright © 2016-
|
|
1777
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
997
1778
|
|
|
998
1779
|
</section>
|
|
999
1780
|
|
|
@@ -1006,8 +1787,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
1006
1787
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/math-base-napi-binary.svg
|
|
1007
1788
|
[npm-url]: https://npmjs.org/package/@stdlib/math-base-napi-binary
|
|
1008
1789
|
|
|
1009
|
-
[test-image]: https://github.com/stdlib-js/math-base-napi-binary/actions/workflows/test.yml/badge.svg?branch=v0.3.
|
|
1010
|
-
[test-url]: https://github.com/stdlib-js/math-base-napi-binary/actions/workflows/test.yml?query=branch:v0.3.
|
|
1790
|
+
[test-image]: https://github.com/stdlib-js/math-base-napi-binary/actions/workflows/test.yml/badge.svg?branch=v0.3.2
|
|
1791
|
+
[test-url]: https://github.com/stdlib-js/math-base-napi-binary/actions/workflows/test.yml?query=branch:v0.3.2
|
|
1011
1792
|
|
|
1012
1793
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-napi-binary/main.svg
|
|
1013
1794
|
[coverage-url]: https://codecov.io/github/stdlib-js/math-base-napi-binary?branch=main
|
|
@@ -1019,8 +1800,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
1019
1800
|
|
|
1020
1801
|
-->
|
|
1021
1802
|
|
|
1022
|
-
[chat-image]: https://img.shields.io/
|
|
1023
|
-
[chat-url]: https://
|
|
1803
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
1804
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
1024
1805
|
|
|
1025
1806
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
1026
1807
|
|