@stdlib/math-base-napi-binary 0.3.0 → 0.3.1
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 +1 -1
- 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) 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_BB_B_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_BB_B_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 8-bit integers.
|
|
28
|
+
*
|
|
29
|
+
* @param fcn binary function
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* #include <stdint.h>
|
|
33
|
+
*
|
|
34
|
+
* static uint8_t add( const uint8_t x, const uint8_t y ) {
|
|
35
|
+
* return x + y;
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* // ...
|
|
39
|
+
*
|
|
40
|
+
* // Register a Node-API module:
|
|
41
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_BB_B( add );
|
|
42
|
+
*/
|
|
43
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_BB_B( fcn ) \
|
|
44
|
+
static napi_value stdlib_math_base_napi_bb_b_wrapper( \
|
|
45
|
+
napi_env env, \
|
|
46
|
+
napi_callback_info info \
|
|
47
|
+
) { \
|
|
48
|
+
return stdlib_math_base_napi_bb_b( env, info, fcn ); \
|
|
49
|
+
}; \
|
|
50
|
+
static napi_value stdlib_math_base_napi_bb_b_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_bb_b_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_bb_b_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 8-bit integers.
|
|
77
|
+
*/
|
|
78
|
+
napi_value stdlib_math_base_napi_bb_b( napi_env env, napi_callback_info info, uint8_t (*fcn)( uint8_t, uint8_t ) );
|
|
79
|
+
|
|
80
|
+
#ifdef __cplusplus
|
|
81
|
+
}
|
|
82
|
+
#endif
|
|
83
|
+
|
|
84
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_BB_B_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_CC_C_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_CC_C_H
|
|
21
|
+
|
|
22
|
+
#include "stdlib/complex/float32/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 single-precision complex floating-point numbers.
|
|
28
|
+
*
|
|
29
|
+
* @param fcn binary function
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* #include "stdlib/complex/float32/ctor.h"
|
|
33
|
+
* #include "stdlib/complex/float32/reim.h"
|
|
34
|
+
*
|
|
35
|
+
* static stdlib_complex64_t add( const stdlib_complex64_t x, const stdlib_complex64_t y ) {
|
|
36
|
+
* float xre;
|
|
37
|
+
* float xim;
|
|
38
|
+
* float yre;
|
|
39
|
+
* float yim;
|
|
40
|
+
* float re;
|
|
41
|
+
* float im;
|
|
42
|
+
*
|
|
43
|
+
* stdlib_complex64_reim( x, &xre, &xim );
|
|
44
|
+
* stdlib_complex64_reim( y, &yre, &yim );
|
|
45
|
+
*
|
|
46
|
+
* re = xre + yre;
|
|
47
|
+
* im = xim + yim;
|
|
48
|
+
*
|
|
49
|
+
* return stdlib_complex64( re, im );
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* // ...
|
|
53
|
+
*
|
|
54
|
+
* // Register a Node-API module:
|
|
55
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_CC_C( add );
|
|
56
|
+
*/
|
|
57
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_CC_C( fcn ) \
|
|
58
|
+
static napi_value stdlib_math_base_napi_cc_c_wrapper( \
|
|
59
|
+
napi_env env, \
|
|
60
|
+
napi_callback_info info \
|
|
61
|
+
) { \
|
|
62
|
+
return stdlib_math_base_napi_cc_c( env, info, fcn ); \
|
|
63
|
+
}; \
|
|
64
|
+
static napi_value stdlib_math_base_napi_cc_c_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_cc_c_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_cc_c_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 single-precision complex floating-point numbers.
|
|
91
|
+
*/
|
|
92
|
+
napi_value stdlib_math_base_napi_cc_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, stdlib_complex64_t ) );
|
|
93
|
+
|
|
94
|
+
#ifdef __cplusplus
|
|
95
|
+
}
|
|
96
|
+
#endif
|
|
97
|
+
|
|
98
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_CC_C_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_CF_C_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_CF_C_H
|
|
21
|
+
|
|
22
|
+
#include "stdlib/complex/float32/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 single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number.
|
|
28
|
+
*
|
|
29
|
+
* @param fcn binary function
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* #include "stdlib/complex/float32/ctor.h"
|
|
33
|
+
* #include "stdlib/complex/float32/reim.h"
|
|
34
|
+
*
|
|
35
|
+
* static stdlib_complex64_t mul( const stdlib_complex64_t x, const float n ) {
|
|
36
|
+
* float re;
|
|
37
|
+
* float im;
|
|
38
|
+
*
|
|
39
|
+
* stdlib_complex64_reim( x, &re, &im );
|
|
40
|
+
* return stdlib_complex64( re*n, im*n );
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* // ...
|
|
44
|
+
*
|
|
45
|
+
* // Register a Node-API module:
|
|
46
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_CF_C( mul );
|
|
47
|
+
*/
|
|
48
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_CF_C( fcn ) \
|
|
49
|
+
static napi_value stdlib_math_base_napi_cf_c_wrapper( \
|
|
50
|
+
napi_env env, \
|
|
51
|
+
napi_callback_info info \
|
|
52
|
+
) { \
|
|
53
|
+
return stdlib_math_base_napi_cf_c( env, info, fcn ); \
|
|
54
|
+
}; \
|
|
55
|
+
static napi_value stdlib_math_base_napi_cf_c_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_cf_c_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_cf_c_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 single-precision complex floating-point number and a single-precision floating-point number and returning a single-precision complex floating-point number.
|
|
82
|
+
*/
|
|
83
|
+
napi_value stdlib_math_base_napi_cf_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, float ) );
|
|
84
|
+
|
|
85
|
+
#ifdef __cplusplus
|
|
86
|
+
}
|
|
87
|
+
#endif
|
|
88
|
+
|
|
89
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_CF_C_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_CI_C_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_CI_C_H
|
|
21
|
+
|
|
22
|
+
#include "stdlib/complex/float32/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 single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number.
|
|
29
|
+
*
|
|
30
|
+
* @param fcn binary function
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* #include "stdlib/complex/float32/ctor.h"
|
|
34
|
+
* #include "stdlib/complex/float32/reim.h"
|
|
35
|
+
* #include <stdint.h>
|
|
36
|
+
*
|
|
37
|
+
* static stdlib_complex64_t mul( const stdlib_complex64_t x, const int32_t n ) {
|
|
38
|
+
* float re;
|
|
39
|
+
* float im;
|
|
40
|
+
*
|
|
41
|
+
* stdlib_complex64_reim( x, &re, &im );
|
|
42
|
+
* return stdlib_complex64( re*n, im*n );
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* // ...
|
|
46
|
+
*
|
|
47
|
+
* // Register a Node-API module:
|
|
48
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_CI_C( mul );
|
|
49
|
+
*/
|
|
50
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_CI_C( fcn ) \
|
|
51
|
+
static napi_value stdlib_math_base_napi_ci_c_wrapper( \
|
|
52
|
+
napi_env env, \
|
|
53
|
+
napi_callback_info info \
|
|
54
|
+
) { \
|
|
55
|
+
return stdlib_math_base_napi_ci_c( env, info, fcn ); \
|
|
56
|
+
}; \
|
|
57
|
+
static napi_value stdlib_math_base_napi_ci_c_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_ci_c_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_ci_c_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 single-precision complex floating-point number and a signed 32-bit integer and returning a single-precision complex floating-point number.
|
|
84
|
+
*/
|
|
85
|
+
napi_value stdlib_math_base_napi_ci_c( napi_env env, napi_callback_info info, stdlib_complex64_t (*fcn)( stdlib_complex64_t, int32_t ) );
|
|
86
|
+
|
|
87
|
+
#ifdef __cplusplus
|
|
88
|
+
}
|
|
89
|
+
#endif
|
|
90
|
+
|
|
91
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_CI_C_H
|
|
@@ -0,0 +1,81 @@
|
|
|
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_DD_D_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_DD_D_H
|
|
21
|
+
|
|
22
|
+
#include <node_api.h>
|
|
23
|
+
#include <assert.h>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Macro for registering a Node-API module exporting an interface invoking a binary function accepting and returning double-precision floating-point numbers.
|
|
27
|
+
*
|
|
28
|
+
* @param fcn binary function
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* static double add( const double x, const double y ) {
|
|
32
|
+
* return x + y;
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* // ...
|
|
36
|
+
*
|
|
37
|
+
* // Register a Node-API module:
|
|
38
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_DD_D( add );
|
|
39
|
+
*/
|
|
40
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_DD_D( fcn ) \
|
|
41
|
+
static napi_value stdlib_math_base_napi_dd_d_wrapper( \
|
|
42
|
+
napi_env env, \
|
|
43
|
+
napi_callback_info info \
|
|
44
|
+
) { \
|
|
45
|
+
return stdlib_math_base_napi_dd_d( env, info, fcn ); \
|
|
46
|
+
}; \
|
|
47
|
+
static napi_value stdlib_math_base_napi_dd_d_init( \
|
|
48
|
+
napi_env env, \
|
|
49
|
+
napi_value exports \
|
|
50
|
+
) { \
|
|
51
|
+
napi_value f; \
|
|
52
|
+
napi_status status = napi_create_function( \
|
|
53
|
+
env, \
|
|
54
|
+
"exports", \
|
|
55
|
+
NAPI_AUTO_LENGTH, \
|
|
56
|
+
stdlib_math_base_napi_dd_d_wrapper, \
|
|
57
|
+
NULL, \
|
|
58
|
+
&f \
|
|
59
|
+
); \
|
|
60
|
+
assert( status == napi_ok ); \
|
|
61
|
+
return f; \
|
|
62
|
+
}; \
|
|
63
|
+
NAPI_MODULE( NODE_GYP_MODULE_NAME, stdlib_math_base_napi_dd_d_init )
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
|
|
67
|
+
*/
|
|
68
|
+
#ifdef __cplusplus
|
|
69
|
+
extern "C" {
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Invokes a binary function accepting and returning double-precision floating-point numbers.
|
|
74
|
+
*/
|
|
75
|
+
napi_value stdlib_math_base_napi_dd_d( napi_env env, napi_callback_info info, double (*fcn)( double, double ) );
|
|
76
|
+
|
|
77
|
+
#ifdef __cplusplus
|
|
78
|
+
}
|
|
79
|
+
#endif
|
|
80
|
+
|
|
81
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_DD_D_H
|
|
@@ -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_DI_D_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_DI_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 a double-precision floating-point number and a signed 32-bit integer 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 mul( const double x, const int32_t n ) {
|
|
35
|
+
* return x * n;
|
|
36
|
+
* }
|
|
37
|
+
*
|
|
38
|
+
* // ...
|
|
39
|
+
*
|
|
40
|
+
* // Register a Node-API module:
|
|
41
|
+
* STDLIB_MATH_BASE_NAPI_MODULE_DI_D( mul );
|
|
42
|
+
*/
|
|
43
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_DI_D( fcn ) \
|
|
44
|
+
static napi_value stdlib_math_base_napi_di_d_wrapper( \
|
|
45
|
+
napi_env env, \
|
|
46
|
+
napi_callback_info info \
|
|
47
|
+
) { \
|
|
48
|
+
return stdlib_math_base_napi_di_d( env, info, fcn ); \
|
|
49
|
+
}; \
|
|
50
|
+
static napi_value stdlib_math_base_napi_di_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_di_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_di_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 a double-precision floating-point number and a signed 32-bit integer and returning a double-precision floating-point number.
|
|
77
|
+
*/
|
|
78
|
+
napi_value stdlib_math_base_napi_di_d( napi_env env, napi_callback_info info, double (*fcn)( double, int32_t ) );
|
|
79
|
+
|
|
80
|
+
#ifdef __cplusplus
|
|
81
|
+
}
|
|
82
|
+
#endif
|
|
83
|
+
|
|
84
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_DI_D_H
|
|
@@ -0,0 +1,89 @@
|
|
|
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_DZ_Z_H
|
|
20
|
+
#define STDLIB_MATH_BASE_NAPI_BINARY_DZ_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 floating-point number and a double-precision complex 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 double n, const stdlib_complex128_t x ) {
|
|
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_DZ_Z( mul );
|
|
47
|
+
*/
|
|
48
|
+
#define STDLIB_MATH_BASE_NAPI_MODULE_DZ_Z( fcn ) \
|
|
49
|
+
static napi_value stdlib_math_base_napi_dz_z_wrapper( \
|
|
50
|
+
napi_env env, \
|
|
51
|
+
napi_callback_info info \
|
|
52
|
+
) { \
|
|
53
|
+
return stdlib_math_base_napi_dz_z( env, info, fcn ); \
|
|
54
|
+
}; \
|
|
55
|
+
static napi_value stdlib_math_base_napi_dz_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_dz_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_dz_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 floating-point number and a double-precision complex floating-point number and returning a double-precision complex floating-point number.
|
|
82
|
+
*/
|
|
83
|
+
napi_value stdlib_math_base_napi_dz_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( double, stdlib_complex128_t ) );
|
|
84
|
+
|
|
85
|
+
#ifdef __cplusplus
|
|
86
|
+
}
|
|
87
|
+
#endif
|
|
88
|
+
|
|
89
|
+
#endif // !STDLIB_MATH_BASE_NAPI_BINARY_DZ_Z_H
|