@stdlib/blas-base-wasm-scasum 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/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +391 -0
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +317 -0
- package/lib/binary.browser.js +33 -0
- package/lib/binary.js +34 -0
- package/lib/index.js +92 -0
- package/lib/main.js +63 -0
- package/lib/module.js +198 -0
- package/lib/routine.js +166 -0
- package/manifest.json +36 -0
- package/package.json +92 -0
- package/src/exports.json +4 -0
- package/src/main.wasm +0 -0
- package/src/main.wat +93 -0
|
@@ -0,0 +1,317 @@
|
|
|
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
|
+
// TypeScript Version: 4.1
|
|
20
|
+
|
|
21
|
+
/// <reference types="@stdlib/types"/>
|
|
22
|
+
|
|
23
|
+
import { ModuleWrapper, Memory } from '@stdlib/types/wasm';
|
|
24
|
+
import { Complex64Array } from '@stdlib/types/array';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Interface defining a module constructor which is both "newable" and "callable".
|
|
28
|
+
*/
|
|
29
|
+
interface ModuleConstructor {
|
|
30
|
+
/**
|
|
31
|
+
* Returns a new WebAssembly module wrapper instance which uses the provided WebAssembly memory instance as its underlying memory.
|
|
32
|
+
*
|
|
33
|
+
* @param mem - WebAssembly memory instance
|
|
34
|
+
* @returns module wrapper instance
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
38
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
39
|
+
*
|
|
40
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
41
|
+
* var mem = new Memory({
|
|
42
|
+
* 'initial': 10,
|
|
43
|
+
* 'maximum': 100
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Create a BLAS routine:
|
|
47
|
+
* var mod = new scasum.Module( mem );
|
|
48
|
+
* // returns <Module>
|
|
49
|
+
*
|
|
50
|
+
* // Initialize the routine:
|
|
51
|
+
* mod.initializeSync();
|
|
52
|
+
*
|
|
53
|
+
* // Define a vector data type:
|
|
54
|
+
* var dtype = 'complex64';
|
|
55
|
+
*
|
|
56
|
+
* // Specify a vector length:
|
|
57
|
+
* var N = 4;
|
|
58
|
+
*
|
|
59
|
+
* // Define a pointer (i.e., byte offset) for storing the input vector:
|
|
60
|
+
* var xptr = 0;
|
|
61
|
+
*
|
|
62
|
+
* // Write vector values to module memory:
|
|
63
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
64
|
+
*
|
|
65
|
+
* // Perform computation:
|
|
66
|
+
* var out = mod.main( N, xptr, 1 );
|
|
67
|
+
* // returns 10.0
|
|
68
|
+
*/
|
|
69
|
+
new( mem: Memory ): Module; // newable
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Returns a new WebAssembly module wrapper instance which uses the provided WebAssembly memory instance as its underlying memory.
|
|
73
|
+
*
|
|
74
|
+
* @param mem - WebAssembly memory instance
|
|
75
|
+
* @returns module wrapper instance
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
79
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
80
|
+
*
|
|
81
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
82
|
+
* var mem = new Memory({
|
|
83
|
+
* 'initial': 10,
|
|
84
|
+
* 'maximum': 100
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* // Create a BLAS routine:
|
|
88
|
+
* var mod = scasum.Module( mem );
|
|
89
|
+
* // returns <Module>
|
|
90
|
+
*
|
|
91
|
+
* // Initialize the routine:
|
|
92
|
+
* mod.initializeSync();
|
|
93
|
+
*
|
|
94
|
+
* // Define a vector data type:
|
|
95
|
+
* var dtype = 'complex64';
|
|
96
|
+
*
|
|
97
|
+
* // Specify a vector length:
|
|
98
|
+
* var N = 4;
|
|
99
|
+
*
|
|
100
|
+
* // Define a pointer (i.e., byte offset) for storing the input vector:
|
|
101
|
+
* var xptr = 0;
|
|
102
|
+
*
|
|
103
|
+
* // Write vector values to module memory:
|
|
104
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
105
|
+
*
|
|
106
|
+
* // Perform computation:
|
|
107
|
+
* var out = mod.main( N, xptr, 1 );
|
|
108
|
+
* // returns 10.0
|
|
109
|
+
*/
|
|
110
|
+
( mem: Memory ): Module; // callable
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Interface describing a `scasum` WebAssembly module.
|
|
115
|
+
*/
|
|
116
|
+
interface Module extends ModuleWrapper {
|
|
117
|
+
/**
|
|
118
|
+
* Computes the sum of the absolute values of the real and imaginary components of a single-precision complex floating-point vector.
|
|
119
|
+
*
|
|
120
|
+
* @param N - number of indexed elements
|
|
121
|
+
* @param xptr - input array pointer (i.e., byte offset)
|
|
122
|
+
* @param strideX - `x` stride length
|
|
123
|
+
* @returns sum of absolute values
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
127
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
128
|
+
*
|
|
129
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
130
|
+
* var mem = new Memory({
|
|
131
|
+
* 'initial': 10,
|
|
132
|
+
* 'maximum': 100
|
|
133
|
+
* });
|
|
134
|
+
*
|
|
135
|
+
* // Create a BLAS routine:
|
|
136
|
+
* var mod = new scasum.Module( mem );
|
|
137
|
+
* // returns <Module>
|
|
138
|
+
*
|
|
139
|
+
* // Initialize the routine:
|
|
140
|
+
* mod.initializeSync();
|
|
141
|
+
*
|
|
142
|
+
* // Define a vector data type:
|
|
143
|
+
* var dtype = 'complex64';
|
|
144
|
+
*
|
|
145
|
+
* // Specify a vector length:
|
|
146
|
+
* var N = 4;
|
|
147
|
+
*
|
|
148
|
+
* // Define a pointer (i.e., byte offset) for storing the input vector:
|
|
149
|
+
* var xptr = 0;
|
|
150
|
+
*
|
|
151
|
+
* // Write vector values to module memory:
|
|
152
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
153
|
+
*
|
|
154
|
+
* // Perform computation:
|
|
155
|
+
* var out = mod.main( N, xptr, 1 );
|
|
156
|
+
* // returns 10.0
|
|
157
|
+
*/
|
|
158
|
+
main( N: number, xptr: number, strideX: number ): number;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Computes the sum of the absolute values of the real and imaginary components of a single-precision complex floating-point vector using alternative indexing semantics.
|
|
162
|
+
*
|
|
163
|
+
* @param N - number of indexed elements
|
|
164
|
+
* @param xptr - input array pointer (i.e., byte offset)
|
|
165
|
+
* @param strideX - `x` stride length
|
|
166
|
+
* @param offsetX - starting index for `x`
|
|
167
|
+
* @returns sum of absolute values
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
171
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
172
|
+
*
|
|
173
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
174
|
+
* var mem = new Memory({
|
|
175
|
+
* 'initial': 10,
|
|
176
|
+
* 'maximum': 100
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* // Create a BLAS routine:
|
|
180
|
+
* var mod = new scasum.Module( mem );
|
|
181
|
+
* // returns <Module>
|
|
182
|
+
*
|
|
183
|
+
* // Initialize the routine:
|
|
184
|
+
* mod.initializeSync();
|
|
185
|
+
*
|
|
186
|
+
* // Define a vector data type:
|
|
187
|
+
* var dtype = 'complex64';
|
|
188
|
+
*
|
|
189
|
+
* // Specify a vector length:
|
|
190
|
+
* var N = 4;
|
|
191
|
+
*
|
|
192
|
+
* // Define a pointer (i.e., byte offset) for storing the input vector:
|
|
193
|
+
* var xptr = 0;
|
|
194
|
+
*
|
|
195
|
+
* // Write vector values to module memory:
|
|
196
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
197
|
+
*
|
|
198
|
+
* // Perform computation:
|
|
199
|
+
* var out = mod.ndarray( N, xptr, 1, 0 );
|
|
200
|
+
* // returns 10.0
|
|
201
|
+
*/
|
|
202
|
+
ndarray( N: number, xptr: number, strideX: number, offsetX: number ): number;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Interface describing `scasum`.
|
|
207
|
+
*/
|
|
208
|
+
interface Routine extends ModuleWrapper {
|
|
209
|
+
/**
|
|
210
|
+
* Computes the sum of the absolute values of the real and imaginary components of a single-precision complex floating-point vector.
|
|
211
|
+
*
|
|
212
|
+
* @param N - number of indexed elements
|
|
213
|
+
* @param x - input array
|
|
214
|
+
* @param strideX - `x` stride length
|
|
215
|
+
* @returns sum of absolute values
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
219
|
+
*
|
|
220
|
+
* var x = new Complex64Array( [ 2.0, 1.0, 3.0, 5.0, 4.0, 0.0, 1.0, 3.0 ] );
|
|
221
|
+
*
|
|
222
|
+
* var out = scasum.main( x.length, x, 1 );
|
|
223
|
+
* // returns 19.0
|
|
224
|
+
*/
|
|
225
|
+
main( N: number, x: Complex64Array, strideX: number ): number;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Computes the sum of absolute values using alternative indexing semantics.
|
|
229
|
+
*
|
|
230
|
+
* @param N - number of indexed elements
|
|
231
|
+
* @param x - input array
|
|
232
|
+
* @param strideX - `x` stride length
|
|
233
|
+
* @param offsetX - starting index for `x`
|
|
234
|
+
* @returns sum of absolute values
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
238
|
+
*
|
|
239
|
+
* var x = new Complex64Array( [ 2.0, 1.0, 3.0, 5.0, 4.0, 0.0, 1.0, 3.0 ] );
|
|
240
|
+
*
|
|
241
|
+
* var out = scasum.ndarray( x.length, x, 1, 0 );
|
|
242
|
+
* // returns 19.0
|
|
243
|
+
*/
|
|
244
|
+
ndarray( N: number, x: Complex64Array, strideX: number, offsetX: number ): number;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Returns a new WebAssembly module wrapper instance which uses the provided WebAssembly memory instance as its underlying memory.
|
|
248
|
+
*
|
|
249
|
+
* @param mem - WebAssembly memory instance
|
|
250
|
+
* @returns module wrapper instance
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
254
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
255
|
+
*
|
|
256
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
257
|
+
* var mem = new Memory({
|
|
258
|
+
* 'initial': 10,
|
|
259
|
+
* 'maximum': 100
|
|
260
|
+
* });
|
|
261
|
+
*
|
|
262
|
+
* // Create a BLAS routine:
|
|
263
|
+
* var mod = new scasum.Module( mem );
|
|
264
|
+
* // returns <Module>
|
|
265
|
+
*
|
|
266
|
+
* // Initialize the routine:
|
|
267
|
+
* mod.initializeSync();
|
|
268
|
+
*
|
|
269
|
+
* // Define a vector data type:
|
|
270
|
+
* var dtype = 'complex64';
|
|
271
|
+
*
|
|
272
|
+
* // Specify a vector length:
|
|
273
|
+
* var N = 4;
|
|
274
|
+
*
|
|
275
|
+
* // Define a pointer (i.e., byte offset) for storing the input vector:
|
|
276
|
+
* var xptr = 0;
|
|
277
|
+
*
|
|
278
|
+
* // Write vector values to module memory:
|
|
279
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
280
|
+
*
|
|
281
|
+
* // Perform computation:
|
|
282
|
+
* var out = mod.main( N, xptr, 1 );
|
|
283
|
+
* // returns 10.0
|
|
284
|
+
*/
|
|
285
|
+
Module: ModuleConstructor;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Computes the sum of absolute values.
|
|
290
|
+
*
|
|
291
|
+
* @param N - number of indexed elements
|
|
292
|
+
* @param x - input array
|
|
293
|
+
* @param strideX - `x` stride length
|
|
294
|
+
* @returns sum of absolute values
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
298
|
+
*
|
|
299
|
+
* var x = new Complex64Array( [ 2.0, 1.0, 3.0, 5.0, 4.0, 0.0, 1.0, 3.0 ] );
|
|
300
|
+
*
|
|
301
|
+
* var out = scasum.main( x.length, x, 1 );
|
|
302
|
+
* // returns 19.0
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
306
|
+
*
|
|
307
|
+
* var x = new Complex64Array( [ 2.0, 1.0, 3.0, 5.0, 4.0, 0.0, 1.0, 3.0 ] );
|
|
308
|
+
*
|
|
309
|
+
* var out = scasum.ndarray( x.length, x, 1, 0 );
|
|
310
|
+
* // returns 19.0
|
|
311
|
+
*/
|
|
312
|
+
declare var scasum: Routine;
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
// EXPORTS //
|
|
316
|
+
|
|
317
|
+
export = scasum;
|
|
@@ -0,0 +1,33 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var base64ToUint8Array = require( '@stdlib/string-base-base64-to-uint8array' );
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// MAIN //
|
|
27
|
+
|
|
28
|
+
var wasm = base64ToUint8Array( 'AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGADf39/AX1gBH9/f38BfQIPAQNlbnYGbWVtb3J5AgAAAwQDAAECBzMDEV9fd2FzbV9jYWxsX2N0b3JzAAAIY19zY2FzdW0AARBjX3NjYXN1bV9uZGFycmF5AAIKfQMDAAELGgAgACABIAJBASAAayACbEEAIAJBAEwbEAILXAIBfQJ/AkAgAEEATARADAELIANBAXQhBSACQQF0IQJBACEDA0AgACADRg0BIAQgASAFQQJ0aiIGKgIAiyAGKgIEi5KSIQQgA0EBaiEDIAIgBWohBQwACwALIAQL' );
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// EXPORTS //
|
|
32
|
+
|
|
33
|
+
module.exports = wasm;
|
package/lib/binary.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var resolve = require( 'path' ).resolve;
|
|
24
|
+
var readWASM = require( '@stdlib/fs-read-wasm' ).sync;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// MAIN //
|
|
28
|
+
|
|
29
|
+
var wasm = readWASM( resolve( __dirname, '..', 'src', 'main.wasm' ) );
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// EXPORTS //
|
|
33
|
+
|
|
34
|
+
module.exports = wasm;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* WebAssembly routine to compute the sum of the absolute values of the real and imaginary components of a single-precision complex floating-point vector.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/blas-base-wasm-scasum
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
28
|
+
* var scasum = require( '@stdlib/blas-base-wasm-scasum' );
|
|
29
|
+
*
|
|
30
|
+
* // Define a strided array:
|
|
31
|
+
* var x = new Complex64Array( [ 2.0, 1.0, 3.0, 5.0, 4.0, 0.0, 1.0, 3.0 ] );
|
|
32
|
+
*
|
|
33
|
+
* // Perform operation:
|
|
34
|
+
* var sum = scasum.main( x.length, x, 1 );
|
|
35
|
+
* // returns 19.0
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
39
|
+
* var scasum = require( '@stdlib/blas-base-wasm-scasum' );
|
|
40
|
+
*
|
|
41
|
+
* // Define a strided array:
|
|
42
|
+
* var x = new Complex64Array( [ 2.0, 1.0, 3.0, 5.0, 4.0, 0.0, 1.0, 3.0 ] );
|
|
43
|
+
*
|
|
44
|
+
* // Perform operation:
|
|
45
|
+
* var sum = scasum.ndarray( x.length, x, 1, 0 );
|
|
46
|
+
* // returns 19.0
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* var Memory = require( '@stdlib/wasm-memory' );
|
|
50
|
+
* var oneTo = require( '@stdlib/array-one-to' );
|
|
51
|
+
* var scasum = require( '@stdlib/blas-base-wasm-scasum' );
|
|
52
|
+
*
|
|
53
|
+
* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
54
|
+
* var mem = new Memory({
|
|
55
|
+
* 'initial': 10,
|
|
56
|
+
* 'maximum': 100
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* // Create a BLAS routine:
|
|
60
|
+
* var mod = new scasum.Module( mem );
|
|
61
|
+
* // returns <Module>
|
|
62
|
+
*
|
|
63
|
+
* // Initialize the routine:
|
|
64
|
+
* mod.initializeSync();
|
|
65
|
+
*
|
|
66
|
+
* // Define a vector data type:
|
|
67
|
+
* var dtype = 'complex64';
|
|
68
|
+
*
|
|
69
|
+
* // Specify a vector length:
|
|
70
|
+
* var N = 4;
|
|
71
|
+
*
|
|
72
|
+
* // Define a pointer (i.e., byte offset) for storing the input vector:
|
|
73
|
+
* var xptr = 0;
|
|
74
|
+
*
|
|
75
|
+
* // Write vector values to module memory:
|
|
76
|
+
* mod.write( xptr, oneTo( N, dtype ) );
|
|
77
|
+
*
|
|
78
|
+
* // Perform computation:
|
|
79
|
+
* var sum = mod.main( N, xptr, 1 );
|
|
80
|
+
* // returns 10.0
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
// MODULES //
|
|
84
|
+
|
|
85
|
+
var main = require( './main.js' );
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
// EXPORTS //
|
|
89
|
+
|
|
90
|
+
module.exports = main;
|
|
91
|
+
|
|
92
|
+
// exports: { "Module": "main.Module" }
|
package/lib/main.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
'use strict';
|
|
20
|
+
|
|
21
|
+
// MODULES //
|
|
22
|
+
|
|
23
|
+
var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
|
|
24
|
+
var Routine = require( './routine.js' );
|
|
25
|
+
var Module = require( './module.js' );
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// MAIN //
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* WebAssembly module compute the sum of the absolute values of the real and imaginary components of a single-precision complex floating-point vector.
|
|
32
|
+
*
|
|
33
|
+
* @name scasum
|
|
34
|
+
* @type {Routine}
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
38
|
+
*
|
|
39
|
+
* // Define a strided array:
|
|
40
|
+
* var x = new Complex64Array( [ 2.0, 1.0, 3.0, 5.0, 4.0, 0.0, 1.0, 3.0 ] );
|
|
41
|
+
*
|
|
42
|
+
* // Perform operation:
|
|
43
|
+
* var sum = scasum.main( x.length, x, 1 );
|
|
44
|
+
* // returns 19.0
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
48
|
+
*
|
|
49
|
+
* // Define a strided array:
|
|
50
|
+
* var x = new Complex64Array( [ 2.0, 1.0, 3.0, 5.0, 4.0, 0.0, 1.0, 3.0 ] );
|
|
51
|
+
*
|
|
52
|
+
* // Perform operation:
|
|
53
|
+
* var sum = scasum.ndarray( x.length, x, 1, 0 );
|
|
54
|
+
* // returns 19.0
|
|
55
|
+
*/
|
|
56
|
+
var scasum = new Routine();
|
|
57
|
+
scasum.initializeSync(); // eslint-disable-line node/no-sync
|
|
58
|
+
setReadOnly( scasum, 'Module', Module.bind( null ) );
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
// EXPORTS //
|
|
62
|
+
|
|
63
|
+
module.exports = scasum;
|