@stdlib/math-base-napi-unary 0.0.7 → 0.0.9

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.
@@ -19,6 +19,8 @@
19
19
  #ifndef STDLIB_MATH_BASE_NAPI_UNARY_H
20
20
  #define STDLIB_MATH_BASE_NAPI_UNARY_H
21
21
 
22
+ #include "stdlib/complex/float32.h"
23
+ #include "stdlib/complex/float64.h"
22
24
  #include <node_api.h>
23
25
  #include <assert.h>
24
26
  #include <stdint.h>
@@ -103,6 +105,192 @@
103
105
  }; \
104
106
  NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_f_f_init )
105
107
 
108
+ /**
109
+ * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning double-precision complex floating-point numbers.
110
+ *
111
+ * @param fcn unary function
112
+ *
113
+ * @example
114
+ * #include "stdlib/complex/float64.h"
115
+ * #include "stdlib/complex/reim.h"
116
+ *
117
+ * static stdlib_complex128_t scale( const stdlib_complex128_t x ) {
118
+ * double re;
119
+ * double im;
120
+ *
121
+ * stdlib_reim( x, &re, &im );
122
+ *
123
+ * re *= 10.0;
124
+ * im *= 10.0;
125
+ *
126
+ * return stdlib_complex128( re, im );
127
+ * }
128
+ *
129
+ * // ...
130
+ *
131
+ * // Register a Node-API module:
132
+ * STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( scale );
133
+ */
134
+ #define STDLIB_MATH_BASE_NAPI_MODULE_Z_Z( fcn ) \
135
+ static napi_value stdlib_math_base_napi_z_z_wrapper( \
136
+ napi_env env, \
137
+ napi_callback_info info \
138
+ ) { \
139
+ return stdlib_math_base_napi_z_z( env, info, fcn ); \
140
+ }; \
141
+ static napi_value stdlib_math_base_napi_z_z_init( \
142
+ napi_env env, \
143
+ napi_value exports \
144
+ ) { \
145
+ napi_value fcn; \
146
+ napi_status status = napi_create_function( \
147
+ env, \
148
+ "exports", \
149
+ NAPI_AUTO_LENGTH, \
150
+ stdlib_math_base_napi_z_z_wrapper, \
151
+ NULL, \
152
+ &fcn \
153
+ ); \
154
+ assert( status == napi_ok ); \
155
+ return fcn; \
156
+ }; \
157
+ NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_z_z_init )
158
+
159
+ /**
160
+ * Macro for registering a Node-API module exporting an interface invoking a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number.
161
+ *
162
+ * @param fcn unary function
163
+ *
164
+ * @example
165
+ * #include "stdlib/complex/float64.h"
166
+ *
167
+ * static double fcn( const stdlib_complex128_t x ) {
168
+ * // ...
169
+ * }
170
+ *
171
+ * // ...
172
+ *
173
+ * // Register a Node-API module:
174
+ * STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn );
175
+ */
176
+ #define STDLIB_MATH_BASE_NAPI_MODULE_Z_D( fcn ) \
177
+ static napi_value stdlib_math_base_napi_z_d_wrapper( \
178
+ napi_env env, \
179
+ napi_callback_info info \
180
+ ) { \
181
+ return stdlib_math_base_napi_z_d( env, info, fcn ); \
182
+ }; \
183
+ static napi_value stdlib_math_base_napi_z_d_init( \
184
+ napi_env env, \
185
+ napi_value exports \
186
+ ) { \
187
+ napi_value fcn; \
188
+ napi_status status = napi_create_function( \
189
+ env, \
190
+ "exports", \
191
+ NAPI_AUTO_LENGTH, \
192
+ stdlib_math_base_napi_z_d_wrapper, \
193
+ NULL, \
194
+ &fcn \
195
+ ); \
196
+ assert( status == napi_ok ); \
197
+ return fcn; \
198
+ }; \
199
+ NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_z_d_init )
200
+
201
+ /**
202
+ * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning single-precision complex floating-point numbers.
203
+ *
204
+ * @param fcn unary function
205
+ *
206
+ * @example
207
+ * #include "stdlib/complex/float32.h"
208
+ * #include "stdlib/complex/reimf.h"
209
+ *
210
+ * static stdlib_complex64_t scale( const stdlib_complex64_t x ) {
211
+ * float re;
212
+ * float im;
213
+ *
214
+ * stdlib_reimf( x, &re, &im );
215
+ *
216
+ * re *= 10.0f;
217
+ * im *= 10.0f;
218
+ *
219
+ * return stdlib_complex64( re, im );
220
+ * }
221
+ *
222
+ * // ...
223
+ *
224
+ * // Register a Node-API module:
225
+ * STDLIB_MATH_BASE_NAPI_MODULE_C_C( scale );
226
+ */
227
+ #define STDLIB_MATH_BASE_NAPI_MODULE_C_C( fcn ) \
228
+ static napi_value stdlib_math_base_napi_c_c_wrapper( \
229
+ napi_env env, \
230
+ napi_callback_info info \
231
+ ) { \
232
+ return stdlib_math_base_napi_c_c( env, info, fcn ); \
233
+ }; \
234
+ static napi_value stdlib_math_base_napi_c_c_init( \
235
+ napi_env env, \
236
+ napi_value exports \
237
+ ) { \
238
+ napi_value fcn; \
239
+ napi_status status = napi_create_function( \
240
+ env, \
241
+ "exports", \
242
+ NAPI_AUTO_LENGTH, \
243
+ stdlib_math_base_napi_c_c_wrapper, \
244
+ NULL, \
245
+ &fcn \
246
+ ); \
247
+ assert( status == napi_ok ); \
248
+ return fcn; \
249
+ }; \
250
+ NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_c_c_init )
251
+
252
+ /**
253
+ * Macro for registering a Node-API module exporting an interface invoking a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number.
254
+ *
255
+ * @param fcn unary function
256
+ *
257
+ * @example
258
+ * #include "stdlib/complex/float32.h"
259
+ *
260
+ * static float fcn( const stdlib_complex64_t x ) {
261
+ * // ...
262
+ * }
263
+ *
264
+ * // ...
265
+ *
266
+ * // Register a Node-API module:
267
+ * STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn );
268
+ */
269
+ #define STDLIB_MATH_BASE_NAPI_MODULE_C_F( fcn ) \
270
+ static napi_value stdlib_math_base_napi_c_f_wrapper( \
271
+ napi_env env, \
272
+ napi_callback_info info \
273
+ ) { \
274
+ return stdlib_math_base_napi_c_f( env, info, fcn ); \
275
+ }; \
276
+ static napi_value stdlib_math_base_napi_c_f_init( \
277
+ napi_env env, \
278
+ napi_value exports \
279
+ ) { \
280
+ napi_value fcn; \
281
+ napi_status status = napi_create_function( \
282
+ env, \
283
+ "exports", \
284
+ NAPI_AUTO_LENGTH, \
285
+ stdlib_math_base_napi_c_f_wrapper, \
286
+ NULL, \
287
+ &fcn \
288
+ ); \
289
+ assert( status == napi_ok ); \
290
+ return fcn; \
291
+ }; \
292
+ NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_c_f_init )
293
+
106
294
  /**
107
295
  * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning 32-bit signed integers.
108
296
  *
@@ -145,6 +333,48 @@
145
333
  }; \
146
334
  NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_i_init )
147
335
 
336
+ /**
337
+ * Macro for registering a Node-API module exporting an interface invoking a unary function accepting a signed 32-bit integer and returning a double-precision floating-point number.
338
+ *
339
+ * @param fcn unary function
340
+ *
341
+ * @example
342
+ * #include <stdint.h>
343
+ *
344
+ * static double scale( const int32_t x ) {
345
+ * return x * 10.0;
346
+ * }
347
+ *
348
+ * // ...
349
+ *
350
+ * // Register a Node-API module:
351
+ * STDLIB_MATH_BASE_NAPI_MODULE_I_D( scale );
352
+ */
353
+ #define STDLIB_MATH_BASE_NAPI_MODULE_I_D( fcn ) \
354
+ static napi_value stdlib_math_base_napi_i_d_wrapper( \
355
+ napi_env env, \
356
+ napi_callback_info info \
357
+ ) { \
358
+ return stdlib_math_base_napi_i_d( env, info, fcn ); \
359
+ }; \
360
+ static napi_value stdlib_math_base_napi_i_d_init( \
361
+ napi_env env, \
362
+ napi_value exports \
363
+ ) { \
364
+ napi_value fcn; \
365
+ napi_status status = napi_create_function( \
366
+ env, \
367
+ "exports", \
368
+ NAPI_AUTO_LENGTH, \
369
+ stdlib_math_base_napi_i_d_wrapper, \
370
+ NULL, \
371
+ &fcn \
372
+ ); \
373
+ assert( status == napi_ok ); \
374
+ return fcn; \
375
+ }; \
376
+ NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_i_d_init )
377
+
148
378
  /*
149
379
  * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
150
380
  */
