@stdlib/math-base-napi-binary 0.3.0 → 0.3.2
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.
- package/NOTICE +1 -1
- package/README.md +1065 -284
- package/include/stdlib/math/base/napi/binary/bb_b.h +84 -0
- package/include/stdlib/math/base/napi/binary/cc_c.h +98 -0
- package/include/stdlib/math/base/napi/binary/cf_c.h +89 -0
- package/include/stdlib/math/base/napi/binary/ci_c.h +91 -0
- package/include/stdlib/math/base/napi/binary/dd_d.h +81 -0
- package/include/stdlib/math/base/napi/binary/di_d.h +84 -0
- package/include/stdlib/math/base/napi/binary/dz_z.h +89 -0
- package/include/stdlib/math/base/napi/binary/fc_c.h +89 -0
- package/include/stdlib/math/base/napi/binary/ff_f.h +81 -0
- package/include/stdlib/math/base/napi/binary/fi_f.h +84 -0
- package/include/stdlib/math/base/napi/binary/id_d.h +84 -0
- package/include/stdlib/math/base/napi/binary/ii_d.h +84 -0
- package/include/stdlib/math/base/napi/binary/ii_f.h +84 -0
- package/include/stdlib/math/base/napi/binary/ii_i.h +84 -0
- package/include/stdlib/math/base/napi/binary/kk_k.h +84 -0
- package/include/stdlib/math/base/napi/binary/ll_d.h +84 -0
- package/include/stdlib/math/base/napi/binary/ss_s.h +84 -0
- package/include/stdlib/math/base/napi/binary/tt_t.h +84 -0
- package/include/stdlib/math/base/napi/binary/uu_u.h +84 -0
- package/include/stdlib/math/base/napi/binary/zd_z.h +89 -0
- package/include/stdlib/math/base/napi/binary/zi_z.h +91 -0
- package/include/stdlib/math/base/napi/binary/zz_z.h +98 -0
- package/include/stdlib/math/base/napi/binary.h +23 -621
- package/manifest.json +56 -36
- package/package.json +5 -10
- package/src/bb_b.c +84 -0
- package/src/cc_c.c +179 -0
- package/src/cf_c.c +143 -0
- package/src/ci_c.c +143 -0
- package/src/dd_d.c +83 -0
- package/src/di_d.c +84 -0
- package/src/dz_z.c +142 -0
- package/src/fc_c.c +142 -0
- package/src/ff_f.c +83 -0
- package/src/fi_f.c +84 -0
- package/src/id_d.c +84 -0
- package/src/ii_d.c +84 -0
- package/src/ii_f.c +84 -0
- package/src/ii_i.c +84 -0
- package/src/kk_k.c +84 -0
- package/src/ll_d.c +84 -0
- package/src/ss_s.c +84 -0
- package/src/tt_t.c +84 -0
- package/src/uu_u.c +84 -0
- package/src/zd_z.c +142 -0
- package/src/zi_z.c +143 -0
- package/src/zz_z.c +179 -0
- package/src/main.c +0 -1187
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2020 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_BINARY_LL_D_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_LL_D_H
|
|
21
|
+
|
|
22
|
+
#include <node_api.h>
|
|
23
|
+
#include <assert.h>
|
|
24
|
+
#include <stdint.h>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Macro for registering a Node-API module exporting an interface invoking a binary function accepting signed 64-bit integers and returning a double-precision floating-point number.
|
|
28
|
+
*
|
|
29
|
+
* @param fcn binary function
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* #include <stdint.h>
|
|
33
|
+
*
|
|
34
|
+
* static double fcn( const int_64 x, const int_64 y ) {
|
|
35
|
+
* // ...
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* // ...
|
|
39
|
+
*
|
|
40
|
+
* // Register a Node-API module:
|
|
41
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_LL_D( fcn );
|
|
42
|
+
*/
|
|
43
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_LL_D( fcn ) \
|
|
44
|
+
static napi_value stdlib_math_base_napi_ll_d_wrapper( \
|
|
45
|
+
napi_env env, \
|
|
46
|
+
napi_callback_info info \
|
|
47
|
+
) { \
|
|
48
|
+
return stdlib_math_base_napi_ll_d( env, info, fcn ); \
|
|
49
|
+
}; \
|
|
50
|
+
static napi_value stdlib_math_base_napi_ll_d_init( \
|
|
51
|
+
napi_env env, \
|
|
52
|
+
napi_value exports \
|
|
53
|
+
) { \
|
|
54
|
+
napi_value f; \
|
|
55
|
+
napi_status status = napi_create_function( \
|
|
56
|
+
env, \
|
|
57
|
+
"exports", \
|
|
58
|
+
NAPI_AUTO_LENGTH, \
|
|
59
|
+
stdlib_math_base_napi_ll_d_wrapper, \
|
|
60
|
+
NULL, \
|
|
61
|
+
&f \
|
|
62
|
+
); \
|
|
63
|
+
assert( status == napi_ok ); \
|
|
64
|
+
return f; \
|
|
65
|
+
}; \
|
|
66
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ll_d_init )
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
70
|
+
*/
|
|
71
|
+
#ifdef __cplusplus
|
|
72
|
+
extern "C" {
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Invokes a binary function accepting signed 64-bit integers and returning a double-precision floating-point number.
|
|
77
|
+
*/
|
|
78
|
+
napi_value stdlib_math_base_napi_ll_d( napi_env env, napi_callback_info info, double (*fcn)( int64_t, int64_t ) );
|
|
79
|
+
|
|
80
|
+
#ifdef __cplusplus
|
|
81
|
+
}
|
|
82
|
+
#endif
|
|
83
|
+
|
|
84
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_LL_D_H
|
|
@@ -0,0 +1,84 @@
|
|
|
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_BINARY_SS_S_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_SS_S_H
|
|
21
|
+
|
|
22
|
+
#include <node_api.h>
|
|
23
|
+
#include <assert.h>
|
|
24
|
+
#include <stdint.h>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning signed 8-bit integers.
|
|
28
|
+
*
|
|
29
|
+
* @param fcn binary function
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* #include <stdint.h>
|
|
33
|
+
*
|
|
34
|
+
* static int8_t add( const int8_t x, const int8_t y ) {
|
|
35
|
+
* return x + y;
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* // ...
|
|
39
|
+
*
|
|
40
|
+
* // Register a Node-API module:
|
|
41
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_SS_S( add );
|
|
42
|
+
*/
|
|
43
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_SS_S( fcn ) \
|
|
44
|
+
static napi_value stdlib_math_base_napi_ss_s_wrapper( \
|
|
45
|
+
napi_env env, \
|
|
46
|
+
napi_callback_info info \
|
|
47
|
+
) { \
|
|
48
|
+
return stdlib_math_base_napi_ss_s( env, info, fcn ); \
|
|
49
|
+
}; \
|
|
50
|
+
static napi_value stdlib_math_base_napi_ss_s_init( \
|
|
51
|
+
napi_env env, \
|
|
52
|
+
napi_value exports \
|
|
53
|
+
) { \
|
|
54
|
+
napi_value f; \
|
|
55
|
+
napi_status status = napi_create_function( \
|
|
56
|
+
env, \
|
|
57
|
+
"exports", \
|
|
58
|
+
NAPI_AUTO_LENGTH, \
|
|
59
|
+
stdlib_math_base_napi_ss_s_wrapper, \
|
|
60
|
+
NULL, \
|
|
61
|
+
&f \
|
|
62
|
+
); \
|
|
63
|
+
assert( status == napi_ok ); \
|
|
64
|
+
return f; \
|
|
65
|
+
}; \
|
|
66
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_ss_s_init )
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
70
|
+
*/
|
|
71
|
+
#ifdef __cplusplus
|
|
72
|
+
extern "C" {
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Invokes a binary function accepting and returning signed 8-bit integers.
|
|
77
|
+
*/
|
|
78
|
+
napi_value stdlib_math_base_napi_ss_s( napi_env env, napi_callback_info info, int8_t (*fcn)( int8_t, int8_t ) );
|
|
79
|
+
|
|
80
|
+
#ifdef __cplusplus
|
|
81
|
+
}
|
|
82
|
+
#endif
|
|
83
|
+
|
|
84
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_SS_S_H
|
|
@@ -0,0 +1,84 @@
|
|
|
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_BINARY_TT_T_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_TT_T_H
|
|
21
|
+
|
|
22
|
+
#include <node_api.h>
|
|
23
|
+
#include <assert.h>
|
|
24
|
+
#include <stdint.h>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning unsigned 16-bit integers.
|
|
28
|
+
*
|
|
29
|
+
* @param fcn binary function
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* #include <stdint.h>
|
|
33
|
+
*
|
|
34
|
+
* static uint16_t add( const uint16_t x, const uint16_t y ) {
|
|
35
|
+
* return x + y;
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* // ...
|
|
39
|
+
*
|
|
40
|
+
* // Register a Node-API module:
|
|
41
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_TT_T( add );
|
|
42
|
+
*/
|
|
43
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_TT_T( fcn ) \
|
|
44
|
+
static napi_value stdlib_math_base_napi_tt_t_wrapper( \
|
|
45
|
+
napi_env env, \
|
|
46
|
+
napi_callback_info info \
|
|
47
|
+
) { \
|
|
48
|
+
return stdlib_math_base_napi_tt_t( env, info, fcn ); \
|
|
49
|
+
}; \
|
|
50
|
+
static napi_value stdlib_math_base_napi_tt_t_init( \
|
|
51
|
+
napi_env env, \
|
|
52
|
+
napi_value exports \
|
|
53
|
+
) { \
|
|
54
|
+
napi_value f; \
|
|
55
|
+
napi_status status = napi_create_function( \
|
|
56
|
+
env, \
|
|
57
|
+
"exports", \
|
|
58
|
+
NAPI_AUTO_LENGTH, \
|
|
59
|
+
stdlib_math_base_napi_tt_t_wrapper, \
|
|
60
|
+
NULL, \
|
|
61
|
+
&f \
|
|
62
|
+
); \
|
|
63
|
+
assert( status == napi_ok ); \
|
|
64
|
+
return f; \
|
|
65
|
+
}; \
|
|
66
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_tt_t_init )
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
70
|
+
*/
|
|
71
|
+
#ifdef __cplusplus
|
|
72
|
+
extern "C" {
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Invokes a binary function accepting and returning unsigned 16-bit integers.
|
|
77
|
+
*/
|
|
78
|
+
napi_value stdlib_math_base_napi_tt_t( napi_env env, napi_callback_info info, uint16_t (*fcn)( uint16_t, uint16_t ) );
|
|
79
|
+
|
|
80
|
+
#ifdef __cplusplus
|
|
81
|
+
}
|
|
82
|
+
#endif
|
|
83
|
+
|
|
84
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_TT_T_H
|
|
@@ -0,0 +1,84 @@
|
|
|
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_BINARY_UU_U_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_UU_U_H
|
|
21
|
+
|
|
22
|
+
#include <node_api.h>
|
|
23
|
+
#include <assert.h>
|
|
24
|
+
#include <stdint.h>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning unsigned 32-bit integers.
|
|
28
|
+
*
|
|
29
|
+
* @param fcn binary function
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* #include <stdint.h>
|
|
33
|
+
*
|
|
34
|
+
* static uint32_t add( const uint32_t x, const uint32_t y ) {
|
|
35
|
+
* return x + y;
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* // ...
|
|
39
|
+
*
|
|
40
|
+
* // Register a Node-API module:
|
|
41
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_UU_U( add );
|
|
42
|
+
*/
|
|
43
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_UU_U( fcn ) \
|
|
44
|
+
static napi_value stdlib_math_base_napi_uu_u_wrapper( \
|
|
45
|
+
napi_env env, \
|
|
46
|
+
napi_callback_info info \
|
|
47
|
+
) { \
|
|
48
|
+
return stdlib_math_base_napi_uu_u( env, info, fcn ); \
|
|
49
|
+
}; \
|
|
50
|
+
static napi_value stdlib_math_base_napi_uu_u_init( \
|
|
51
|
+
napi_env env, \
|
|
52
|
+
napi_value exports \
|
|
53
|
+
) { \
|
|
54
|
+
napi_value f; \
|
|
55
|
+
napi_status status = napi_create_function( \
|
|
56
|
+
env, \
|
|
57
|
+
"exports", \
|
|
58
|
+
NAPI_AUTO_LENGTH, \
|
|
59
|
+
stdlib_math_base_napi_uu_u_wrapper, \
|
|
60
|
+
NULL, \
|
|
61
|
+
&f \
|
|
62
|
+
); \
|
|
63
|
+
assert( status == napi_ok ); \
|
|
64
|
+
return f; \
|
|
65
|
+
}; \
|
|
66
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_uu_u_init )
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
70
|
+
*/
|
|
71
|
+
#ifdef __cplusplus
|
|
72
|
+
extern "C" {
|
|
73
|
+
#endif
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Invokes a binary function accepting and returning unsigned 32-bit integers.
|
|
77
|
+
*/
|
|
78
|
+
napi_value stdlib_math_base_napi_uu_u( napi_env env, napi_callback_info info, uint32_t (*fcn)( uint32_t, uint32_t ) );
|
|
79
|
+
|
|
80
|
+
#ifdef __cplusplus
|
|
81
|
+
}
|
|
82
|
+
#endif
|
|
83
|
+
|
|
84
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_UU_U_H
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2020 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_BINARY_ZD_Z_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_ZD_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 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.
|
|
28
|
+
*
|
|
29
|
+
* @param fcn binary function
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* #include "stdlib/complex/float64/ctor.h"
|
|
33
|
+
* #include "stdlib/complex/float64/reim.h"
|
|
34
|
+
*
|
|
35
|
+
* static stdlib_complex128_t mul( const stdlib_complex128_t x, const double n ) {
|
|
36
|
+
* double re;
|
|
37
|
+
* double im;
|
|
38
|
+
*
|
|
39
|
+
* stdlib_complex128_reim( x, &re, &im );
|
|
40
|
+
* return stdlib_complex128( re*n, im*n );
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* // ...
|
|
44
|
+
*
|
|
45
|
+
* // Register a Node-API module:
|
|
46
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( mul );
|
|
47
|
+
*/
|
|
48
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_ZD_Z( fcn ) \
|
|
49
|
+
static napi_value stdlib_math_base_napi_zd_z_wrapper( \
|
|
50
|
+
napi_env env, \
|
|
51
|
+
napi_callback_info info \
|
|
52
|
+
) { \
|
|
53
|
+
return stdlib_math_base_napi_zd_z( env, info, fcn ); \
|
|
54
|
+
}; \
|
|
55
|
+
static napi_value stdlib_math_base_napi_zd_z_init( \
|
|
56
|
+
napi_env env, \
|
|
57
|
+
napi_value exports \
|
|
58
|
+
) { \
|
|
59
|
+
napi_value f; \
|
|
60
|
+
napi_status status = napi_create_function( \
|
|
61
|
+
env, \
|
|
62
|
+
"exports", \
|
|
63
|
+
NAPI_AUTO_LENGTH, \
|
|
64
|
+
stdlib_math_base_napi_zd_z_wrapper, \
|
|
65
|
+
NULL, \
|
|
66
|
+
&f \
|
|
67
|
+
); \
|
|
68
|
+
assert( status == napi_ok ); \
|
|
69
|
+
return f; \
|
|
70
|
+
}; \
|
|
71
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zd_z_init )
|
|
72
|
+
|
|
73
|
+
/*
|
|
74
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
75
|
+
*/
|
|
76
|
+
#ifdef __cplusplus
|
|
77
|
+
extern "C" {
|
|
78
|
+
#endif
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 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.
|
|
82
|
+
*/
|
|
83
|
+
napi_value stdlib_math_base_napi_zd_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, double ) );
|
|
84
|
+
|
|
85
|
+
#ifdef __cplusplus
|
|
86
|
+
}
|
|
87
|
+
#endif
|
|
88
|
+
|
|
89
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_ZD_Z_H
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2020 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_BINARY_ZI_Z_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_ZI_Z_H
|
|
21
|
+
|
|
22
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
23
|
+
#include <node_api.h>
|
|
24
|
+
#include <assert.h>
|
|
25
|
+
#include <stdint.h>
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Macro for registering a Node-API module exporting an interface invoking a binary function accepting a double-precision complex floating-point number and a signed 32-bit and returning a double-precision complex floating-point number.
|
|
29
|
+
*
|
|
30
|
+
* @param fcn binary function
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* #include "stdlib/complex/float64/ctor.h"
|
|
34
|
+
* #include "stdlib/complex/float64/reim.h"
|
|
35
|
+
* #include <stdint.h>
|
|
36
|
+
*
|
|
37
|
+
* static stdlib_complex128_t mul( const stdlib_complex128_t x, const int32_t n ) {
|
|
38
|
+
* double re;
|
|
39
|
+
* double im;
|
|
40
|
+
*
|
|
41
|
+
* stdlib_complex128_reim( x, &re, &im );
|
|
42
|
+
* return stdlib_complex128( re*n, im*n );
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* // ...
|
|
46
|
+
*
|
|
47
|
+
* // Register a Node-API module:
|
|
48
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( mul );
|
|
49
|
+
*/
|
|
50
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_ZI_Z( fcn ) \
|
|
51
|
+
static napi_value stdlib_math_base_napi_zi_z_wrapper( \
|
|
52
|
+
napi_env env, \
|
|
53
|
+
napi_callback_info info \
|
|
54
|
+
) { \
|
|
55
|
+
return stdlib_math_base_napi_zi_z( env, info, fcn ); \
|
|
56
|
+
}; \
|
|
57
|
+
static napi_value stdlib_math_base_napi_zi_z_init( \
|
|
58
|
+
napi_env env, \
|
|
59
|
+
napi_value exports \
|
|
60
|
+
) { \
|
|
61
|
+
napi_value f; \
|
|
62
|
+
napi_status status = napi_create_function( \
|
|
63
|
+
env, \
|
|
64
|
+
"exports", \
|
|
65
|
+
NAPI_AUTO_LENGTH, \
|
|
66
|
+
stdlib_math_base_napi_zi_z_wrapper, \
|
|
67
|
+
NULL, \
|
|
68
|
+
&f \
|
|
69
|
+
); \
|
|
70
|
+
assert( status == napi_ok ); \
|
|
71
|
+
return f; \
|
|
72
|
+
}; \
|
|
73
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zi_z_init )
|
|
74
|
+
|
|
75
|
+
/*
|
|
76
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
77
|
+
*/
|
|
78
|
+
#ifdef __cplusplus
|
|
79
|
+
extern "C" {
|
|
80
|
+
#endif
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Invokes a binary function accepting a double-precision complex floating-point number and a signed 32-bit integer and returning a double-precision complex floating-point number.
|
|
84
|
+
*/
|
|
85
|
+
napi_value stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t ) );
|
|
86
|
+
|
|
87
|
+
#ifdef __cplusplus
|
|
88
|
+
}
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_ZI_Z_H
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2020 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_BINARY_ZZ_Z_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_ZZ_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 binary function accepting and returning double-precision complex floating-point numbers.
|
|
28
|
+
*
|
|
29
|
+
* @param fcn binary 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 ) {
|
|
36
|
+
* double xre;
|
|
37
|
+
* double xim;
|
|
38
|
+
* double yre;
|
|
39
|
+
* double yim;
|
|
40
|
+
* double re;
|
|
41
|
+
* double im;
|
|
42
|
+
*
|
|
43
|
+
* stdlib_complex128_reim( x, &xre, &xim );
|
|
44
|
+
* stdlib_complex128_reim( y, &yre, &yim );
|
|
45
|
+
*
|
|
46
|
+
* re = xre + yre;
|
|
47
|
+
* im = xim + yim;
|
|
48
|
+
*
|
|
49
|
+
* return stdlib_complex128( re, im );
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* // ...
|
|
53
|
+
*
|
|
54
|
+
* // Register a Node-API module:
|
|
55
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( add );
|
|
56
|
+
*/
|
|
57
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_ZZ_Z( fcn ) \
|
|
58
|
+
static napi_value stdlib_math_base_napi_zz_z_wrapper( \
|
|
59
|
+
napi_env env, \
|
|
60
|
+
napi_callback_info info \
|
|
61
|
+
) { \
|
|
62
|
+
return stdlib_math_base_napi_zz_z( env, info, fcn ); \
|
|
63
|
+
}; \
|
|
64
|
+
static napi_value stdlib_math_base_napi_zz_z_init( \
|
|
65
|
+
napi_env env, \
|
|
66
|
+
napi_value exports \
|
|
67
|
+
) { \
|
|
68
|
+
napi_value f; \
|
|
69
|
+
napi_status status = napi_create_function( \
|
|
70
|
+
env, \
|
|
71
|
+
"exports", \
|
|
72
|
+
NAPI_AUTO_LENGTH, \
|
|
73
|
+
stdlib_math_base_napi_zz_z_wrapper, \
|
|
74
|
+
NULL, \
|
|
75
|
+
&f \
|
|
76
|
+
); \
|
|
77
|
+
assert( status == napi_ok ); \
|
|
78
|
+
return f; \
|
|
79
|
+
}; \
|
|
80
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_zz_z_init )
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
84
|
+
*/
|
|
85
|
+
#ifdef __cplusplus
|
|
86
|
+
extern "C" {
|
|
87
|
+
#endif
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Invokes a binary function accepting and returning double-precision complex floating-point numbers.
|
|
91
|
+
*/
|
|
92
|
+
napi_value stdlib_math_base_napi_zz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, stdlib_complex128_t ) );
|
|
93
|
+
|
|
94
|
+
#ifdef __cplusplus
|
|
95
|
+
}
|
|
96
|
+
#endif
|
|
97
|
+
|
|
98
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_ZZ_Z_H
|