@stdlib/math-base-napi-binary 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +1 -1
- package/README.md +1155 -252
- 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 -531
- package/manifest.json +60 -40
- package/package.json +6 -6
- 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/include.gypi +0 -53
- package/src/main.c +0 -1063
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,74 +186,56 @@ 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/reim.h"
|
|
216
|
-
#include <node_api.h>
|
|
200
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
201
|
+
#include "stdlib/complex/float32/reim.h"
|
|
217
202
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
double re;
|
|
226
|
-
double im;
|
|
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
|
|
|
265
234
|
Invokes a binary function accepting and returning single-precision complex floating-point numbers.
|
|
266
235
|
|
|
267
236
|
```c
|
|
268
|
-
#include "stdlib/complex/float64.h"
|
|
269
|
-
#include "stdlib/complex/reim.h"
|
|
237
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
238
|
+
#include "stdlib/complex/float64/reim.h"
|
|
270
239
|
#include <node_api.h>
|
|
271
240
|
|
|
272
241
|
// ...
|
|
@@ -279,8 +248,8 @@ static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex6
|
|
|
279
248
|
float re;
|
|
280
249
|
float im;
|
|
281
250
|
|
|
282
|
-
|
|
283
|
-
|
|
251
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
252
|
+
stdlib_complex64_reim( y, &yre, &yim );
|
|
284
253
|
|
|
285
254
|
re = xre + yre;
|
|
286
255
|
im = xim + yim;
|
|
@@ -314,58 +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.
|
|
320
289
|
|
|
321
290
|
```c
|
|
322
|
-
#include
|
|
323
|
-
#include
|
|
291
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
292
|
+
#include "stdlib/complex/float32/reim.h"
|
|
324
293
|
|
|
325
|
-
|
|
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;
|
|
326
299
|
|
|
327
|
-
|
|
328
|
-
return x * y;
|
|
329
|
-
}
|
|
300
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
330
301
|
|
|
331
|
-
|
|
302
|
+
re = xre * y;
|
|
303
|
+
im = xim * y;
|
|
332
304
|
|
|
333
|
-
|
|
334
|
-
* Receives JavaScript callback invocation data.
|
|
335
|
-
*
|
|
336
|
-
* @param env environment under which the function is invoked
|
|
337
|
-
* @param info callback data
|
|
338
|
-
* @return Node-API value
|
|
339
|
-
*/
|
|
340
|
-
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
341
|
-
return stdlib_math_base_napi_di_d( env, info, mul );
|
|
305
|
+
return stdlib_complex64( re, im );
|
|
342
306
|
}
|
|
343
307
|
|
|
344
308
|
// ...
|
|
309
|
+
|
|
310
|
+
// Register a Node-API module:
|
|
311
|
+
STDLIB_MATH_BASE_NAPI_MODULE_CF_C( add );
|
|
345
312
|
```
|
|
346
313
|
|
|
347
|
-
The
|
|
314
|
+
The macro expects the following arguments:
|
|
348
315
|
|
|
349
|
-
- **
|
|
350
|
-
- **info**: `[in] napi_callback_info` callback data.
|
|
351
|
-
- **fcn**: `[in] double (*fcn)( double, int32_t )` binary function.
|
|
316
|
+
- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, float )` binary function.
|
|
352
317
|
|
|
353
|
-
|
|
354
|
-
void stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) );
|
|
355
|
-
```
|
|
318
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
356
319
|
|
|
357
|
-
####
|
|
320
|
+
#### stdlib_math_base_napi_cf_c( env, info, fcn )
|
|
358
321
|
|
|
359
|
-
Invokes a binary function accepting a single-precision floating-point number and a
|
|
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.
|
|
360
323
|
|
|
361
324
|
```c
|
|
325
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
326
|
+
#include "stdlib/complex/float32/reim.h"
|
|
362
327
|
#include <node_api.h>
|
|
363
|
-
#include <stdint.h>
|
|
364
328
|
|
|
365
329
|
// ...
|
|
366
330
|
|
|
367
|
-
static
|
|
368
|
-
|
|
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 );
|
|
369
343
|
}
|
|
370
344
|
|
|
371
345
|
// ...
|
|
@@ -378,7 +352,7 @@ static float mulf( const float x, const int32_t y ) {
|
|
|
378
352
|
* @return Node-API value
|
|
379
353
|
*/
|
|
380
354
|
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
381
|
-
return
|
|
355
|
+
return stdlib_math_base_napi_cf_c( env, info, mul );
|
|
382
356
|
}
|
|
383
357
|
|
|
384
358
|
// ...
|
|
@@ -388,71 +362,54 @@ The function accepts the following arguments:
|
|
|
388
362
|
|
|
389
363
|
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
390
364
|
- **info**: `[in] napi_callback_info` callback data.
|
|
391
|
-
- **fcn**: `[in]
|
|
365
|
+
- **fcn**: `[in] stdlib_complex64_t (*fcn)( stdlib_complex64_t, float )` binary function.
|
|
392
366
|
|
|
393
367
|
```c
|
|
394
|
-
void
|
|
368
|
+
void stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, float ) );
|
|
395
369
|
```
|
|
396
370
|
|
|
397
|
-
####
|
|
371
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_CI_C( fcn )
|
|
398
372
|
|
|
399
|
-
|
|
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.
|
|
400
374
|
|
|
401
375
|
```c
|
|
402
|
-
#include "stdlib/complex/
|
|
403
|
-
#include "stdlib/complex/reim.h"
|
|
404
|
-
#include <node_api.h>
|
|
376
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
377
|
+
#include "stdlib/complex/float32/reim.h"
|
|
405
378
|
#include <stdint.h>
|
|
406
379
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
double re;
|
|
413
|
-
double im;
|
|
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;
|
|
414
385
|
|
|
415
|
-
|
|
386
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
416
387
|
|
|
417
388
|
re = xre * y;
|
|
418
389
|
im = xim * y;
|
|
419
390
|
|
|
420
|
-
return
|
|
391
|
+
return stdlib_complex64( re, im );
|
|
421
392
|
}
|
|
422
393
|
|
|
423
394
|
// ...
|
|
424
395
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
*
|
|
428
|
-
* @param env environment under which the function is invoked
|
|
429
|
-
* @param info callback data
|
|
430
|
-
* @return Node-API value
|
|
431
|
-
*/
|
|
432
|
-
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
433
|
-
return stdlib_math_base_napi_zi_z( env, info, mul );
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// ...
|
|
396
|
+
// Register a Node-API module:
|
|
397
|
+
STDLIB_MATH_BASE_NAPI_MODULE_CI_C( add );
|
|
437
398
|
```
|
|
438
399
|
|
|
439
|
-
The
|
|
400
|
+
The macro expects the following arguments:
|
|
440
401
|
|
|
441
|
-
- **
|
|
442
|
-
- **info**: `[in] napi_callback_info` callback data.
|
|
443
|
-
- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t )` binary function.
|
|
402
|
+
- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t )` binary function.
|
|
444
403
|
|
|
445
|
-
|
|
446
|
-
void stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t ) );
|
|
447
|
-
```
|
|
404
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
448
405
|
|
|
449
406
|
#### stdlib_math_base_napi_ci_c( env, info, fcn )
|
|
450
407
|
|
|
451
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.
|
|
452
409
|
|
|
453
410
|
```c
|
|
454
|
-
#include "stdlib/complex/float64.h"
|
|
455
|
-
#include "stdlib/complex/
|
|
411
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
412
|
+
#include "stdlib/complex/float32/reim.h"
|
|
456
413
|
#include <node_api.h>
|
|
457
414
|
#include <stdint.h>
|
|
458
415
|
|
|
@@ -464,7 +421,7 @@ static stdlib_complex64_t mul( const stdlib_complex64_t x, const int32_t y ) {
|
|
|
464
421
|
float re;
|
|
465
422
|
float im;
|
|
466
423
|
|
|
467
|
-
|
|
424
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
468
425
|
|
|
469
426
|
re = xre * y;
|
|
470
427
|
im = xim * y;
|
|
@@ -519,154 +476,1060 @@ The macro expects the following arguments:
|
|
|
519
476
|
|
|
520
477
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
521
478
|
|
|
522
|
-
####
|
|
479
|
+
#### stdlib_math_base_napi_dd_d( env, info, fcn )
|
|
523
480
|
|
|
524
|
-
|
|
481
|
+
Invokes a binary function accepting and returning double-precision floating-point numbers.
|
|
525
482
|
|
|
526
483
|
```c
|
|
527
|
-
|
|
528
|
-
return x + y;
|
|
529
|
-
}
|
|
484
|
+
#include <node_api.h>
|
|
530
485
|
|
|
531
486
|
// ...
|
|
532
487
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
488
|
+
static double add( const double x, const double y ) {
|
|
489
|
+
return x + y;
|
|
490
|
+
}
|
|
536
491
|
|
|
537
|
-
|
|
492
|
+
// ...
|
|
538
493
|
|
|
539
|
-
|
|
494
|
+
/**
|
|
495
|
+
* Receives JavaScript callback invocation data.
|
|
496
|
+
*
|
|
497
|
+
* @param env environment under which the function is invoked
|
|
498
|
+
* @param info callback data
|
|
499
|
+
* @return Node-API value
|
|
500
|
+
*/
|
|
501
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
502
|
+
return stdlib_math_base_napi_dd_d( env, info, add );
|
|
503
|
+
}
|
|
540
504
|
|
|
541
|
-
|
|
505
|
+
// ...
|
|
506
|
+
```
|
|
542
507
|
|
|
543
|
-
|
|
508
|
+
The function accepts the following arguments:
|
|
544
509
|
|
|
545
|
-
|
|
510
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
511
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
512
|
+
- **fcn**: `[in] double (*fcn)( double, double )` binary function.
|
|
546
513
|
|
|
547
514
|
```c
|
|
548
|
-
|
|
549
|
-
|
|
515
|
+
void stdlib_math_base_napi_dd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double ) );
|
|
516
|
+
```
|
|
550
517
|
|
|
551
|
-
|
|
552
|
-
double xre;
|
|
553
|
-
double xim;
|
|
554
|
-
double yre;
|
|
555
|
-
double yim;
|
|
556
|
-
double re;
|
|
557
|
-
double im;
|
|
518
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_DI_D( fcn )
|
|
558
519
|
|
|
559
|
-
|
|
560
|
-
stdlib_reim( y, &yre, &yim );
|
|
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.
|
|
561
521
|
|
|
562
|
-
|
|
563
|
-
|
|
522
|
+
```c
|
|
523
|
+
#include <stdint.h>
|
|
564
524
|
|
|
565
|
-
|
|
525
|
+
static double mul( const double x, const int32_t y ) {
|
|
526
|
+
return x * y;
|
|
566
527
|
}
|
|
567
528
|
|
|
568
529
|
// ...
|
|
569
530
|
|
|
570
531
|
// Register a Node-API module:
|
|
571
|
-
|
|
532
|
+
STDLIB_MATH_BASE_NAPI_MODULE_DI_D( mul );
|
|
572
533
|
```
|
|
573
534
|
|
|
574
535
|
The macro expects the following arguments:
|
|
575
536
|
|
|
576
|
-
- **fcn**: `
|
|
537
|
+
- **fcn**: `double (*fcn)( double, int32_t )` binary function.
|
|
577
538
|
|
|
578
539
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
579
540
|
|
|
580
|
-
####
|
|
541
|
+
#### stdlib_math_base_napi_di_d( env, info, fcn )
|
|
581
542
|
|
|
582
|
-
|
|
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.
|
|
583
544
|
|
|
584
545
|
```c
|
|
585
|
-
#include
|
|
586
|
-
#include
|
|
546
|
+
#include <node_api.h>
|
|
547
|
+
#include <stdint.h>
|
|
587
548
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
549
|
+
// ...
|
|
550
|
+
|
|
551
|
+
static double mul( const double x, const int32_t y ) {
|
|
552
|
+
return x * y;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// ...
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Receives JavaScript callback invocation data.
|
|
559
|
+
*
|
|
560
|
+
* @param env environment under which the function is invoked
|
|
561
|
+
* @param info callback data
|
|
562
|
+
* @return Node-API value
|
|
563
|
+
*/
|
|
564
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
565
|
+
return stdlib_math_base_napi_di_d( env, info, mul );
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// ...
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
The function accepts the following arguments:
|
|
572
|
+
|
|
573
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
574
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
575
|
+
- **fcn**: `[in] double (*fcn)( double, int32_t )` binary function.
|
|
576
|
+
|
|
577
|
+
```c
|
|
578
|
+
void stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) );
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_DZ_Z( fcn )
|
|
582
|
+
|
|
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.
|
|
584
|
+
|
|
585
|
+
```c
|
|
586
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
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"
|
|
622
|
+
#include <node_api.h>
|
|
623
|
+
|
|
624
|
+
// ...
|
|
625
|
+
|
|
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;
|
|
631
|
+
|
|
632
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
633
|
+
|
|
634
|
+
re = xre * y;
|
|
635
|
+
im = xim * y;
|
|
636
|
+
|
|
637
|
+
return stdlib_complex128( re, im );
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// ...
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Receives JavaScript callback invocation data.
|
|
644
|
+
*
|
|
645
|
+
* @param env environment under which the function is invoked
|
|
646
|
+
* @param info callback data
|
|
647
|
+
* @return Node-API value
|
|
648
|
+
*/
|
|
649
|
+
napi_value addon( napi_env env, napi_callback_info info ) {
|
|
650
|
+
return stdlib_math_base_napi_dz_z( env, info, mul );
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// ...
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
The function accepts the following arguments:
|
|
657
|
+
|
|
658
|
+
- **env**: `[in] napi_env` environment under which the function is invoked.
|
|
659
|
+
- **info**: `[in] napi_callback_info` callback data.
|
|
660
|
+
- **fcn**: `[in] stdlib_complex128_t (*fcn)( double, stdlib_complex128_t )` binary function.
|
|
661
|
+
|
|
662
|
+
```c
|
|
663
|
+
void stdlib_math_base_napi_dz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( double, stdlib_complex128_t ) );
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_FC_C( fcn )
|
|
667
|
+
|
|
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.
|
|
669
|
+
|
|
670
|
+
```c
|
|
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 );
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// ...
|
|
689
|
+
|
|
690
|
+
// Register a Node-API module:
|
|
691
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FC_C( mul );
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
The macro expects the following arguments:
|
|
695
|
+
|
|
696
|
+
- **fcn**: `stdlib_complex64_t (*fcn)( float, stdlib_complex64_t )` binary function.
|
|
697
|
+
|
|
698
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
699
|
+
|
|
700
|
+
#### stdlib_math_base_napi_fc_c( env, info, fcn )
|
|
701
|
+
|
|
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.
|
|
703
|
+
|
|
704
|
+
```c
|
|
705
|
+
#include "stdlib/complex/float32/ctor.h"
|
|
706
|
+
#include "stdlib/complex/float32/reim.h"
|
|
707
|
+
#include <node_api.h>
|
|
708
|
+
|
|
709
|
+
// ...
|
|
710
|
+
|
|
711
|
+
static stdlib_complex64_t mul( const float y, const stdlib_complex64_t x ) {
|
|
712
|
+
float xre;
|
|
713
|
+
float xim;
|
|
593
714
|
float re;
|
|
594
715
|
float im;
|
|
595
716
|
|
|
596
|
-
|
|
597
|
-
|
|
717
|
+
stdlib_complex64_reim( x, &xre, &xim );
|
|
718
|
+
|
|
719
|
+
re = xre * y;
|
|
720
|
+
im = xim * y;
|
|
721
|
+
|
|
722
|
+
return stdlib_complex64( re, im );
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// ...
|
|
726
|
+
|
|
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 );
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// ...
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
The function accepts the following arguments:
|
|
742
|
+
|
|
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.
|
|
746
|
+
|
|
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
|
+
```
|
|
750
|
+
|
|
751
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_FF_F( fcn )
|
|
752
|
+
|
|
753
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning single-precision floating-point numbers.
|
|
754
|
+
|
|
755
|
+
```c
|
|
756
|
+
static float addf( const float x, const float y ) {
|
|
757
|
+
return x + y;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
// ...
|
|
761
|
+
|
|
762
|
+
// Register a Node-API module:
|
|
763
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FF_F( addf );
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
The macro expects the following arguments:
|
|
767
|
+
|
|
768
|
+
- **fcn**: `float (*fcn)( float, float )` binary function.
|
|
769
|
+
|
|
770
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
771
|
+
|
|
772
|
+
#### stdlib_math_base_napi_ff_f( env, info, fcn )
|
|
773
|
+
|
|
774
|
+
Invokes a binary function accepting and returning single-precision floating-point numbers.
|
|
775
|
+
|
|
776
|
+
```c
|
|
777
|
+
#include <node_api.h>
|
|
778
|
+
|
|
779
|
+
// ...
|
|
780
|
+
|
|
781
|
+
static float addf( const float x, const float y ) {
|
|
782
|
+
return x + y;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// ...
|
|
786
|
+
|
|
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 );
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// ...
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
The function accepts the following arguments:
|
|
802
|
+
|
|
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.
|
|
806
|
+
|
|
807
|
+
```c
|
|
808
|
+
void stdlib_math_base_napi_ff_f( napi_env env, napi_callback_info info, float (*fcn)( float, float ) );
|
|
809
|
+
```
|
|
810
|
+
|
|
811
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_FI_F( fcn )
|
|
812
|
+
|
|
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.
|
|
814
|
+
|
|
815
|
+
```c
|
|
816
|
+
#include <stdint.h>
|
|
817
|
+
|
|
818
|
+
static float mulf( const float x, const int32_t y ) {
|
|
819
|
+
return x * y;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// ...
|
|
823
|
+
|
|
824
|
+
// Register a Node-API module:
|
|
825
|
+
STDLIB_MATH_BASE_NAPI_MODULE_FI_F( mulf );
|
|
826
|
+
```
|
|
827
|
+
|
|
828
|
+
The macro expects the following arguments:
|
|
829
|
+
|
|
830
|
+
- **fcn**: `float (*fcn)( float, int32_t )` binary function.
|
|
831
|
+
|
|
832
|
+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
833
|
+
|
|
834
|
+
#### stdlib_math_base_napi_fi_f( env, info, fcn )
|
|
835
|
+
|
|
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.
|
|
837
|
+
|
|
838
|
+
```c
|
|
839
|
+
#include <node_api.h>
|
|
840
|
+
#include <stdint.h>
|
|
841
|
+
|
|
842
|
+
// ...
|
|
843
|
+
|
|
844
|
+
static float mulf( const float x, const int32_t y ) {
|
|
845
|
+
return x * y;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
// ...
|
|
849
|
+
|
|
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 )
|
|
598
1316
|
|
|
599
|
-
|
|
600
|
-
im = xim + yim;
|
|
1317
|
+
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning unsigned 16-bit integers.
|
|
601
1318
|
|
|
602
|
-
|
|
1319
|
+
```c
|
|
1320
|
+
#include <stdint.h>
|
|
1321
|
+
|
|
1322
|
+
static uint16_t add( const uint16_t x, const uint16_t y ) {
|
|
1323
|
+
return x + y;
|
|
603
1324
|
}
|
|
604
1325
|
|
|
605
1326
|
// ...
|
|
606
1327
|
|
|
607
1328
|
// Register a Node-API module:
|
|
608
|
-
|
|
1329
|
+
STDLIB_MATH_BASE_NAPI_MODULE_TT_T( add );
|
|
609
1330
|
```
|
|
610
1331
|
|
|
611
1332
|
The macro expects the following arguments:
|
|
612
1333
|
|
|
613
|
-
- **fcn**: `
|
|
1334
|
+
- **fcn**: `uint16_t (*fcn)( uint16_t, uint16_t )` binary function.
|
|
614
1335
|
|
|
615
1336
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
616
1337
|
|
|
617
|
-
####
|
|
1338
|
+
#### stdlib_math_base_napi_tt_t( env, info, fcn )
|
|
618
1339
|
|
|
619
|
-
|
|
1340
|
+
Invokes a binary function accepting and returning unsigned 16-bit integers.
|
|
620
1341
|
|
|
621
1342
|
```c
|
|
1343
|
+
#include <node_api.h>
|
|
622
1344
|
#include <stdint.h>
|
|
623
1345
|
|
|
624
|
-
|
|
625
|
-
|
|
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
|
+
}
|
|
1364
|
+
|
|
1365
|
+
// ...
|
|
1366
|
+
```
|
|
1367
|
+
|
|
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.
|
|
1381
|
+
|
|
1382
|
+
```c
|
|
1383
|
+
#include <stdint.h>
|
|
1384
|
+
|
|
1385
|
+
static uint32_t add( const uint32_t x, const uint32_t y ) {
|
|
1386
|
+
return x + y;
|
|
626
1387
|
}
|
|
627
1388
|
|
|
628
1389
|
// ...
|
|
629
1390
|
|
|
630
1391
|
// Register a Node-API module:
|
|
631
|
-
|
|
1392
|
+
STDLIB_MATH_BASE_NAPI_MODULE_UU_U( add );
|
|
632
1393
|
```
|
|
633
1394
|
|
|
634
1395
|
The macro expects the following arguments:
|
|
635
1396
|
|
|
636
|
-
- **fcn**: `
|
|
1397
|
+
- **fcn**: `uint32_t (*fcn)( uint32_t, uint32_t )` binary function.
|
|
637
1398
|
|
|
638
1399
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
639
1400
|
|
|
640
|
-
####
|
|
1401
|
+
#### stdlib_math_base_napi_uu_u( env, info, fcn )
|
|
641
1402
|
|
|
642
|
-
|
|
1403
|
+
Invokes a binary function accepting and returning unsigned 32-bit integers.
|
|
643
1404
|
|
|
644
1405
|
```c
|
|
1406
|
+
#include <node_api.h>
|
|
645
1407
|
#include <stdint.h>
|
|
646
1408
|
|
|
647
|
-
|
|
648
|
-
|
|
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.
|
|
1444
|
+
|
|
1445
|
+
```c
|
|
1446
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1447
|
+
#include "stdlib/complex/float64/reim.h"
|
|
1448
|
+
|
|
1449
|
+
static stdlib_complex128_t mul( const stdlib_complex128_t x, const double y ) {
|
|
1450
|
+
double xre;
|
|
1451
|
+
double xim;
|
|
1452
|
+
double re;
|
|
1453
|
+
double im;
|
|
1454
|
+
|
|
1455
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
1456
|
+
|
|
1457
|
+
re = xre * y;
|
|
1458
|
+
im = xim * y;
|
|
1459
|
+
|
|
1460
|
+
return stdlib_complex128( re, im );
|
|
649
1461
|
}
|
|
650
1462
|
|
|
651
1463
|
// ...
|
|
652
1464
|
|
|
653
1465
|
// Register a Node-API module:
|
|
654
|
-
|
|
1466
|
+
STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( mul );
|
|
655
1467
|
```
|
|
656
1468
|
|
|
657
1469
|
The macro expects the following arguments:
|
|
658
1470
|
|
|
659
|
-
- **fcn**: `
|
|
1471
|
+
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, double )` binary function.
|
|
660
1472
|
|
|
661
1473
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
662
1474
|
|
|
1475
|
+
#### stdlib_math_base_napi_zd_z( env, info, fcn )
|
|
1476
|
+
|
|
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.
|
|
1478
|
+
|
|
1479
|
+
```c
|
|
1480
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1481
|
+
#include "stdlib/complex/float64/reim.h"
|
|
1482
|
+
#include <node_api.h>
|
|
1483
|
+
|
|
1484
|
+
// ...
|
|
1485
|
+
|
|
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 );
|
|
1493
|
+
|
|
1494
|
+
re = xre * y;
|
|
1495
|
+
im = xim * y;
|
|
1496
|
+
|
|
1497
|
+
return stdlib_complex128( re, im );
|
|
1498
|
+
}
|
|
1499
|
+
|
|
1500
|
+
// ...
|
|
1501
|
+
|
|
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
|
+
// ...
|
|
1514
|
+
```
|
|
1515
|
+
|
|
1516
|
+
The function accepts the following arguments:
|
|
1517
|
+
|
|
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.
|
|
1521
|
+
|
|
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
|
+
```
|
|
1525
|
+
|
|
663
1526
|
#### STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( fcn )
|
|
664
1527
|
|
|
665
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.
|
|
666
1529
|
|
|
667
1530
|
```c
|
|
668
|
-
#include "stdlib/complex/float64.h"
|
|
669
|
-
#include "stdlib/complex/reim.h"
|
|
1531
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1532
|
+
#include "stdlib/complex/float64/reim.h"
|
|
670
1533
|
#include <stdint.h>
|
|
671
1534
|
|
|
672
1535
|
static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) {
|
|
@@ -675,7 +1538,7 @@ static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t y ) {
|
|
|
675
1538
|
double re;
|
|
676
1539
|
double im;
|
|
677
1540
|
|
|
678
|
-
|
|
1541
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
679
1542
|
|
|
680
1543
|
re = xre * y;
|
|
681
1544
|
im = xim * y;
|
|
@@ -695,59 +1558,79 @@ The macro expects the following arguments:
|
|
|
695
1558
|
|
|
696
1559
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
697
1560
|
|
|
698
|
-
####
|
|
1561
|
+
#### stdlib_math_base_napi_zi_z( env, info, fcn )
|
|
699
1562
|
|
|
700
|
-
|
|
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.
|
|
701
1564
|
|
|
702
1565
|
```c
|
|
703
|
-
#include "stdlib/complex/
|
|
704
|
-
#include "stdlib/complex/
|
|
1566
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1567
|
+
#include "stdlib/complex/float64/reim.h"
|
|
1568
|
+
#include <node_api.h>
|
|
705
1569
|
#include <stdint.h>
|
|
706
1570
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
1571
|
+
// ...
|
|
1572
|
+
|
|
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;
|
|
712
1578
|
|
|
713
|
-
|
|
1579
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
714
1580
|
|
|
715
1581
|
re = xre * y;
|
|
716
1582
|
im = xim * y;
|
|
717
1583
|
|
|
718
|
-
return
|
|
1584
|
+
return stdlib_complex128( re, im );
|
|
719
1585
|
}
|
|
720
1586
|
|
|
721
1587
|
// ...
|
|
722
1588
|
|
|
723
|
-
|
|
724
|
-
|
|
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
|
+
// ...
|
|
725
1601
|
```
|
|
726
1602
|
|
|
727
|
-
The
|
|
1603
|
+
The function accepts the following arguments:
|
|
728
1604
|
|
|
729
|
-
- **
|
|
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.
|
|
730
1608
|
|
|
731
|
-
|
|
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
|
+
```
|
|
732
1612
|
|
|
733
|
-
####
|
|
1613
|
+
#### STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( fcn )
|
|
734
1614
|
|
|
735
|
-
Macro for registering a Node-API module exporting an interface invoking a binary function accepting
|
|
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.
|
|
736
1616
|
|
|
737
1617
|
```c
|
|
738
|
-
#include "stdlib/complex/float64.h"
|
|
739
|
-
#include "stdlib/complex/reim.h"
|
|
1618
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1619
|
+
#include "stdlib/complex/float64/reim.h"
|
|
740
1620
|
|
|
741
|
-
static stdlib_complex128_t
|
|
1621
|
+
static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y ) {
|
|
742
1622
|
double xre;
|
|
743
1623
|
double xim;
|
|
1624
|
+
double yre;
|
|
1625
|
+
double yim;
|
|
744
1626
|
double re;
|
|
745
1627
|
double im;
|
|
746
1628
|
|
|
747
|
-
|
|
1629
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
1630
|
+
stdlib_complex128_reim( y, &yre, &yim );
|
|
748
1631
|
|
|
749
|
-
re = xre
|
|
750
|
-
im = xim
|
|
1632
|
+
re = xre + yre;
|
|
1633
|
+
im = xim + yim;
|
|
751
1634
|
|
|
752
1635
|
return stdlib_complex128( re, im );
|
|
753
1636
|
}
|
|
@@ -755,48 +1638,68 @@ static stdlib_complex128_t mul( const stdlib_complex128_t x, const double y ) {
|
|
|
755
1638
|
// ...
|
|
756
1639
|
|
|
757
1640
|
// Register a Node-API module:
|
|
758
|
-
|
|
1641
|
+
STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( add );
|
|
759
1642
|
```
|
|
760
1643
|
|
|
761
1644
|
The macro expects the following arguments:
|
|
762
1645
|
|
|
763
|
-
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t,
|
|
1646
|
+
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t )` binary function.
|
|
764
1647
|
|
|
765
1648
|
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
|
|
766
1649
|
|
|
767
|
-
####
|
|
1650
|
+
#### stdlib_math_base_napi_zz_z( env, info, fcn )
|
|
768
1651
|
|
|
769
|
-
|
|
1652
|
+
Invokes a binary function accepting and returning double-precision complex floating-point numbers.
|
|
770
1653
|
|
|
771
1654
|
```c
|
|
772
|
-
#include "stdlib/complex/
|
|
773
|
-
#include "stdlib/complex/
|
|
1655
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
1656
|
+
#include "stdlib/complex/float64/reim.h"
|
|
1657
|
+
#include <node_api.h>
|
|
774
1658
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
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;
|
|
780
1668
|
|
|
781
|
-
|
|
1669
|
+
stdlib_complex128_reim( x, &xre, &xim );
|
|
1670
|
+
stdlib_complex128_reim( y, &yre, &yim );
|
|
782
1671
|
|
|
783
|
-
re = xre
|
|
784
|
-
im = xim
|
|
1672
|
+
re = xre + yre;
|
|
1673
|
+
im = xim + yim;
|
|
785
1674
|
|
|
786
|
-
return
|
|
1675
|
+
return stdlib_complex128( re, im );
|
|
787
1676
|
}
|
|
788
1677
|
|
|
789
1678
|
// ...
|
|
790
1679
|
|
|
791
|
-
|
|
792
|
-
|
|
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
|
+
// ...
|
|
793
1692
|
```
|
|
794
1693
|
|
|
795
|
-
The
|
|
1694
|
+
The function accepts the following arguments:
|
|
796
1695
|
|
|
797
|
-
- **
|
|
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.
|
|
798
1699
|
|
|
799
|
-
|
|
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
|
+
```
|
|
800
1703
|
|
|
801
1704
|
</section>
|
|
802
1705
|
|
|
@@ -871,7 +1774,7 @@ See [LICENSE][stdlib-license].
|
|
|
871
1774
|
|
|
872
1775
|
## Copyright
|
|
873
1776
|
|
|
874
|
-
Copyright © 2016-
|
|
1777
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
875
1778
|
|
|
876
1779
|
</section>
|
|
877
1780
|
|
|
@@ -884,8 +1787,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
884
1787
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/math-base-napi-binary.svg
|
|
885
1788
|
[npm-url]: https://npmjs.org/package/@stdlib/math-base-napi-binary
|
|
886
1789
|
|
|
887
|
-
[test-image]: https://github.com/stdlib-js/math-base-napi-binary/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
888
|
-
[test-url]: https://github.com/stdlib-js/math-base-napi-binary/actions/workflows/test.yml?query=branch:v0.
|
|
1790
|
+
[test-image]: https://github.com/stdlib-js/math-base-napi-binary/actions/workflows/test.yml/badge.svg?branch=v0.3.1
|
|
1791
|
+
[test-url]: https://github.com/stdlib-js/math-base-napi-binary/actions/workflows/test.yml?query=branch:v0.3.1
|
|
889
1792
|
|
|
890
1793
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-base-napi-binary/main.svg
|
|
891
1794
|
[coverage-url]: https://codecov.io/github/stdlib-js/math-base-napi-binary?branch=main
|
|
@@ -897,8 +1800,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
897
1800
|
|
|
898
1801
|
-->
|
|
899
1802
|
|
|
900
|
-
[chat-image]: https://img.shields.io/
|
|
901
|
-
[chat-url]: https://
|
|
1803
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
1804
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
902
1805
|
|
|
903
1806
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
904
1807
|
|