@stdlib/blas-base-ccopy 0.0.7 → 0.1.0
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/CITATION.cff +30 -0
- package/NOTICE +1 -1
- package/README.md +28 -23
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +10 -10
- package/include.gypi +1 -1
- package/lib/ccopy.js +6 -6
- package/lib/ccopy.native.js +6 -6
- package/lib/index.js +2 -0
- package/lib/ndarray.js +6 -6
- package/lib/ndarray.native.js +12 -12
- package/manifest.json +146 -116
- package/package.json +28 -18
- package/src/addon.c +45 -0
- package/src/ccopy.c +2 -2
- package/src/ccopy.f +2 -2
- package/src/ccopy_cblas.c +2 -2
- package/src/ccopy_f.c +2 -2
- package/docs/repl.txt +0 -135
- package/docs/types/test.ts +0 -249
- package/src/addon.cpp +0 -151
package/docs/types/test.ts
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
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
|
-
import Complex64Array = require( '@stdlib/array-complex64' );
|
|
20
|
-
import ccopy = require( './index' );
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// TESTS //
|
|
24
|
-
|
|
25
|
-
// The function returns a Complex64Array...
|
|
26
|
-
{
|
|
27
|
-
const x = new Complex64Array( 10 );
|
|
28
|
-
const y = new Complex64Array( 10 );
|
|
29
|
-
|
|
30
|
-
ccopy( x.length, x, 1, y, 1 ); // $ExpectType Complex64Array
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// The compiler throws an error if the function is provided a first argument which is not a number...
|
|
34
|
-
{
|
|
35
|
-
const x = new Complex64Array( 10 );
|
|
36
|
-
const y = new Complex64Array( 10 );
|
|
37
|
-
|
|
38
|
-
ccopy( '10', x, 1, y, 1 ); // $ExpectError
|
|
39
|
-
ccopy( true, x, 1, y, 1 ); // $ExpectError
|
|
40
|
-
ccopy( false, x, 1, y, 1 ); // $ExpectError
|
|
41
|
-
ccopy( null, x, 1, y, 1 ); // $ExpectError
|
|
42
|
-
ccopy( undefined, x, 1, y, 1 ); // $ExpectError
|
|
43
|
-
ccopy( [], x, 1, y, 1 ); // $ExpectError
|
|
44
|
-
ccopy( {}, x, 1, y, 1 ); // $ExpectError
|
|
45
|
-
ccopy( ( x: number ): number => x, x, 1, y, 1 ); // $ExpectError
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// The compiler throws an error if the function is provided a second argument which is not a Complex64Array...
|
|
49
|
-
{
|
|
50
|
-
const x = new Complex64Array( 10 );
|
|
51
|
-
const y = new Complex64Array( 10 );
|
|
52
|
-
|
|
53
|
-
ccopy( x.length, 10, 1, y, 1 ); // $ExpectError
|
|
54
|
-
ccopy( x.length, '10', 1, y, 1 ); // $ExpectError
|
|
55
|
-
ccopy( x.length, true, 1, y, 1 ); // $ExpectError
|
|
56
|
-
ccopy( x.length, false, 1, y, 1 ); // $ExpectError
|
|
57
|
-
ccopy( x.length, null, 1, y, 1 ); // $ExpectError
|
|
58
|
-
ccopy( x.length, undefined, 1, y, 1 ); // $ExpectError
|
|
59
|
-
ccopy( x.length, [ '1' ], 1, y, 1 ); // $ExpectError
|
|
60
|
-
ccopy( x.length, {}, 1, y, 1 ); // $ExpectError
|
|
61
|
-
ccopy( x.length, ( x: number ): number => x, 1, y, 1 ); // $ExpectError
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// The compiler throws an error if the function is provided a third argument which is not a number...
|
|
65
|
-
{
|
|
66
|
-
const x = new Complex64Array( 10 );
|
|
67
|
-
const y = new Complex64Array( 10 );
|
|
68
|
-
|
|
69
|
-
ccopy( x.length, x, '10', y, 1 ); // $ExpectError
|
|
70
|
-
ccopy( x.length, x, true, y, 1 ); // $ExpectError
|
|
71
|
-
ccopy( x.length, x, false, y, 1 ); // $ExpectError
|
|
72
|
-
ccopy( x.length, x, null, y, 1 ); // $ExpectError
|
|
73
|
-
ccopy( x.length, x, undefined, y, 1 ); // $ExpectError
|
|
74
|
-
ccopy( x.length, x, [], y, 1 ); // $ExpectError
|
|
75
|
-
ccopy( x.length, x, {}, y, 1 ); // $ExpectError
|
|
76
|
-
ccopy( x.length, x, ( x: number ): number => x, y, 1 ); // $ExpectError
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// The compiler throws an error if the function is provided a fourth argument which is not a Complex64Array...
|
|
80
|
-
{
|
|
81
|
-
const x = new Complex64Array( 10 );
|
|
82
|
-
|
|
83
|
-
ccopy( x.length, x, 1, 10, 1 ); // $ExpectError
|
|
84
|
-
ccopy( x.length, x, 1, '10', 1 ); // $ExpectError
|
|
85
|
-
ccopy( x.length, x, 1, true, 1 ); // $ExpectError
|
|
86
|
-
ccopy( x.length, x, 1, false, 1 ); // $ExpectError
|
|
87
|
-
ccopy( x.length, x, 1, null, 1 ); // $ExpectError
|
|
88
|
-
ccopy( x.length, x, 1, undefined, 1 ); // $ExpectError
|
|
89
|
-
ccopy( x.length, x, 1, [ '1' ], 1 ); // $ExpectError
|
|
90
|
-
ccopy( x.length, x, 1, {}, 1 ); // $ExpectError
|
|
91
|
-
ccopy( x.length, x, 1, ( x: number ): number => x, 1 ); // $ExpectError
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// The compiler throws an error if the function is provided a fifth argument which is not a number...
|
|
95
|
-
{
|
|
96
|
-
const x = new Complex64Array( 10 );
|
|
97
|
-
const y = new Complex64Array( 10 );
|
|
98
|
-
|
|
99
|
-
ccopy( x.length, x, 1, y, '10' ); // $ExpectError
|
|
100
|
-
ccopy( x.length, x, 1, y, true ); // $ExpectError
|
|
101
|
-
ccopy( x.length, x, 1, y, false ); // $ExpectError
|
|
102
|
-
ccopy( x.length, x, 1, y, null ); // $ExpectError
|
|
103
|
-
ccopy( x.length, x, 1, y, undefined ); // $ExpectError
|
|
104
|
-
ccopy( x.length, x, 1, y, [] ); // $ExpectError
|
|
105
|
-
ccopy( x.length, x, 1, y, {} ); // $ExpectError
|
|
106
|
-
ccopy( x.length, x, 1, y, ( x: number ): number => x ); // $ExpectError
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// The compiler throws an error if the function is provided an unsupported number of arguments...
|
|
110
|
-
{
|
|
111
|
-
const x = new Complex64Array( 10 );
|
|
112
|
-
const y = new Complex64Array( 10 );
|
|
113
|
-
|
|
114
|
-
ccopy(); // $ExpectError
|
|
115
|
-
ccopy( x.length ); // $ExpectError
|
|
116
|
-
ccopy( x.length, x ); // $ExpectError
|
|
117
|
-
ccopy( x.length, x, 1 ); // $ExpectError
|
|
118
|
-
ccopy( x.length, x, 1, y ); // $ExpectError
|
|
119
|
-
ccopy( x.length, x, 1, y, 1, 10 ); // $ExpectError
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Attached to main export is an `ndarray` method which returns a Complex64Array...
|
|
123
|
-
{
|
|
124
|
-
const x = new Complex64Array( 10 );
|
|
125
|
-
const y = new Complex64Array( 10 );
|
|
126
|
-
|
|
127
|
-
ccopy.ndarray( x.length, x, 1, 0, y, 1, 0 ); // $ExpectType Complex64Array
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...
|
|
131
|
-
{
|
|
132
|
-
const x = new Complex64Array( 10 );
|
|
133
|
-
const y = new Complex64Array( 10 );
|
|
134
|
-
|
|
135
|
-
ccopy.ndarray( '10', x, 1, 0, y, 1, 0 ); // $ExpectError
|
|
136
|
-
ccopy.ndarray( true, x, 1, 0, y, 1, 0 ); // $ExpectError
|
|
137
|
-
ccopy.ndarray( false, x, 1, 0, y, 1, 0 ); // $ExpectError
|
|
138
|
-
ccopy.ndarray( null, x, 1, 0, y, 1, 0 ); // $ExpectError
|
|
139
|
-
ccopy.ndarray( undefined, x, 1, 0, y, 1, 0 ); // $ExpectError
|
|
140
|
-
ccopy.ndarray( [], x, 1, 0, y, 1, 0 ); // $ExpectError
|
|
141
|
-
ccopy.ndarray( {}, x, 1, 0, y, 1, 0 ); // $ExpectError
|
|
142
|
-
ccopy.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0 ); // $ExpectError
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// The compiler throws an error if the `ndarray` method is provided a second argument which is not a Complex64Array...
|
|
146
|
-
{
|
|
147
|
-
const x = new Complex64Array( 10 );
|
|
148
|
-
const y = new Complex64Array( 10 );
|
|
149
|
-
|
|
150
|
-
ccopy.ndarray( x.length, 10, 1, 0, y, 1, 0 ); // $ExpectError
|
|
151
|
-
ccopy.ndarray( x.length, '10', 1, 0, y, 1, 0 ); // $ExpectError
|
|
152
|
-
ccopy.ndarray( x.length, true, 1, 0, y, 1, 0 ); // $ExpectError
|
|
153
|
-
ccopy.ndarray( x.length, false, 1, 0, y, 1, 0 ); // $ExpectError
|
|
154
|
-
ccopy.ndarray( x.length, null, 1, 0, y, 1, 0 ); // $ExpectError
|
|
155
|
-
ccopy.ndarray( x.length, undefined, 1, 0, y, 1, 0 ); // $ExpectError
|
|
156
|
-
ccopy.ndarray( x.length, [ '1' ], 1, 0, y, 1, 0 ); // $ExpectError
|
|
157
|
-
ccopy.ndarray( x.length, {}, 1, 0, y, 1, 0 ); // $ExpectError
|
|
158
|
-
ccopy.ndarray( x.length, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number...
|
|
162
|
-
{
|
|
163
|
-
const x = new Complex64Array( 10 );
|
|
164
|
-
const y = new Complex64Array( 10 );
|
|
165
|
-
|
|
166
|
-
ccopy.ndarray( x.length, x, '10', 0, y, 1, 0 ); // $ExpectError
|
|
167
|
-
ccopy.ndarray( x.length, x, true, 0, y, 1, 0 ); // $ExpectError
|
|
168
|
-
ccopy.ndarray( x.length, x, false, 0, y, 1, 0 ); // $ExpectError
|
|
169
|
-
ccopy.ndarray( x.length, x, null, 0, y, 1, 0 ); // $ExpectError
|
|
170
|
-
ccopy.ndarray( x.length, x, undefined, 0, y, 1, 0 ); // $ExpectError
|
|
171
|
-
ccopy.ndarray( x.length, x, [], 0, y, 1, 0 ); // $ExpectError
|
|
172
|
-
ccopy.ndarray( x.length, x, {}, 0, y, 1, 0 ); // $ExpectError
|
|
173
|
-
ccopy.ndarray( x.length, x, ( x: number ): number => x, 0, y, 1, 0 ); // $ExpectError
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number...
|
|
177
|
-
{
|
|
178
|
-
const x = new Complex64Array( 10 );
|
|
179
|
-
const y = new Complex64Array( 10 );
|
|
180
|
-
|
|
181
|
-
ccopy.ndarray( x.length, x, 1, '10', y, 1, 0 ); // $ExpectError
|
|
182
|
-
ccopy.ndarray( x.length, x, 1, true, y, 1, 0 ); // $ExpectError
|
|
183
|
-
ccopy.ndarray( x.length, x, 1, false, y, 1, 0 ); // $ExpectError
|
|
184
|
-
ccopy.ndarray( x.length, x, 1, null, y, 1, 0 ); // $ExpectError
|
|
185
|
-
ccopy.ndarray( x.length, x, 1, undefined, y, 1, 0 ); // $ExpectError
|
|
186
|
-
ccopy.ndarray( x.length, x, 1, [], y, 1, 0 ); // $ExpectError
|
|
187
|
-
ccopy.ndarray( x.length, x, 1, {}, y, 1, 0 ); // $ExpectError
|
|
188
|
-
ccopy.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Complex64Array...
|
|
192
|
-
{
|
|
193
|
-
const x = new Complex64Array( 10 );
|
|
194
|
-
|
|
195
|
-
ccopy.ndarray( x.length, x, 1, 0, 10, 1, 0 ); // $ExpectError
|
|
196
|
-
ccopy.ndarray( x.length, x, 1, 0, '10', 1, 0 ); // $ExpectError
|
|
197
|
-
ccopy.ndarray( x.length, x, 1, 0, true, 1, 0 ); // $ExpectError
|
|
198
|
-
ccopy.ndarray( x.length, x, 1, 0, false, 1, 0 ); // $ExpectError
|
|
199
|
-
ccopy.ndarray( x.length, x, 1, 0, null, 1, 0 ); // $ExpectError
|
|
200
|
-
ccopy.ndarray( x.length, x, 1, 0, undefined, 1, 0 ); // $ExpectError
|
|
201
|
-
ccopy.ndarray( x.length, x, 1, 0, [ '1' ], 1, 0 ); // $ExpectError
|
|
202
|
-
ccopy.ndarray( x.length, x, 1, 0, {}, 1, 0 ); // $ExpectError
|
|
203
|
-
ccopy.ndarray( x.length, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number...
|
|
207
|
-
{
|
|
208
|
-
const x = new Complex64Array( 10 );
|
|
209
|
-
const y = new Complex64Array( 10 );
|
|
210
|
-
|
|
211
|
-
ccopy.ndarray( x.length, x, 1, 0, y, '10', 0 ); // $ExpectError
|
|
212
|
-
ccopy.ndarray( x.length, x, 1, 0, y, true, 0 ); // $ExpectError
|
|
213
|
-
ccopy.ndarray( x.length, x, 1, 0, y, false, 0 ); // $ExpectError
|
|
214
|
-
ccopy.ndarray( x.length, x, 1, 0, y, null, 0 ); // $ExpectError
|
|
215
|
-
ccopy.ndarray( x.length, x, 1, 0, y, undefined, 0 ); // $ExpectError
|
|
216
|
-
ccopy.ndarray( x.length, x, 1, 0, y, [], 0 ); // $ExpectError
|
|
217
|
-
ccopy.ndarray( x.length, x, 1, 0, y, {}, 0 ); // $ExpectError
|
|
218
|
-
ccopy.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number...
|
|
222
|
-
{
|
|
223
|
-
const x = new Complex64Array( 10 );
|
|
224
|
-
const y = new Complex64Array( 10 );
|
|
225
|
-
|
|
226
|
-
ccopy.ndarray( x.length, x, 1, 0, y, 1, '10' ); // $ExpectError
|
|
227
|
-
ccopy.ndarray( x.length, x, 1, 0, y, 1, true ); // $ExpectError
|
|
228
|
-
ccopy.ndarray( x.length, x, 1, 0, y, 1, false ); // $ExpectError
|
|
229
|
-
ccopy.ndarray( x.length, x, 1, 0, y, 1, null ); // $ExpectError
|
|
230
|
-
ccopy.ndarray( x.length, x, 1, 0, y, 1, undefined ); // $ExpectError
|
|
231
|
-
ccopy.ndarray( x.length, x, 1, 0, y, 1, [] ); // $ExpectError
|
|
232
|
-
ccopy.ndarray( x.length, x, 1, 0, y, 1, {} ); // $ExpectError
|
|
233
|
-
ccopy.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x ); // $ExpectError
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments...
|
|
237
|
-
{
|
|
238
|
-
const x = new Complex64Array( 10 );
|
|
239
|
-
const y = new Complex64Array( 10 );
|
|
240
|
-
|
|
241
|
-
ccopy.ndarray(); // $ExpectError
|
|
242
|
-
ccopy.ndarray( x.length ); // $ExpectError
|
|
243
|
-
ccopy.ndarray( x.length, x ); // $ExpectError
|
|
244
|
-
ccopy.ndarray( x.length, x, 1 ); // $ExpectError
|
|
245
|
-
ccopy.ndarray( x.length, x, 1, 0 ); // $ExpectError
|
|
246
|
-
ccopy.ndarray( x.length, x, 1, 0, y ); // $ExpectError
|
|
247
|
-
ccopy.ndarray( x.length, x, 1, 0, y, 1 ); // $ExpectError
|
|
248
|
-
ccopy.ndarray( x.length, x, 1, 0, y, 1, 0, 10 ); // $ExpectError
|
|
249
|
-
}
|
package/src/addon.cpp
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
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/blas/base/ccopy.h"
|
|
20
|
-
#include <node_api.h>
|
|
21
|
-
#include <stdint.h>
|
|
22
|
-
#include <stdlib.h>
|
|
23
|
-
#include <stdbool.h>
|
|
24
|
-
#include <assert.h>
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Add-on namespace.
|
|
28
|
-
*/
|
|
29
|
-
namespace stdlib_blas_base_ccopy {
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Copies values from one complex single-precision floating-point vector to another complex single-precision floating-point vector.
|
|
33
|
-
*
|
|
34
|
-
* ## Notes
|
|
35
|
-
*
|
|
36
|
-
* - When called from JavaScript, the function expects five arguments:
|
|
37
|
-
*
|
|
38
|
-
* - `N`: number of indexed elements
|
|
39
|
-
* - `X`: input array
|
|
40
|
-
* - `strideX`: `X` stride length
|
|
41
|
-
* - `Y`: destination array
|
|
42
|
-
* - `strideY`: `Y` stride length
|
|
43
|
-
*/
|
|
44
|
-
napi_value node_ccopy( napi_env env, napi_callback_info info ) {
|
|
45
|
-
napi_status status;
|
|
46
|
-
|
|
47
|
-
size_t argc = 5;
|
|
48
|
-
napi_value argv[ 5 ];
|
|
49
|
-
status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr );
|
|
50
|
-
assert( status == napi_ok );
|
|
51
|
-
|
|
52
|
-
if ( argc < 5 ) {
|
|
53
|
-
napi_throw_error( env, nullptr, "invalid invocation. Must provide 5 arguments." );
|
|
54
|
-
return nullptr;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
napi_valuetype vtype0;
|
|
58
|
-
status = napi_typeof( env, argv[ 0 ], &vtype0 );
|
|
59
|
-
assert( status == napi_ok );
|
|
60
|
-
if ( vtype0 != napi_number ) {
|
|
61
|
-
napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." );
|
|
62
|
-
return nullptr;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
bool res1;
|
|
66
|
-
status = napi_is_typedarray( env, argv[ 1 ], &res1 );
|
|
67
|
-
assert( status == napi_ok );
|
|
68
|
-
if ( res1 == false ) {
|
|
69
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." );
|
|
70
|
-
return nullptr;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
napi_valuetype vtype2;
|
|
74
|
-
status = napi_typeof( env, argv[ 2 ], &vtype2 );
|
|
75
|
-
assert( status == napi_ok );
|
|
76
|
-
if ( vtype2 != napi_number ) {
|
|
77
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a number." );
|
|
78
|
-
return nullptr;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
bool res3;
|
|
82
|
-
status = napi_is_typedarray( env, argv[ 3 ], &res3 );
|
|
83
|
-
assert( status == napi_ok );
|
|
84
|
-
if ( res3 == false ) {
|
|
85
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a Float32Array." );
|
|
86
|
-
return nullptr;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
napi_valuetype vtype4;
|
|
90
|
-
status = napi_typeof( env, argv[ 4 ], &vtype4 );
|
|
91
|
-
assert( status == napi_ok );
|
|
92
|
-
if ( vtype4 != napi_number ) {
|
|
93
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a number." );
|
|
94
|
-
return nullptr;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
int64_t N;
|
|
98
|
-
status = napi_get_value_int64( env, argv[ 0 ], &N );
|
|
99
|
-
assert( status == napi_ok );
|
|
100
|
-
|
|
101
|
-
int64_t strideX;
|
|
102
|
-
status = napi_get_value_int64( env, argv[ 2 ], &strideX );
|
|
103
|
-
assert( status == napi_ok );
|
|
104
|
-
|
|
105
|
-
int64_t strideY;
|
|
106
|
-
status = napi_get_value_int64( env, argv[ 4 ], &strideY );
|
|
107
|
-
assert( status == napi_ok );
|
|
108
|
-
|
|
109
|
-
napi_typedarray_type vtype1;
|
|
110
|
-
size_t xlen;
|
|
111
|
-
void *X;
|
|
112
|
-
status = napi_get_typedarray_info( env, argv[ 1 ], &vtype1, &xlen, &X, nullptr, nullptr );
|
|
113
|
-
assert( status == napi_ok );
|
|
114
|
-
if ( vtype1 != napi_float32_array ) {
|
|
115
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." );
|
|
116
|
-
return nullptr;
|
|
117
|
-
}
|
|
118
|
-
if ( 2*(N-1)*llabs(strideX) >= (int64_t)xlen ) {
|
|
119
|
-
napi_throw_range_error( env, nullptr, "invalid argument. Second argument has insufficient elements based on the associated stride and the number of indexed elements." );
|
|
120
|
-
return nullptr;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
napi_typedarray_type vtype3;
|
|
124
|
-
size_t ylen;
|
|
125
|
-
void *Y;
|
|
126
|
-
status = napi_get_typedarray_info( env, argv[ 3 ], &vtype3, &ylen, &Y, nullptr, nullptr );
|
|
127
|
-
assert( status == napi_ok );
|
|
128
|
-
if ( vtype3 != napi_float32_array ) {
|
|
129
|
-
napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a Float32Array." );
|
|
130
|
-
return nullptr;
|
|
131
|
-
}
|
|
132
|
-
if ( 2*(N-1)*llabs(strideY) >= (int64_t)ylen ) {
|
|
133
|
-
napi_throw_range_error( env, nullptr, "invalid argument. Fourth argument has insufficient elements based on the associated stride and the number of indexed elements." );
|
|
134
|
-
return nullptr;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
c_ccopy( N, X, strideX, Y, strideY );
|
|
138
|
-
|
|
139
|
-
return nullptr;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
napi_value Init( napi_env env, napi_value exports ) {
|
|
143
|
-
napi_status status;
|
|
144
|
-
napi_value fcn;
|
|
145
|
-
status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_ccopy, NULL, &fcn );
|
|
146
|
-
assert( status == napi_ok );
|
|
147
|
-
return fcn;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
NAPI_MODULE( NODE_GYP_MODULE_NAME, Init )
|
|
151
|
-
} // end namespace stdlib_blas_base_ccopy
|