Skip to content

Commit b8756e8

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents b5aed7a + c81313e commit b8756e8

20 files changed

Lines changed: 1251 additions & 73 deletions

File tree

lib/node_modules/@stdlib/array/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ Lastly, the namespace contains various other functions for dealing with arrays,
167167
- <span class="signature">[`convertArray( arr, dtype )`][@stdlib/array/convert]</span><span class="delimiter">: </span><span class="description">convert an array to an array of a different data type.</span>
168168
- <span class="signature">[`DataView( buffer[, byteOffset[, byteLength]] )`][@stdlib/array/dataview]</span><span class="delimiter">: </span><span class="description">constructor which returns a data view representing a provided array buffer.</span>
169169
- <span class="signature">[`arrayDataType( array )`][@stdlib/array/dtype]</span><span class="delimiter">: </span><span class="description">return the data type of an array.</span>
170+
- <span class="signature">[`aemptyLike( x[, dtype] )`][@stdlib/array/empty-like]</span><span class="delimiter">: </span><span class="description">create an uninitialized array having the same length and data type as a provided array.</span>
170171
- <span class="signature">[`aempty( length[, dtype] )`][@stdlib/array/empty]</span><span class="delimiter">: </span><span class="description">create an uninitialized array having a specified length.</span>
171172
- <span class="signature">[`filledarrayBy()`][@stdlib/array/filled-by]</span><span class="delimiter">: </span><span class="description">create a filled array according to a provided callback function.</span>
172173
- <span class="signature">[`filledarray()`][@stdlib/array/filled]</span><span class="delimiter">: </span><span class="description">create a filled array.</span>
@@ -254,6 +255,8 @@ console.log( objectKeys( ns ) );
254255

255256
[@stdlib/array/dtype]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/dtype
256257

258+
[@stdlib/array/empty-like]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/empty-like
259+
257260
[@stdlib/array/empty]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/empty
258261

259262
[@stdlib/array/filled-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/filled-by

lib/node_modules/@stdlib/math/base/napi/binary/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,74 @@ The macro expects the following arguments:
707707

708708
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
709709

710+
#### STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( fcn )
711+
712+
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.
713+
714+
```c
715+
#include "stdlib/complex/float64.h"
716+
#include "stdlib/complex/reim.h"
717+
718+
static stdlib_complex128_t mul( const stdlib_complex128_t x, const double y ) {
719+
double xre;
720+
double xim;
721+
double re;
722+
double im;
723+
724+
stdlib_reim( x, &xre, &xim );
725+
726+
re = xre * y;
727+
im = xim * y;
728+
729+
return stdlib_complex128( re, im );
730+
}
731+
732+
// ...
733+
734+
// Register a Node-API module:
735+
STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( mul );
736+
```
737+
738+
The macro expects the following arguments:
739+
740+
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, double )` binary function.
741+
742+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
743+
744+
#### STDLIB_MATH_BASE_NAPI_MODULE_CF_C( fcn )
745+
746+
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.
747+
748+
```c
749+
#include "stdlib/complex/float32.h"
750+
#include "stdlib/complex/reimf.h"
751+
752+
static stdlib_complex64_t add( const stdlib_complex64_t x, const float y ) {
753+
float xre;
754+
float xim;
755+
float re;
756+
float im;
757+
758+
stdlib_reimf( x, &xre, &xim );
759+
760+
re = xre * y;
761+
im = xim * y;
762+
763+
return stdlib_complex64( re, im );
764+
}
765+
766+
// ...
767+
768+
// Register a Node-API module:
769+
STDLIB_MATH_BASE_NAPI_MODULE_CF_C( add );
770+
```
771+
772+
The macro expects the following arguments:
773+
774+
- **fcn**: `stdlib_complex64_t (*fcn)( stdlib_complex64_t, float )` binary function.
775+
776+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
777+
710778
</section>
711779

712780
<!-- /.usage -->

lib/node_modules/@stdlib/math/base/napi/binary/include/stdlib/math/base/napi/binary.h

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,100 @@
396396
}; \
397397
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ci_c_init )
398398

399+
/**
400+
* 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.
401+
*
402+
* @param fcn binary function
403+
*
404+
* @example
405+
* #include "stdlib/complex/float64.h"
406+
* #include "stdlib/complex/reim.h"
407+
*
408+
* static stdlib_complex128_t mul( const stdlib_complex128_t x, const double n ) {
409+
* double re;
410+
* double im;
411+
*
412+
* stdlib_reim( x, &re, &im );
413+
* return stdlib_complex128( re*n, im*n );
414+
* }
415+
*
416+
* // ...
417+
*
418+
* // Register a Node-API module:
419+
* STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( mul );
420+
*/
421+
#define STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( fcn ) \
422+
static napi_value stdlib_math_base_napi_zd_z_wrapper( \
423+
napi_env env, \
424+
napi_callback_info info \
425+
) { \
426+
return stdlib_math_base_napi_zd_z( env, info, fcn ); \
427+
}; \
428+
static napi_value stdlib_math_base_napi_zd_z_init( \
429+
napi_env env, \
430+
napi_value exports \
431+
) { \
432+
napi_value fcn; \
433+
napi_status status = napi_create_function( \
434+
env, \
435+
"exports", \
436+
NAPI_AUTO_LENGTH, \
437+
stdlib_math_base_napi_zd_z_wrapper, \
438+
NULL, \
439+
&fcn \
440+
); \
441+
assert( status == napi_ok ); \
442+
return fcn; \
443+
}; \
444+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zd_z_init )
445+
446+
/**
447+
* 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.
448+
*
449+
* @param fcn binary function
450+
*
451+
* @example
452+
* #include "stdlib/complex/float32.h"
453+
* #include "stdlib/complex/reimf.h"
454+
*
455+
* static stdlib_complex64_t mul( const stdlib_complex64_t x, const float n ) {
456+
* float re;
457+
* float im;
458+
*
459+
* stdlib_reimf( x, &re, &im );
460+
* return stdlib_complex64( re*n, im*n );
461+
* }
462+
*
463+
* // ...
464+
*
465+
* // Register a Node-API module:
466+
* STDLIB_MATH_BASE_NAPI_MODULE_CF_C( mul );
467+
*/
468+
#define STDLIB_MATH_BASE_NAPI_MODULE_CF_C( fcn ) \
469+
static napi_value stdlib_math_base_napi_cf_c_wrapper( \
470+
napi_env env, \
471+
napi_callback_info info \
472+
) { \
473+
return stdlib_math_base_napi_cf_c( env, info, fcn ); \
474+
}; \
475+
static napi_value stdlib_math_base_napi_cf_c_init( \
476+
napi_env env, \
477+
napi_value exports \
478+
) { \
479+
napi_value fcn; \
480+
napi_status status = napi_create_function( \
481+
env, \
482+
"exports", \
483+
NAPI_AUTO_LENGTH, \
484+
stdlib_math_base_napi_cf_c_wrapper, \
485+
NULL, \
486+
&fcn \
487+
); \
488+
assert( status == napi_ok ); \
489+
return fcn; \
490+
}; \
491+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_cf_c_init )
492+
399493
/*
400494
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
401495
*/
@@ -443,6 +537,16 @@ napi_value stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, st
443537
*/
444538
napi_value stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) );
445539

540+
/**
541+
* 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.
542+
*/
543+
napi_value stdlib_math_base_napi_zd_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, double ) );
544+
545+
/**
546+
* 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.
547+
*/
548+
napi_value stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, float ) );
549+
446550
#ifdef __cplusplus
447551
}
448552
#endif

0 commit comments

Comments
 (0)