@stdlib/math-base-napi-unary 0.0.4 → 0.0.8

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,12 +19,14 @@
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>
25
27
 
26
28
  /**
27
- * Macro for registering an N-API module exporting an interface invoking a unary function accepting and returning double-precision floating-point numbers.
29
+ * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning double-precision floating-point numbers.
28
30
  *
29
31
  * @param fcn unary function
30
32
  *
@@ -35,7 +37,7 @@
35
37
  *
36
38
  * // ...
37
39
  *
38
- * // Register an N-API module:
40
+ * // Register a Node-API module:
39
41
  * STDLIB_MATH_BASE_NAPI_MODULE_D_D( scale );
40
42
  */
41
43
  #define STDLIB_MATH_BASE_NAPI_MODULE_D_D( fcn ) \
@@ -64,7 +66,7 @@
64
66
  NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_d_d_init )
65
67
 
66
68
  /**
67
- * Macro for registering an N-API module exporting an interface invoking a unary function accepting and returning single-precision floating-point numbers.
69
+ * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning single-precision floating-point numbers.
68
70
  *
69
71
  * @param fcn unary function
70
72
  *
@@ -75,7 +77,7 @@
75
77
  *
76
78
  * // ...
77
79
  *
78
- * // Register an N-API module:
80
+ * // Register a Node-API module:
79
81
  * STDLIB_MATH_BASE_NAPI_MODULE_F_F( scale );
80
82
  */
81
83
  #define STDLIB_MATH_BASE_NAPI_MODULE_F_F( fcn ) \
@@ -104,7 +106,193 @@
104
106
  NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_f_f_init )
105
107
 
106
108
  /**
107
- * Macro for registering an N-API module exporting an interface invoking a unary function accepting and returning 32-bit signed integers.
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
+
294
+ /**
295
+ * Macro for registering a Node-API module exporting an interface invoking a unary function accepting and returning 32-bit signed integers.
108
296
  *
109
297
  * @param fcn unary function
110
298
  *
@@ -117,7 +305,7 @@
117
305
  *
118
306
  * // ...
119
307
  *
120
- * // Register an N-API module:
308
+ * // Register a Node-API module:
121
309
  * STDLIB_MATH_BASE_NAPI_MODULE_I_I( scale );
122
310
  */
123
311
  #define STDLIB_MATH_BASE_NAPI_MODULE_I_I( fcn ) \
@@ -162,6 +350,26 @@ napi_value stdlib_math_base_napi_d_d( napi_env env, napi_callback_info info, dou
162
350
  */
163
351
  napi_value stdlib_math_base_napi_f_f( napi_env env, napi_callback_info info, float (*fcn)( float ) );
164
352
 
353
+ /**
354
+ * Invokes a unary function accepting and returning double-precision complex floating-point numbers.
355
+ */
356
+ napi_value stdlib_math_base_napi_z_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t ) );
357
+
358
+ /**
359
+ * Invokes a unary function accepting a double-precision complex floating-point number and returning a double-precision floating-point number.
360
+ */
361
+ napi_value stdlib_math_base_napi_z_d( napi_env env, napi_callback_info info, double (*fcn)( stdlib_complex128_t ) );
362
+
363
+ /**
364
+ * Invokes a unary function accepting and returning single-precision complex floating-point numbers.
365
+ */
366
+ napi_value stdlib_math_base_napi_c_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t ) );
367
+
368
+ /**
369
+ * Invokes a unary function accepting a single-precision complex floating-point number and returning a single-precision floating-point number.
370
+ */
371
+ napi_value stdlib_math_base_napi_c_f( napi_env env, napi_callback_info info, float (*fcn)( stdlib_complex64_t ) );
372
+
165
373
  /**
166
374
  * Invokes a unary function accepting and returning 32-bit signed integers.
167
375
  */
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@stdlib/math-base-napi-unary",
3
- "version": "0.0.4",
4
- "description": "C APIs for registering an N-API module exporting an interface for invoking a unary numerical function.",
3
+ "version": "0.0.8",
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": {
7
7
  "name": "The Stdlib Authors",
@@ -15,7 +15,7 @@
15
15
  ],
16
16
  "main": "./lib",
17
17
  "browser": "./lib/browser.js",
18
- "gypfile": true,
18
+ "gypfile": false,
19
19
  "directories": {
20
20
  "benchmark": "./benchmark",
21
21
  "doc": "./docs",
@@ -32,7 +32,7 @@
32
32
  "examples": "make examples",
33
33
  "benchmark": "make benchmark"
34
34
  },
35
- "homepage": "https://github.com/stdlib-js/stdlib",
35
+ "homepage": "https://stdlib.io",
36
36
  "repository": {
37
37
  "type": "git",
38
38
  "url": "git://github.com/stdlib-js/math-base-napi-unary.git"
@@ -41,6 +41,10 @@
41
41
  "url": "https://github.com/stdlib-js/stdlib/issues"
42
42
  },
43
43
  "dependencies": {
44
+ "@stdlib/complex-float32": "^0.0.x",
45
+ "@stdlib/complex-float64": "^0.0.x",
46
+ "@stdlib/complex-reim": "^0.0.x",
47
+ "@stdlib/complex-reimf": "^0.0.x",
44
48
  "@stdlib/utils-library-manifest": "^0.0.x"
45
49
  },
46
50
  "devDependencies": {
@@ -74,6 +78,7 @@
74
78
  "math",
75
79
  "napi",
76
80
  "n-api",
81
+ "node-api",
77
82
  "addon",
78
83
  "unary",
79
84
  "map",