@stdlib/math-base-napi-binary 0.2.1 → 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 +1155 -252
- 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 -531
- package/manifest.json +60 -40
- package/package.json +6 -6
- 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/include.gypi +0 -53
- package/src/main.c +0 -1063
package/src/zd_z.c
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
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
|
+
#include "stdlib/math/base/napi/binary/zd_z.h"
|
|
20
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
21
|
+
#include "stdlib/complex/float64/reim.h"
|
|
22
|
+
#include <node_api.h>
|
|
23
|
+
#include <assert.h>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 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.
|
|
27
|
+
*
|
|
28
|
+
* ## Notes
|
|
29
|
+
*
|
|
30
|
+
* - This function expects that the callback `info` argument provides access to the following JavaScript arguments:
|
|
31
|
+
*
|
|
32
|
+
* - `x`: input value.
|
|
33
|
+
* - `y`: input value.
|
|
34
|
+
*
|
|
35
|
+
* @param env environment under which the function is invoked
|
|
36
|
+
* @param info callback data
|
|
37
|
+
* @param fcn binary function
|
|
38
|
+
* @return function return value as a Node-API complex-like object
|
|
39
|
+
*/
|
|
40
|
+
napi_value stdlib_math_base_napi_zd_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, double ) ) {
|
|
41
|
+
napi_status status;
|
|
42
|
+
|
|
43
|
+
size_t argc = 2;
|
|
44
|
+
napi_value argv[ 2 ];
|
|
45
|
+
status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL );
|
|
46
|
+
assert( status == napi_ok );
|
|
47
|
+
|
|
48
|
+
if ( argc < 2 ) {
|
|
49
|
+
status = napi_throw_error( env, NULL, "invalid invocation. Must provide two arguments." );
|
|
50
|
+
assert( status == napi_ok );
|
|
51
|
+
return NULL;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
bool hprop;
|
|
55
|
+
status = napi_has_named_property( env, argv[ 0 ], "re", &hprop );
|
|
56
|
+
assert( status == napi_ok );
|
|
57
|
+
if ( !hprop ) {
|
|
58
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." );
|
|
59
|
+
assert( status == napi_ok );
|
|
60
|
+
return NULL;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
napi_value xre;
|
|
64
|
+
status = napi_get_named_property( env, argv[ 0 ], "re", &xre );
|
|
65
|
+
assert( status == napi_ok );
|
|
66
|
+
|
|
67
|
+
napi_valuetype xretype;
|
|
68
|
+
status = napi_typeof( env, xre, &xretype );
|
|
69
|
+
assert( status == napi_ok );
|
|
70
|
+
if ( xretype != napi_number ) {
|
|
71
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." );
|
|
72
|
+
assert( status == napi_ok );
|
|
73
|
+
return NULL;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
status = napi_has_named_property( env, argv[ 0 ], "im", &hprop );
|
|
77
|
+
assert( status == napi_ok );
|
|
78
|
+
if ( !hprop ) {
|
|
79
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." );
|
|
80
|
+
assert( status == napi_ok );
|
|
81
|
+
return NULL;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
napi_value xim;
|
|
85
|
+
status = napi_get_named_property( env, argv[ 0 ], "im", &xim );
|
|
86
|
+
assert( status == napi_ok );
|
|
87
|
+
|
|
88
|
+
napi_valuetype ximtype;
|
|
89
|
+
status = napi_typeof( env, xim, &ximtype );
|
|
90
|
+
assert( status == napi_ok );
|
|
91
|
+
if ( ximtype != napi_number ) {
|
|
92
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." );
|
|
93
|
+
assert( status == napi_ok );
|
|
94
|
+
return NULL;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
napi_valuetype vtype1;
|
|
98
|
+
status = napi_typeof( env, argv[ 1 ], &vtype1 );
|
|
99
|
+
assert( status == napi_ok );
|
|
100
|
+
if ( vtype1 != napi_number ) {
|
|
101
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." );
|
|
102
|
+
assert( status == napi_ok );
|
|
103
|
+
return NULL;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
double re0;
|
|
107
|
+
status = napi_get_value_double( env, xre, &re0 );
|
|
108
|
+
assert( status == napi_ok );
|
|
109
|
+
|
|
110
|
+
double im0;
|
|
111
|
+
status = napi_get_value_double( env, xim, &im0 );
|
|
112
|
+
assert( status == napi_ok );
|
|
113
|
+
|
|
114
|
+
double y;
|
|
115
|
+
status = napi_get_value_double( env, argv[ 1 ], &y );
|
|
116
|
+
assert( status == napi_ok );
|
|
117
|
+
|
|
118
|
+
stdlib_complex128_t v = fcn( stdlib_complex128( re0, im0 ), y );
|
|
119
|
+
double re;
|
|
120
|
+
double im;
|
|
121
|
+
stdlib_complex128_reim( v, &re, &im );
|
|
122
|
+
|
|
123
|
+
napi_value obj;
|
|
124
|
+
status = napi_create_object( env, &obj );
|
|
125
|
+
assert( status == napi_ok );
|
|
126
|
+
|
|
127
|
+
napi_value vre;
|
|
128
|
+
status = napi_create_double( env, re, &vre );
|
|
129
|
+
assert( status == napi_ok );
|
|
130
|
+
|
|
131
|
+
status = napi_set_named_property( env, obj, "re", vre );
|
|
132
|
+
assert( status == napi_ok );
|
|
133
|
+
|
|
134
|
+
napi_value vim;
|
|
135
|
+
status = napi_create_double( env, im, &vim );
|
|
136
|
+
assert( status == napi_ok );
|
|
137
|
+
|
|
138
|
+
status = napi_set_named_property( env, obj, "im", vim );
|
|
139
|
+
assert( status == napi_ok );
|
|
140
|
+
|
|
141
|
+
return obj;
|
|
142
|
+
}
|
package/src/zi_z.c
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
#include "stdlib/math/base/napi/binary/zi_z.h"
|
|
20
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
21
|
+
#include "stdlib/complex/float64/reim.h"
|
|
22
|
+
#include <node_api.h>
|
|
23
|
+
#include <stdint.h>
|
|
24
|
+
#include <assert.h>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 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.
|
|
28
|
+
*
|
|
29
|
+
* ## Notes
|
|
30
|
+
*
|
|
31
|
+
* - This function expects that the callback `info` argument provides access to the following JavaScript arguments:
|
|
32
|
+
*
|
|
33
|
+
* - `x`: input value.
|
|
34
|
+
* - `y`: input value.
|
|
35
|
+
*
|
|
36
|
+
* @param env environment under which the function is invoked
|
|
37
|
+
* @param info callback data
|
|
38
|
+
* @param fcn binary function
|
|
39
|
+
* @return function return value as a Node-API complex-like object
|
|
40
|
+
*/
|
|
41
|
+
napi_value stdlib_math_base_napi_zi_z( napi_env env, napi_callback_info info, stdlib_complex128_t (*fcn)( stdlib_complex128_t, int32_t ) ) {
|
|
42
|
+
napi_status status;
|
|
43
|
+
|
|
44
|
+
size_t argc = 2;
|
|
45
|
+
napi_value argv[ 2 ];
|
|
46
|
+
status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL );
|
|
47
|
+
assert( status == napi_ok );
|
|
48
|
+
|
|
49
|
+
if ( argc < 2 ) {
|
|
50
|
+
status = napi_throw_error( env, NULL, "invalid invocation. Must provide two arguments." );
|
|
51
|
+
assert( status == napi_ok );
|
|
52
|
+
return NULL;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
bool hprop;
|
|
56
|
+
status = napi_has_named_property( env, argv[ 0 ], "re", &hprop );
|
|
57
|
+
assert( status == napi_ok );
|
|
58
|
+
if ( !hprop ) {
|
|
59
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." );
|
|
60
|
+
assert( status == napi_ok );
|
|
61
|
+
return NULL;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
napi_value xre;
|
|
65
|
+
status = napi_get_named_property( env, argv[ 0 ], "re", &xre );
|
|
66
|
+
assert( status == napi_ok );
|
|
67
|
+
|
|
68
|
+
napi_valuetype xretype;
|
|
69
|
+
status = napi_typeof( env, xre, &xretype );
|
|
70
|
+
assert( status == napi_ok );
|
|
71
|
+
if ( xretype != napi_number ) {
|
|
72
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." );
|
|
73
|
+
assert( status == napi_ok );
|
|
74
|
+
return NULL;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
status = napi_has_named_property( env, argv[ 0 ], "im", &hprop );
|
|
78
|
+
assert( status == napi_ok );
|
|
79
|
+
if ( !hprop ) {
|
|
80
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." );
|
|
81
|
+
assert( status == napi_ok );
|
|
82
|
+
return NULL;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
napi_value xim;
|
|
86
|
+
status = napi_get_named_property( env, argv[ 0 ], "im", &xim );
|
|
87
|
+
assert( status == napi_ok );
|
|
88
|
+
|
|
89
|
+
napi_valuetype ximtype;
|
|
90
|
+
status = napi_typeof( env, xim, &ximtype );
|
|
91
|
+
assert( status == napi_ok );
|
|
92
|
+
if ( ximtype != napi_number ) {
|
|
93
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." );
|
|
94
|
+
assert( status == napi_ok );
|
|
95
|
+
return NULL;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
napi_valuetype vtype1;
|
|
99
|
+
status = napi_typeof( env, argv[ 1 ], &vtype1 );
|
|
100
|
+
assert( status == napi_ok );
|
|
101
|
+
if ( vtype1 != napi_number ) {
|
|
102
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must be a number." );
|
|
103
|
+
assert( status == napi_ok );
|
|
104
|
+
return NULL;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
double re0;
|
|
108
|
+
status = napi_get_value_double( env, xre, &re0 );
|
|
109
|
+
assert( status == napi_ok );
|
|
110
|
+
|
|
111
|
+
double im0;
|
|
112
|
+
status = napi_get_value_double( env, xim, &im0 );
|
|
113
|
+
assert( status == napi_ok );
|
|
114
|
+
|
|
115
|
+
int32_t y;
|
|
116
|
+
status = napi_get_value_int32( env, argv[ 1 ], &y );
|
|
117
|
+
assert( status == napi_ok );
|
|
118
|
+
|
|
119
|
+
stdlib_complex128_t v = fcn( stdlib_complex128( re0, im0 ), y );
|
|
120
|
+
double re;
|
|
121
|
+
double im;
|
|
122
|
+
stdlib_complex128_reim( v, &re, &im );
|
|
123
|
+
|
|
124
|
+
napi_value obj;
|
|
125
|
+
status = napi_create_object( env, &obj );
|
|
126
|
+
assert( status == napi_ok );
|
|
127
|
+
|
|
128
|
+
napi_value vre;
|
|
129
|
+
status = napi_create_double( env, re, &vre );
|
|
130
|
+
assert( status == napi_ok );
|
|
131
|
+
|
|
132
|
+
status = napi_set_named_property( env, obj, "re", vre );
|
|
133
|
+
assert( status == napi_ok );
|
|
134
|
+
|
|
135
|
+
napi_value vim;
|
|
136
|
+
status = napi_create_double( env, im, &vim );
|
|
137
|
+
assert( status == napi_ok );
|
|
138
|
+
|
|
139
|
+
status = napi_set_named_property( env, obj, "im", vim );
|
|
140
|
+
assert( status == napi_ok );
|
|
141
|
+
|
|
142
|
+
return obj;
|
|
143
|
+
}
|
package/src/zz_z.c
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
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
|
+
#include "stdlib/math/base/napi/binary/zz_z.h"
|
|
20
|
+
#include "stdlib/complex/float64/ctor.h"
|
|
21
|
+
#include "stdlib/complex/float64/reim.h"
|
|
22
|
+
#include <node_api.h>
|
|
23
|
+
#include <assert.h>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Invokes a binary function accepting and returning double-precision complex floating-point numbers.
|
|
27
|
+
*
|
|
28
|
+
* ## Notes
|
|
29
|
+
*
|
|
30
|
+
* - This function expects that the callback `info` argument provides access to the following JavaScript arguments:
|
|
31
|
+
*
|
|
32
|
+
* - `x`: input value.
|
|
33
|
+
* - `y`: input value.
|
|
34
|
+
*
|
|
35
|
+
* @param env environment under which the function is invoked
|
|
36
|
+
* @param info callback data
|
|
37
|
+
* @param fcn binary function
|
|
38
|
+
* @return function return value as a Node-API complex-like object
|
|
39
|
+
*/
|
|
40
|
+
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 ) ) {
|
|
41
|
+
napi_status status;
|
|
42
|
+
|
|
43
|
+
size_t argc = 2;
|
|
44
|
+
napi_value argv[ 2 ];
|
|
45
|
+
status = napi_get_cb_info( env, info, &argc, argv, NULL, NULL );
|
|
46
|
+
assert( status == napi_ok );
|
|
47
|
+
|
|
48
|
+
if ( argc < 2 ) {
|
|
49
|
+
status = napi_throw_error( env, NULL, "invalid invocation. Must provide two complex numbers." );
|
|
50
|
+
assert( status == napi_ok );
|
|
51
|
+
return NULL;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
bool hprop;
|
|
55
|
+
status = napi_has_named_property( env, argv[ 0 ], "re", &hprop );
|
|
56
|
+
assert( status == napi_ok );
|
|
57
|
+
if ( !hprop ) {
|
|
58
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component." );
|
|
59
|
+
assert( status == napi_ok );
|
|
60
|
+
return NULL;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
napi_value xre;
|
|
64
|
+
status = napi_get_named_property( env, argv[ 0 ], "re", &xre );
|
|
65
|
+
assert( status == napi_ok );
|
|
66
|
+
|
|
67
|
+
napi_valuetype xretype;
|
|
68
|
+
status = napi_typeof( env, xre, &xretype );
|
|
69
|
+
assert( status == napi_ok );
|
|
70
|
+
if ( xretype != napi_number ) {
|
|
71
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have a real component which is a number." );
|
|
72
|
+
assert( status == napi_ok );
|
|
73
|
+
return NULL;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
status = napi_has_named_property( env, argv[ 0 ], "im", &hprop );
|
|
77
|
+
assert( status == napi_ok );
|
|
78
|
+
if ( !hprop ) {
|
|
79
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component." );
|
|
80
|
+
assert( status == napi_ok );
|
|
81
|
+
return NULL;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
napi_value xim;
|
|
85
|
+
status = napi_get_named_property( env, argv[ 0 ], "im", &xim );
|
|
86
|
+
assert( status == napi_ok );
|
|
87
|
+
|
|
88
|
+
napi_valuetype ximtype;
|
|
89
|
+
status = napi_typeof( env, xim, &ximtype );
|
|
90
|
+
assert( status == napi_ok );
|
|
91
|
+
if ( ximtype != napi_number ) {
|
|
92
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. First argument must have an imaginary component which a number." );
|
|
93
|
+
assert( status == napi_ok );
|
|
94
|
+
return NULL;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
status = napi_has_named_property( env, argv[ 1 ], "re", &hprop );
|
|
98
|
+
assert( status == napi_ok );
|
|
99
|
+
if ( !hprop ) {
|
|
100
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component." );
|
|
101
|
+
assert( status == napi_ok );
|
|
102
|
+
return NULL;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
napi_value yre;
|
|
106
|
+
status = napi_get_named_property( env, argv[ 1 ], "re", &yre );
|
|
107
|
+
assert( status == napi_ok );
|
|
108
|
+
|
|
109
|
+
napi_valuetype yretype;
|
|
110
|
+
status = napi_typeof( env, yre, &yretype );
|
|
111
|
+
assert( status == napi_ok );
|
|
112
|
+
if ( yretype != napi_number ) {
|
|
113
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have a real component which is a number." );
|
|
114
|
+
assert( status == napi_ok );
|
|
115
|
+
return NULL;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
status = napi_has_named_property( env, argv[ 1 ], "im", &hprop );
|
|
119
|
+
assert( status == napi_ok );
|
|
120
|
+
if ( !hprop ) {
|
|
121
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component." );
|
|
122
|
+
assert( status == napi_ok );
|
|
123
|
+
return NULL;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
napi_value yim;
|
|
127
|
+
status = napi_get_named_property( env, argv[ 1 ], "im", &yim );
|
|
128
|
+
assert( status == napi_ok );
|
|
129
|
+
|
|
130
|
+
napi_valuetype yimtype;
|
|
131
|
+
status = napi_typeof( env, yim, &yimtype );
|
|
132
|
+
assert( status == napi_ok );
|
|
133
|
+
if ( yimtype != napi_number ) {
|
|
134
|
+
status = napi_throw_type_error( env, NULL, "invalid argument. Second argument must have an imaginary component which a number." );
|
|
135
|
+
assert( status == napi_ok );
|
|
136
|
+
return NULL;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
double re0;
|
|
140
|
+
status = napi_get_value_double( env, xre, &re0 );
|
|
141
|
+
assert( status == napi_ok );
|
|
142
|
+
|
|
143
|
+
double im0;
|
|
144
|
+
status = napi_get_value_double( env, xim, &im0 );
|
|
145
|
+
assert( status == napi_ok );
|
|
146
|
+
|
|
147
|
+
double re1;
|
|
148
|
+
status = napi_get_value_double( env, yre, &re1 );
|
|
149
|
+
assert( status == napi_ok );
|
|
150
|
+
|
|
151
|
+
double im1;
|
|
152
|
+
status = napi_get_value_double( env, yim, &im1 );
|
|
153
|
+
assert( status == napi_ok );
|
|
154
|
+
|
|
155
|
+
stdlib_complex128_t v = fcn( stdlib_complex128( re0, im0 ), stdlib_complex128( re1, im1 ) );
|
|
156
|
+
double re;
|
|
157
|
+
double im;
|
|
158
|
+
stdlib_complex128_reim( v, &re, &im );
|
|
159
|
+
|
|
160
|
+
napi_value obj;
|
|
161
|
+
status = napi_create_object( env, &obj );
|
|
162
|
+
assert( status == napi_ok );
|
|
163
|
+
|
|
164
|
+
napi_value vre;
|
|
165
|
+
status = napi_create_double( env, re, &vre );
|
|
166
|
+
assert( status == napi_ok );
|
|
167
|
+
|
|
168
|
+
status = napi_set_named_property( env, obj, "re", vre );
|
|
169
|
+
assert( status == napi_ok );
|
|
170
|
+
|
|
171
|
+
napi_value vim;
|
|
172
|
+
status = napi_create_double( env, im, &vim );
|
|
173
|
+
assert( status == napi_ok );
|
|
174
|
+
|
|
175
|
+
status = napi_set_named_property( env, obj, "im", vim );
|
|
176
|
+
assert( status == napi_ok );
|
|
177
|
+
|
|
178
|
+
return obj;
|
|
179
|
+
}
|
package/include.gypi
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# @license Apache-2.0
|
|
2
|
-
#
|
|
3
|
-
# Copyright (c) 2020 The Stdlib Authors.
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
# you may not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
#
|
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
#
|
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
-
# See the License for the specific language governing permissions and
|
|
15
|
-
# limitations under the License.
|
|
16
|
-
|
|
17
|
-
# A GYP include file for building a Node.js native add-on.
|
|
18
|
-
#
|
|
19
|
-
# Main documentation:
|
|
20
|
-
#
|
|
21
|
-
# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md
|
|
22
|
-
# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md
|
|
23
|
-
{
|
|
24
|
-
# Define variables to be used throughout the configuration for all targets:
|
|
25
|
-
'variables': {
|
|
26
|
-
# Source directory:
|
|
27
|
-
'src_dir': './src',
|
|
28
|
-
|
|
29
|
-
# Include directories:
|
|
30
|
-
'include_dirs': [
|
|
31
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).include; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
32
|
-
],
|
|
33
|
-
|
|
34
|
-
# Add-on destination directory:
|
|
35
|
-
'addon_output_dir': './src',
|
|
36
|
-
|
|
37
|
-
# Source files:
|
|
38
|
-
'src_files': [
|
|
39
|
-
'<(src_dir)/addon.c',
|
|
40
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).src; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
41
|
-
],
|
|
42
|
-
|
|
43
|
-
# Library dependencies:
|
|
44
|
-
'libraries': [
|
|
45
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libraries; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
46
|
-
],
|
|
47
|
-
|
|
48
|
-
# Library directories:
|
|
49
|
-
'library_dirs': [
|
|
50
|
-
'<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libpath; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
|
|
51
|
-
],
|
|
52
|
-
}, # end variables
|
|
53
|
-
}
|