Skip to content

Commit 1994ca1

Browse files
committed
feat: add ZZZ_Z macro
--- 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: passed - 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 5dbd442 commit 1994ca1

File tree

5 files changed

+437
-2
lines changed

5 files changed

+437
-2
lines changed

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

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,103 @@ The function accepts the following arguments:
352352
void stdlib_math_base_napi_iid_d( napi_env env, napi_callback_info info, double (*fcn)( int32_t, int32_t, double ) );
353353
```
354354

355+
#### STDLIB_MATH_BASE_NAPI_MODULE_ZZZ_Z( fcn )
356+
357+
Macro for registering a Node-API module exporting an interface for invoking a ternary function accepting and returning double-precision complex floating-point numbers.
358+
359+
```c
360+
#include "stdlib/complex/float64/ctor.h"
361+
#include "stdlib/complex/float64/reim.h"
362+
363+
static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y, const stdlib_complex128_t z ) {
364+
double xre;
365+
double xim;
366+
double yre;
367+
double yim;
368+
double zre;
369+
double zim;
370+
double re;
371+
double im;
372+
373+
stdlib_complex128_reim( x, &xre, &xim );
374+
stdlib_complex128_reim( y, &yre, &yim );
375+
stdlib_complex128_reim( z, &zre, &zim );
376+
377+
re = xre + yre + zre;
378+
im = xim + yim + zim;
379+
380+
return stdlib_complex128( re, im );
381+
}
382+
383+
// ...
384+
385+
// Register a Node-API module:
386+
STDLIB_MATH_BASE_NAPI_MODULE_ZZZ_Z( add );
387+
```
388+
389+
The macro expects the following arguments:
390+
391+
- **fcn**: `stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t, stdlib_complex128_t )` ternary function.
392+
393+
When used, this macro should be used **instead of** `NAPI_MODULE`. The macro includes `NAPI_MODULE`, thus ensuring Node-API module registration.
394+
395+
#### stdlib_math_base_napi_zzz_z( env, info, fcn )
396+
397+
Invokes a ternary function accepting and returning double-precision complex floating-point numbers.
398+
399+
```c
400+
#include "stdlib/complex/float64/ctor.h"
401+
#include "stdlib/complex/float64/reim.h"
402+
#include <node_api.h>
403+
404+
// ...
405+
406+
static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y, const stdlib_complex128_t z ) {
407+
double xre;
408+
double xim;
409+
double yre;
410+
double yim;
411+
double zre;
412+
double zim;
413+
double re;
414+
double im;
415+
416+
stdlib_complex128_reim( x, &xre, &xim );
417+
stdlib_complex128_reim( y, &yre, &yim );
418+
stdlib_complex128_reim( z, &zre, &zim );
419+
420+
re = xre + yre + zre;
421+
im = xim + yim + zim;
422+
423+
return stdlib_complex128( re, im );
424+
}
425+
426+
// ...
427+
428+
/**
429+
* Receives JavaScript callback invocation data.
430+
*
431+
* @param env environment under which the function is invoked
432+
* @param info callback data
433+
* @return Node-API value
434+
*/
435+
napi_value addon( napi_env env, napi_callback_info info ) {
436+
return stdlib_math_base_napi_zzz_z( env, info, add );
437+
}
438+
439+
// ...
440+
```
441+
442+
The function accepts the following arguments:
443+
444+
- **env**: `[in] napi_env` environment under which the function is invoked.
445+
- **info**: `[in] napi_callback_info` callback data.
446+
- **fcn**: `[in] stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t, stdlib_complex128_t )` ternary function.
447+
448+
```c
449+
void stdlib_math_base_napi_zzz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t, stdlib_complex128_t ) );
450+
```
451+
355452
</section>
356453
357454
<!-- /.usage -->

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
#include "stdlib/math/base/napi/ternary/dii_d.h"
2525
#include "stdlib/math/base/napi/ternary/fff_f.h"
2626
#include "stdlib/math/base/napi/ternary/iid_d.h"
27+
#include "stdlib/math/base/napi/ternary/zzz_z.h"
2728

2829
#endif // !STDLIB_MATH_BASE_NAPI_TERNARY_H
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#ifndef STDLIB_MATH_BASE_NAPI_TERNARY_ZZZ_Z_H
20+
#define STDLIB_MATH_BASE_NAPI_TERNARY_ZZZ_Z_H
21+
22+
#include "stdlib/complex/float64/ctor.h"
23+
#include <node_api.h>
24+
#include <assert.h>
25+
26+
/**
27+
* Macro for registering a Node-API module exporting an interface invoking a ternary function accepting and returning double-precision complex floating-point numbers.
28+
*
29+
* @param fcn ternary function
30+
*
31+
* @example
32+
* #include "stdlib/complex/float64/ctor.h"
33+
* #include "stdlib/complex/float64/reim.h"
34+
*
35+
* static stdlib_complex128_t add( const stdlib_complex128_t x, const stdlib_complex128_t y, const stdlib_complex128_t z ) {
36+
* double xre;
37+
* double xim;
38+
* double yre;
39+
* double yim;
40+
* double zre;
41+
* double zim;
42+
* double re;
43+
* double im;
44+
*
45+
* stdlib_complex128_reim( x, &xre, &xim );
46+
* stdlib_complex128_reim( y, &yre, &yim );
47+
* stdlib_complex128_reim( z, &zre, &zim );
48+
*
49+
* re = xre + yre + zre;
50+
* im = xim + yim + zim;
51+
*
52+
* return stdlib_complex128( re, im );
53+
* }
54+
*
55+
* // ...
56+
*
57+
* // Register a Node-API module:
58+
* STDLIB_MATH_BASE_NAPI_MODULE_ZZZ_Z( add );
59+
*/
60+
#define STDLIB_MATH_BASE_NAPI_MODULE_ZZZ_Z( fcn ) \
61+
static napi_value stdlib_math_base_napi_zzz_z_wrapper( \
62+
napi_env env, \
63+
napi_callback_info info \
64+
) { \
65+
return stdlib_math_base_napi_zzz_z( env, info, fcn ); \
66+
}; \
67+
static napi_value stdlib_math_base_napi_zzz_z_init( \
68+
napi_env env, \
69+
napi_value exports \
70+
) { \
71+
napi_value fcn; \
72+
napi_status status = napi_create_function( \
73+
env, \
74+
"exports", \
75+
NAPI_AUTO_LENGTH, \
76+
stdlib_math_base_napi_zzz_z_wrapper, \
77+
NULL, \
78+
&fcn \
79+
); \
80+
assert( status == napi_ok ); \
81+
return fcn; \
82+
}; \
83+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zzz_z_init )
84+
85+
/*
86+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
87+
*/
88+
#ifdef __cplusplus
89+
extern "C" {
90+
#endif
91+
92+
/**
93+
* Invokes a ternary function accepting and returning double-precision complex floating-point numbers.
94+
*/
95+
napi_value stdlib_math_base_napi_zzz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t, stdlib_complex128_t ) );
96+
97+
#ifdef __cplusplus
98+
}
99+
#endif
100+
101+
#endif // !STDLIB_MATH_BASE_NAPI_TERNARY_ZZZ_Z_H

lib/node_modules/@stdlib/math/base/napi/ternary/manifest.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,20 @@
2828
"./src/ddd_d.c",
2929
"./src/dii_d.c",
3030
"./src/fff_f.c",
31-
"./src/iid_d.c"
31+
"./src/iid_d.c",
32+
"./src/zzz_z.c"
3233
],
3334
"include": [
3435
"./include"
3536
],
3637
"libraries": [],
3738
"libpath": [],
38-
"dependencies": []
39+
"dependencies": [
40+
"@stdlib/complex/float32/ctor",
41+
"@stdlib/complex/float64/ctor",
42+
"@stdlib/complex/float64/reim",
43+
"@stdlib/complex/float32/reim"
44+
]
3945
}
4046
]
4147
}

0 commit comments

Comments
 (0)