@@ -163,10 +393,35 @@ napi_value stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, dou
163
393
  napi_value stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) );
164
394
 
165
395
  /**
166
- * Invokes a unary function accepting and returning 32-bit signed integers.
396
+ * Invokes a unary function accepting and returning double-precision complex floating-point numbers.
397
+ */
398
+ napi_value stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) );
399
+
400
+ /**
401
+ * Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number.
402
+ */
403
+ napi_value stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) );
404
+
405
+ /**
406
+ * Invokes a unary function accepting and returning single-precision complex floating-point numbers.
407
+ */
408
+ napi_value stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) );
409
+
410
+ /**
411
+ * Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number.
412
+ */
413
+ napi_value stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) );
414
+
415
+ /**
416
+ * Invokes a unary function accepting and returning signed 32-bit integers.
167
417
  */
168
418
  napi_value stdlib_math_base_napi_i_i( napi_env env, napi_callback_info info, int32_t (*fcn)( int32_t ) );
169
419
 
420
+ /**
421
+ * Invokes a unary function accepting a signed 32-bit integer and returning a single-precision floating-point number.
422
+ */
423
+ napi_value stdlib_math_base_napi_i_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t ) );
424
+
170
425
  #ifdef __cplusplus
171
426
  }
172
427
  #endif
package/lib/index.js CHANGED
@@ -31,9 +31,9 @@
31
31
 
