Skip to content

Commit 89df5ae

Browse files
committed
docs: add DZ_Z docs
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 8a62393 commit 89df5ae

File tree

1 file changed

+85
-0
lines changed
  • lib/node_modules/@stdlib/math/base/napi/binary

1 file changed

+85
-0
lines changed

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

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,91 @@ The function accepts the following arguments:
492492
void stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) );
493493
```
494494
495+
#### STDLIB_MATH_BASE_NAPI_MODULE_DZ_Z( fcn )
496+
497+
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.
498+
499+
```c
500+
#include "stdlib/complex/float64/ctor.h"
501+
#include "stdlib/complex/float64/reim.h"
502+
503+
static stdlib_complex128_t mul( const double y, const stdlib_complex128_t x ) {
504+
double xre;
505+
double xim;
506+
double re;
507+
double im;
508+
509+
stdlib_complex128_reim( x, &xre, &xim );
510+
511+
re = xre * y;
512+
im = xim * y;
513+
514+
return stdlib_complex128( re, im );
515+
}
516+
517+
// ...
518+
519+
// Register a Node-API module:
520+
STDLIB_MATH_BASE_NAPI_MODULE_DZ_Z( mul );
521+
```
522+
523+
The macro expects the following arguments:
524+
525+
- **fcn**: `stdlib_complex128_t (*fcn)( double, stdlib_complex128_t )` binary function.
526+
527+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
528+
529+
#### stdlib_math_base_napi_dz_z( env, info, fcn )
530+
531+
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.
532+
533+
```c
534+
#include "stdlib/complex/float64/ctor.h"
535+
#include "stdlib/complex/float64/reim.h"
536+
#include <node_api.h>
537+
538+
// ...
539+
540+
static stdlib_complex128_t mul( const double y, const stdlib_complex128_t x ) {
541+
double xre;
542+
double xim;
543+
double re;
544+
double im;
545+
546+
stdlib_complex128_reim( x, &xre, &xim );
547+
548+
re = xre * y;
549+
im = xim * y;
550+
551+
return stdlib_complex128( re, im );
552+
}
553+
554+
// ...
555+
556+
/**
557+
* Receives JavaScript callback invocation data.
558+
*
559+
* @param env environment under which the function is invoked
560+
* @param info callback data
561+
* @return Node-API value
562+
*/
563+
napi_value addon( napi_env env, napi_callback_info info ) {
564+
return stdlib_math_base_napi_dz_z( env, info, mul );
565+
}
566+
567+
// ...
568+
```
569+
570+
The function accepts the following arguments:
571+
572+
- **env**: `[in] napi_env` environment under which the function is invoked.
573+
- **info**: `[in] napi_callback_info` callback data.
574+
- **fcn**: `[in] stdlib_complex128_t (*fcn)( double, stdlib_complex128_t )` binary function.
575+
576+
```c
577+
void stdlib_math_base_napi_dz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( double, stdlib_complex128_t ) );
578+
```
579+
495580
#### STDLIB_MATH_BASE_NAPI_MODULE_FF_F( fcn )
496581

497582
Macro for registering a Node-API module exporting an interface for invoking a binary function accepting and returning single-precision floating-point numbers.

0 commit comments

Comments
 (0)