32
32
  // MODULES //
33
33
 
34
- var headerDir = require( './main.js' );
34
+ var main = require( './main.js' );
35
35
 
36
36
 
37
37
  // EXPORTS //
38
38
 
39
- module.exports = headerDir;
39
+ module.exports = main;
package/manifest.json CHANGED
@@ -32,7 +32,12 @@
32
32
  ],
33
33
  "libraries": [],
34
34
  "libpath": [],
35
- "dependencies": []
35
+ "dependencies": [
36
+ "@stdlib/complex-float32",
37
+ "@stdlib/complex-float64",
38
+ "@stdlib/complex-reim",
39
+ "@stdlib/complex-reimf"
40
+ ]
36
41
  }
37
42
  ]
38
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/math-base-napi-unary",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "C APIs for registering a Node-API module exporting an interface for invoking a unary numerical function.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -41,16 +41,20 @@
41
41
  "url": "https://github.com/stdlib-js/stdlib/issues"
42
42
  },
43
43
  "dependencies": {
44
- "@stdlib/utils-library-manifest": "^0.0.x"
44
+ "@stdlib/complex-float32": "^0.0.7",
45
+ "@stdlib/complex-float64": "^0.0.8",
46
+ "@stdlib/complex-reim": "^0.0.6",
47
+ "@stdlib/complex-reimf": "^0.0.1",
48
+ "@stdlib/utils-library-manifest": "^0.0.8"
45
49
  },
46
50
  "devDependencies": {
47
- "@stdlib/assert-is-browser": "^0.0.x",
48
- "@stdlib/bench": "^0.0.x",
49
- "@stdlib/math-base-assert-is-nan": "^0.0.x",
50
- "@stdlib/utils-try-require": "^0.0.x",
51
+ "@stdlib/assert-is-browser": "^0.0.8",
52
+ "@stdlib/bench": "^0.0.12",
53
+ "@stdlib/math-base-assert-is-nan": "^0.0.8",
54
+ "@stdlib/utils-try-require": "^0.0.7",
51
55
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
52
56
  "istanbul": "^0.4.1",
53
- "tap-spec": "5.x.x"
57
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
54
58
  },
55
59
  "engines": {
56
60
  "node": ">=0.10.0",
@@ -80,9 +84,13 @@
80
84
  "map",
81
85
  "transform"
82
86
  ],
83
- "__stdlib__": {},
87
+ "__stdlib__": {
88
+ "envs": {
89
+ "browser": false
90
+ }
91
+ },
84
92
  "funding": {
85
- "type": "patreon",
86
- "url": "https://www.patreon.com/athan"
93
+ "type": "opencollective",
94
+ "url": "https://opencollective.com/stdlib"
87
95
  }
88
96
  }