@stdlib/blas-base-wasm-dznrm2 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 +399 -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 +322 -0
- package/lib/binary.browser.js +33 -0
- package/lib/binary.js +34 -0
- package/lib/index.js +92 -0
- package/lib/main.js +64 -0
- package/lib/module.js +198 -0
- package/lib/routine.js +166 -0
- package/manifest.json +36 -0
- package/package.json +91 -0
- package/src/exports.json +4 -0
- package/src/main.wasm +0 -0
- package/src/main.wat +277 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
package/NOTICE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
ADDED
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
@license Apache-2.0
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2025 The Stdlib Authors.
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
|
18
|
+
|
|
19
|
+
-->
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
32
|
+
# dznrm2
|
|
33
|
+
|
|
34
|
+
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
35
|
+
|
|
36
|
+
> Calculate the L2-norm of a complex double-precision floating-point vector.
|
|
37
|
+
|
|
38
|
+
<section class="installation">
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install @stdlib/blas-base-wasm-dznrm2
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
</section>
|
|
47
|
+
|
|
48
|
+
<section class="usage">
|
|
49
|
+
|
|
50
|
+
## Usage
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
var dznrm2 = require( '@stdlib/blas-base-wasm-dznrm2' );
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### dznrm2.main( N, x, strideX )
|
|
57
|
+
|
|
58
|
+
Calculates the L2-norm of a complex double-precision floating-point vector.
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
var Complex128Array = require( '@stdlib/array-complex128' );
|
|
62
|
+
|
|
63
|
+
var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
|
|
64
|
+
|
|
65
|
+
var z = dznrm2.main( 3, x, 1 );
|
|
66
|
+
// returns ~9.54
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The function has the following parameters:
|
|
70
|
+
|
|
71
|
+
- **N**: number of indexed elements.
|
|
72
|
+
- **x**: input [`Complex128Array`][@stdlib/array/complex128].
|
|
73
|
+
- **strideX**: index increment for `x`.
|
|
74
|
+
|
|
75
|
+
The `N` and stride parameters determine which elements in the input strided array are accessed at runtime. For example, to compute the L2-norm of every other element in `x`,
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
var Complex128Array = require( '@stdlib/array-complex128' );
|
|
79
|
+
|
|
80
|
+
var x = new Complex128Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] );
|
|
81
|
+
|
|
82
|
+
var z = dznrm2.main( 2, x, 2 );
|
|
83
|
+
// returns ~4.24
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
|
|
87
|
+
|
|
88
|
+
<!-- eslint-disable stdlib/capitalized-comments -->
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
var Complex128Array = require( '@stdlib/array-complex128' );
|
|
92
|
+
|
|
93
|
+
// Initial array:
|
|
94
|
+
var x0 = new Complex128Array( [ 2.0, 1.0, 2.0, 2.0, -2.0, -2.0, 2.0, 3.0 ] );
|
|
95
|
+
|
|
96
|
+
// Create a typed array view:
|
|
97
|
+
var x1 = new Complex128Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
|
|
98
|
+
|
|
99
|
+
var z = dznrm2.main( 2, x1, 2 );
|
|
100
|
+
// returns ~4.58
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### dznrm2.ndarray( N, x, strideX, offsetX )
|
|
104
|
+
|
|
105
|
+
Calculates the L2-norm of a complex double-precision floating-point vector using alternative indexing semantics.
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
var Complex128Array = require( '@stdlib/array-complex128' );
|
|
109
|
+
|
|
110
|
+
var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
|
|
111
|
+
|
|
112
|
+
var z = dznrm2.ndarray( 3, x, 1, 0 );
|
|
113
|
+
// returns ~9.54
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The function has the following additional parameters:
|
|
117
|
+
|
|
118
|
+
- **offsetX**: starting index for `x`.
|
|
119
|
+
|
|
120
|
+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the L2-norm for every other value in `x` starting from the second value,
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
var Complex128Array = require( '@stdlib/array-complex128' );
|
|
124
|
+
|
|
125
|
+
var x = new Complex128Array( [ 2.0, 1.0, 2.0, 2.0, -2.0, -2.0, 2.0, 3.0 ] );
|
|
126
|
+
|
|
127
|
+
var z = dznrm2.ndarray( 2, x, 2, 1 );
|
|
128
|
+
// returns ~4.58
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
* * *
|
|
132
|
+
|
|
133
|
+
### Module
|
|
134
|
+
|
|
135
|
+
#### dznrm2.Module( memory )
|
|
136
|
+
|
|
137
|
+
Returns a new WebAssembly [module wrapper][@stdlib/wasm/module-wrapper] instance which uses the provided WebAssembly [memory][@stdlib/wasm/memory] instance as its underlying memory.
|
|
138
|
+
|
|
139
|
+
<!-- eslint-disable node/no-sync -->
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
var Memory = require( '@stdlib/wasm-memory' );
|
|
143
|
+
|
|
144
|
+
// Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
145
|
+
var mem = new Memory({
|
|
146
|
+
'initial': 10,
|
|
147
|
+
'maximum': 100
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// Create a BLAS routine:
|
|
151
|
+
var mod = new dznrm2.Module( mem );
|
|
152
|
+
// returns <Module>
|
|
153
|
+
|
|
154
|
+
// Initialize the routine:
|
|
155
|
+
mod.initializeSync();
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### dznrm2.Module.prototype.main( N, xp, sx )
|
|
159
|
+
|
|
160
|
+
Computes the L2-norm of a complex double-precision floating-point vector.
|
|
161
|
+
|
|
162
|
+
<!-- eslint-disable node/no-sync -->
|
|
163
|
+
|
|
164
|
+
```javascript
|
|
165
|
+
var Memory = require( '@stdlib/wasm-memory' );
|
|
166
|
+
var oneTo = require( '@stdlib/array-one-to' );
|
|
167
|
+
var Complex128Array = require( '@stdlib/array-complex128' );
|
|
168
|
+
|
|
169
|
+
// Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
170
|
+
var mem = new Memory({
|
|
171
|
+
'initial': 10,
|
|
172
|
+
'maximum': 100
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Create a BLAS routine:
|
|
176
|
+
var mod = new dznrm2.Module( mem );
|
|
177
|
+
// returns <Module>
|
|
178
|
+
|
|
179
|
+
// Initialize the routine:
|
|
180
|
+
mod.initializeSync();
|
|
181
|
+
|
|
182
|
+
// Define a vector data type:
|
|
183
|
+
var dtype = 'complex128';
|
|
184
|
+
|
|
185
|
+
// Specify a vector length:
|
|
186
|
+
var N = 5;
|
|
187
|
+
|
|
188
|
+
// Define a pointer (i.e., byte offset) for storing the input vector:
|
|
189
|
+
var xptr = 0;
|
|
190
|
+
|
|
191
|
+
// Write vector values to module memory:
|
|
192
|
+
var xbuf = oneTo( N*2, 'float64' );
|
|
193
|
+
var x = new Complex128Array( xbuf.buffer );
|
|
194
|
+
mod.write( xptr, x );
|
|
195
|
+
|
|
196
|
+
// Perform computation:
|
|
197
|
+
var out = mod.main( N, xptr, 1 );
|
|
198
|
+
// returns ~19.62
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
The function has the following parameters:
|
|
202
|
+
|
|
203
|
+
- **N**: number of indexed elements.
|
|
204
|
+
- **xp**: input [`Complex128Array`][@stdlib/array/complex128] pointer (i.e., byte offset).
|
|
205
|
+
- **sx**: index increment for `x`.
|
|
206
|
+
|
|
207
|
+
#### dznrm2.Module.prototype.ndarray( N, xp, sx, ox )
|
|
208
|
+
|
|
209
|
+
Computes the L2-norm of a complex double-precision floating-point vector using alternative indexing semantics.
|
|
210
|
+
|
|
211
|
+
<!-- eslint-disable node/no-sync -->
|
|
212
|
+
|
|
213
|
+
```javascript
|
|
214
|
+
var Memory = require( '@stdlib/wasm-memory' );
|
|
215
|
+
var oneTo = require( '@stdlib/array-one-to' );
|
|
216
|
+
var Complex128Array = require( '@stdlib/array-complex128' );
|
|
217
|
+
|
|
218
|
+
// Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):
|
|
219
|
+
var mem = new Memory({
|
|
220
|
+
'initial': 10,
|
|
221
|
+
'maximum': 100
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
// Create a BLAS routine:
|
|
225
|
+
var mod = new dznrm2.Module( mem );
|
|
226
|
+
// returns <Module>
|
|
227
|
+
|
|
228
|
+
// Initialize the routine:
|
|
229
|
+
mod.initializeSync();
|
|
230
|
+
|
|
231
|
+
// Define a vector data type:
|
|
232
|
+
var dtype = 'complex128';
|
|
233
|
+
|
|
234
|
+
// Specify a vector length:
|
|
235
|
+
var N = 5;
|
|
236
|
+
|
|
237
|
+
// Define a pointer (i.e., byte offset) for storing the input vector:
|
|
238
|
+
var xptr = 0;
|
|
239
|
+
|
|
240
|
+
// Write vector values to module memory:
|
|
241
|
+
var xbuf = oneTo( N*2, 'float64' );
|
|
242
|
+
var x = new Complex128Array( xbuf.buffer );
|
|
243
|
+
mod.write( xptr, x );
|
|
244
|
+
|
|
245
|
+
// Perform computation:
|
|
246
|
+
var out = mod.ndarray( N, xptr, 1, 0 );
|
|
247
|
+
// returns ~19.62
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
The function has the following additional parameters:
|
|
251
|
+
|
|
252
|
+
- **ox**: starting index for `x`.
|
|
253
|
+
|
|
254
|
+
</section>
|
|
255
|
+
|
|
256
|
+
<!-- /.usage -->
|
|
257
|
+
|
|
258
|
+
<section class="notes">
|
|
259
|
+
|
|
260
|
+
* * *
|
|
261
|
+
|
|
262
|
+
## Notes
|
|
263
|
+
|
|
264
|
+
- If `N <= 0`, both `main` and `ndarray` methods return `0.0`.
|
|
265
|
+
- This package implements routines using WebAssembly. When provided arrays which are not allocated on a `dznrm2` module memory instance, data must be explicitly copied to module memory prior to computation. Data movement may entail a performance cost, and, thus, if you are using arrays external to module memory, you should prefer using [`@stdlib/blas-base/dznrm2`][@stdlib/blas/base/dznrm2]. However, if working with arrays which are allocated and explicitly managed on module memory, you can achieve better performance when compared to the pure JavaScript implementations found in [`@stdlib/blas/base/dznrm2`][@stdlib/blas/base/dznrm2]. Beware that such performance gains may come at the cost of additional complexity when having to perform manual memory management. Choosing between implementations depends heavily on the particular needs and constraints of your application, with no one choice universally better than the other.
|
|
266
|
+
- `dznrm2()` corresponds to the [BLAS][blas] level 1 function [`dznrm2`][dznrm2].
|
|
267
|
+
|
|
268
|
+
</section>
|
|
269
|
+
|
|
270
|
+
<!-- /.notes -->
|
|
271
|
+
|
|
272
|
+
<section class="examples">
|
|
273
|
+
|
|
274
|
+
* * *
|
|
275
|
+
|
|
276
|
+
## Examples
|
|
277
|
+
|
|
278
|
+
<!-- eslint no-undef: "error" -->
|
|
279
|
+
|
|
280
|
+
```javascript
|
|
281
|
+
var oneTo = require( '@stdlib/array-one-to' );
|
|
282
|
+
var Complex128Array = require( '@stdlib/array-complex128' );
|
|
283
|
+
var dznrm2 = require( '@stdlib/blas-base-wasm-dznrm2' );
|
|
284
|
+
|
|
285
|
+
// Specify a vector length:
|
|
286
|
+
var N = 5;
|
|
287
|
+
|
|
288
|
+
// Create an input array:
|
|
289
|
+
var xbuf = oneTo( N*2, 'float64' );
|
|
290
|
+
var x = new Complex128Array( xbuf.buffer );
|
|
291
|
+
|
|
292
|
+
// Perform computation:
|
|
293
|
+
var out = dznrm2.ndarray( N, x, 1, 0 );
|
|
294
|
+
|
|
295
|
+
// Print the result:
|
|
296
|
+
console.log( out );
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
</section>
|
|
300
|
+
|
|
301
|
+
<!-- /.examples -->
|
|
302
|
+
|
|
303
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
304
|
+
|
|
305
|
+
<section class="related">
|
|
306
|
+
|
|
307
|
+
</section>
|
|
308
|
+
|
|
309
|
+
<!-- /.related -->
|
|
310
|
+
|
|
311
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
<section class="main-repo" >
|
|
315
|
+
|
|
316
|
+
* * *
|
|
317
|
+
|
|
318
|
+
## Notice
|
|
319
|
+
|
|
320
|
+
This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
|
|
321
|
+
|
|
322
|
+
For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
|
|
323
|
+
|
|
324
|
+
#### Community
|
|
325
|
+
|
|
326
|
+
[![Chat][chat-image]][chat-url]
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## License
|
|
331
|
+
|
|
332
|
+
See [LICENSE][stdlib-license].
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
## Copyright
|
|
336
|
+
|
|
337
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
338
|
+
|
|
339
|
+
</section>
|
|
340
|
+
|
|
341
|
+
<!-- /.stdlib -->
|
|
342
|
+
|
|
343
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
344
|
+
|
|
345
|
+
<section class="links">
|
|
346
|
+
|
|
347
|
+
[npm-image]: http://img.shields.io/npm/v/@stdlib/blas-base-wasm-dznrm2.svg
|
|
348
|
+
[npm-url]: https://npmjs.org/package/@stdlib/blas-base-wasm-dznrm2
|
|
349
|
+
|
|
350
|
+
[test-image]: https://github.com/stdlib-js/blas-base-wasm-dznrm2/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
351
|
+
[test-url]: https://github.com/stdlib-js/blas-base-wasm-dznrm2/actions/workflows/test.yml?query=branch:v0.1.0
|
|
352
|
+
|
|
353
|
+
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-base-wasm-dznrm2/main.svg
|
|
354
|
+
[coverage-url]: https://codecov.io/github/stdlib-js/blas-base-wasm-dznrm2?branch=main
|
|
355
|
+
|
|
356
|
+
<!--
|
|
357
|
+
|
|
358
|
+
[dependencies-image]: https://img.shields.io/david/stdlib-js/blas-base-wasm-dznrm2.svg
|
|
359
|
+
[dependencies-url]: https://david-dm.org/stdlib-js/blas-base-wasm-dznrm2/main
|
|
360
|
+
|
|
361
|
+
-->
|
|
362
|
+
|
|
363
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
364
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
365
|
+
|
|
366
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
367
|
+
|
|
368
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
369
|
+
|
|
370
|
+
[umd]: https://github.com/umdjs/umd
|
|
371
|
+
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
372
|
+
|
|
373
|
+
[deno-url]: https://github.com/stdlib-js/blas-base-wasm-dznrm2/tree/deno
|
|
374
|
+
[deno-readme]: https://github.com/stdlib-js/blas-base-wasm-dznrm2/blob/deno/README.md
|
|
375
|
+
[umd-url]: https://github.com/stdlib-js/blas-base-wasm-dznrm2/tree/umd
|
|
376
|
+
[umd-readme]: https://github.com/stdlib-js/blas-base-wasm-dznrm2/blob/umd/README.md
|
|
377
|
+
[esm-url]: https://github.com/stdlib-js/blas-base-wasm-dznrm2/tree/esm
|
|
378
|
+
[esm-readme]: https://github.com/stdlib-js/blas-base-wasm-dznrm2/blob/esm/README.md
|
|
379
|
+
[branches-url]: https://github.com/stdlib-js/blas-base-wasm-dznrm2/blob/main/branches.md
|
|
380
|
+
|
|
381
|
+
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/blas-base-wasm-dznrm2/main/LICENSE
|
|
382
|
+
|
|
383
|
+
[blas]: http://www.netlib.org/blas
|
|
384
|
+
|
|
385
|
+
[dznrm2]: https://www.netlib.org/lapack/explore-html/d1/d2a/group__nrm2_ga7f9f9febc6dc1836c9f5e7c1aa00b743.html
|
|
386
|
+
|
|
387
|
+
[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
|
|
388
|
+
|
|
389
|
+
[@stdlib/array/complex128]: https://www.npmjs.com/package/@stdlib/array-complex128
|
|
390
|
+
|
|
391
|
+
[@stdlib/wasm/memory]: https://www.npmjs.com/package/@stdlib/wasm-memory
|
|
392
|
+
|
|
393
|
+
[@stdlib/wasm/module-wrapper]: https://www.npmjs.com/package/@stdlib/wasm-module-wrapper
|
|
394
|
+
|
|
395
|
+
[@stdlib/blas/base/dznrm2]: https://www.npmjs.com/package/@stdlib/blas-base-dznrm2
|
|
396
|
+
|
|
397
|
+
</section>
|
|
398
|
+
|
|
399
|
+
<!-- /.links -->
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";var u=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var y=u(function(G,p){
|
|
2
|
+
var _=require("path").resolve,b=require('@stdlib/fs-read-wasm/dist').sync,R=b(_(__dirname,"..","src","main.wasm"));p.exports=R
|
|
3
|
+
});var d=u(function(H,f){
|
|
4
|
+
var W=require('@stdlib/assert-is-wasm-memory/dist'),q=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),A=require('@stdlib/utils-inherit/dist'),m=require('@stdlib/wasm-module-wrapper/dist'),O=require('@stdlib/error-tools-fmtprodmsg/dist'),S=y();function n(e){if(!(this instanceof n))return new n(e);if(!W(e))throw new TypeError(O('2NfH0',e));return m.call(this,S,e,{env:{memory:e}}),this}A(n,m);q(n.prototype,"main",function(r,i,t){return this._instance.exports.c_dznrm2(r,i,t)});q(n.prototype,"ndarray",function(r,i,t,o){return this._instance.exports.c_dznrm2_ndarray(r,i,t,o)});f.exports=n
|
|
5
|
+
});var M=u(function(I,w){
|
|
6
|
+
var h=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=require('@stdlib/utils-inherit/dist'),j=require('@stdlib/strided-base-stride2offset/dist'),B=require('@stdlib/wasm-memory/dist'),E=require('@stdlib/wasm-base-arrays2ptrs/dist'),T=require('@stdlib/wasm-base-strided2object/dist'),v=d();function a(){return this instanceof a?(v.call(this,new B({initial:0})),this):new a}g(a,v);h(a.prototype,"main",function(r,i,t){return this.ndarray(r,i,t,j(r,t))});h(a.prototype,"ndarray",function(r,i,t,o){var l,s;return l=E(this,[T(r,i,t,o)]),s=l[0],v.prototype.ndarray.call(this,r,s.ptr,s.stride,s.offset)});w.exports=a
|
|
7
|
+
});var x=u(function(J,z){
|
|
8
|
+
var V=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),k=M(),C=d(),c=new k;c.initializeSync();V(c,"Module",C.bind(null));z.exports=c
|
|
9
|
+
});var D=x();module.exports=D;
|
|
10
|
+
/** @license Apache-2.0 */
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/binary.js", "../lib/module.js", "../lib/routine.js", "../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolve = require( 'path' ).resolve;\nvar readWASM = require( '@stdlib/fs-read-wasm' ).sync;\n\n\n// MAIN //\n\nvar wasm = readWASM( resolve( __dirname, '..', 'src', 'main.wasm' ) );\n\n\n// EXPORTS //\n\nmodule.exports = wasm;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isWebAssemblyMemory = require( '@stdlib/assert-is-wasm-memory' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar inherits = require( '@stdlib/utils-inherit' );\nvar WasmModule = require( '@stdlib/wasm-module-wrapper' );\nvar format = require( '@stdlib/string-format' );\nvar wasmBinary = require( './binary.js' );\n\n\n// MAIN //\n\n/**\n* BLAS routine WebAssembly module wrapper constructor.\n*\n* @constructor\n* @param {Object} memory - WebAssembly memory instance\n* @throws {TypeError} must provide a WebAssembly memory instance\n* @returns {Module} module instance\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var Complex128Array = require( '@stdlib/array-complex128' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var dznrm2 = new Module( mem );\n* // returns <Module>\n*\n* // Initialize the routine:\n* dznrm2.initializeSync();\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define a pointer (i.e., byte offset) for storing the input vector:\n* var xptr = 0;\n*\n* // Write vector values to module memory:\n* var xbuf = oneTo( N*2, 'float64' );\n* var x = new Complex128Array( xbuf.buffer );\n* dznrm2.write( xptr, x );\n*\n* // Perform computation:\n* var out = dznrm2.main( N, xptr, 1 );\n* // returns ~19.62\n*/\nfunction Module( memory ) {\n\tif ( !( this instanceof Module ) ) {\n\t\treturn new Module( memory );\n\t}\n\tif ( !isWebAssemblyMemory( memory ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a WebAssembly memory instance. Value: `%s`.', memory ) );\n\t}\n\t// Call the parent constructor:\n\tWasmModule.call( this, wasmBinary, memory, {\n\t\t'env': {\n\t\t\t'memory': memory\n\t\t}\n\t});\n\n\treturn this;\n}\n\n// Inherit from the parent constructor:\ninherits( Module, WasmModule );\n\n/**\n* Calculates the L2-norm of a complex double-precision floating-point vector.\n*\n* @name main\n* @memberof Module.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NonNegativeInteger} xptr - input array pointer (i.e., byte offset)\n* @param {integer} strideX - `x` stride length\n* @returns {number} the L2-norm\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var Complex128Array = require( '@stdlib/array-complex128' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var dznrm2 = new Module( mem );\n* // returns <Module>\n*\n* // Initialize the routine:\n* dznrm2.initializeSync();\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define a pointer (i.e., byte offset) for storing the input vector:\n* var xptr = 0;\n*\n* // Write vector values to module memory:\n* var xbuf = oneTo( N*2, 'float64' );\n* var x = new Complex128Array( xbuf.buffer );\n* dznrm2.write( xptr, x );\n*\n* // Perform computation:\n* var out = dznrm2.main( N, xptr, 1 );\n* // returns ~19.62\n*/\nsetReadOnly( Module.prototype, 'main', function dznrm2( N, xptr, strideX ) {\n\treturn this._instance.exports.c_dznrm2( N, xptr, strideX );\n});\n\n/**\n* Calculates the L2-norm of a complex double-precision floating-point vector using alternative indexing semantics.\n*\n* @name ndarray\n* @memberof Module.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NonNegativeInteger} xptr - input array pointer (i.e., byte offset)\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @returns {number} the L2-norm\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var Complex128Array = require( '@stdlib/array-complex128' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var dznrm2 = new Module( mem );\n* // returns <Module>\n*\n* // Initialize the routine:\n* dznrm2.initializeSync();\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define a pointer (i.e., byte offset) for storing the input vector:\n* var xptr = 0;\n*\n* // Write vector values to module memory:\n* var xbuf = oneTo( N*2, 'float64' );\n* var x = new Complex128Array( xbuf.buffer );\n* dznrm2.write( xptr, x );\n*\n* // Perform computation:\n* var out = dznrm2.ndarray( N, xptr, 1, 0 );\n* // returns ~19.62\n*/\nsetReadOnly( Module.prototype, 'ndarray', function dznrm2( N, xptr, strideX, offsetX ) {\n\treturn this._instance.exports.c_dznrm2_ndarray( N, xptr, strideX, offsetX );\n});\n\n\n// EXPORTS //\n\nmodule.exports = Module;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar inherits = require( '@stdlib/utils-inherit' );\nvar stride2offset = require( '@stdlib/strided-base-stride2offset' );\nvar Memory = require( '@stdlib/wasm-memory' );\nvar arrays2ptrs = require( '@stdlib/wasm-base-arrays2ptrs' );\nvar strided2object = require( '@stdlib/wasm-base-strided2object' );\nvar Module = require( './module.js' );\n\n\n// MAIN //\n\n/**\n* Routine constructor.\n*\n* @private\n* @constructor\n* @returns {Routine} routine instance\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n*\n* // Create a new routine:\n* var dznrm2 = new Routine();\n*\n* // Initialize the module:\n* dznrm2.initializeSync();\n*\n* // Define a strided array:\n* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );\n*\n* // Perform operation:\n* var out = dznrm2.main( x.length, x, 1 );\n* // returns ~9.54\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n*\n* // Create a new routine:\n* var dznrm2 = new Routine();\n*\n* // Initialize the module:\n* dznrm2.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );\n*\n* // Perform operation:\n* var out = dznrm2.ndarray( x.length, x, 1, 0 );\n* // returns ~9.54\n*/\nfunction Routine() {\n\tif ( !( this instanceof Routine ) ) {\n\t\treturn new Routine();\n\t}\n\tModule.call( this, new Memory({\n\t\t'initial': 0\n\t}));\n\treturn this;\n}\n\n// Inherit from the parent constructor:\ninherits( Routine, Module );\n\n/**\n* Calculates the L2-norm of a complex double-precision floating-point vector.\n*\n* @name main\n* @memberof Routine.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Complex128Array} x - input array\n* @param {integer} strideX - `x` stride length\n* @returns {number} the L2-norm\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n*\n* // Create a new routine:\n* var dznrm2 = new Routine();\n*\n* // Initialize the module:\n* dznrm2.initializeSync();\n*\n* // Define a strided array:\n* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );\n*\n* // Perform operation:\n* var out = dznrm2.main( x.length, x, 1 );\n* // returns ~9.54\n*/\nsetReadOnly( Routine.prototype, 'main', function dznrm2( N, x, strideX ) {\n\treturn this.ndarray( N, x, strideX, stride2offset( N, strideX ) );\n});\n\n/**\n* Calculates the L2-norm of a complex double-precision floating-point vector using alternative indexing semantics.\n*\n* @name ndarray\n* @memberof Routine.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Complex128Array} x - input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @returns {number} the L2-norm\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n*\n* // Create a new routine:\n* var dznrm2 = new Routine();\n*\n* // Initialize the module:\n* dznrm2.initializeSync();\n*\n* // Define a strided array:\n* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );\n*\n* // Perform operation:\n* var out = dznrm2.ndarray( x.length, x, 1, 0 );\n* // returns ~9.54\n*/\nsetReadOnly( Routine.prototype, 'ndarray', function dznrm2( N, x, strideX, offsetX ) {\n\tvar ptrs;\n\tvar p0;\n\n\t// Convert the input array to \"pointers\" in the module's memory:\n\tptrs = arrays2ptrs( this, [\n\t\tstrided2object( N, x, strideX, offsetX )\n\t]);\n\tp0 = ptrs[ 0 ];\n\n\t// Perform computation by calling the corresponding parent method:\n\treturn Module.prototype.ndarray.call( this, N, p0.ptr, p0.stride, p0.offset ); // eslint-disable-line max-len\n});\n\n\n// EXPORTS //\n\nmodule.exports = Routine;\n", "\n/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar Routine = require( './routine.js' );\nvar Module = require( './module.js' );\n\n\n// MAIN //\n\n/**\n* WebAssembly module to calculate the L2-norm of a complex double-precision floating-point vector.\n*\n* @name dznrm2\n* @type {Routine}\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n*\n* // Define a strided array:\n* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );\n*\n* // Perform operation:\n* var out = dznrm2.main( x.length, x, 1 );\n* // returns ~9.54\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n*\n* // Define a strided array:\n* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );\n*\n* // Perform operation:\n* var out = dznrm2.ndarray( x.length, x, 1, 0 );\n* // returns ~9.54\n*/\nvar dznrm2 = new Routine();\ndznrm2.initializeSync(); // eslint-disable-line node/no-sync\nsetReadOnly( dznrm2, 'Module', Module.bind( null ) );\n\n\n// EXPORTS //\n\nmodule.exports = dznrm2;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* WebAssembly routine to calculate the L2-norm of a complex double-precision floating-point vector.\n*\n* @module @stdlib/blas-base-wasm-dznrm2\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n* var dznrm2 = require( '@stdlib/blas-base-wasm-dznrm2' );\n*\n* // Define a strided array:\n* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );\n*\n* // Perform operation:\n* var out = dznrm2.main( x.length, x, 1 );\n* // returns ~9.54\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n* var dznrm2 = require( '@stdlib/blas-base-wasm-dznrm2' );\n*\n* // Define a strided array:\n* var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );\n*\n* // Perform operation:\n* var out = dznrm2.ndarray( x.length, x, 1, 0 );\n* // returns ~9.54\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var Complex128Array = require( '@stdlib/array-complex128' );\n* var dznrm2 = require( '@stdlib/blas-base-wasm-dznrm2' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var mod = new dznrm2.Module( mem );\n* // returns <Module>\n*\n* // Initialize the routine:\n* mod.initializeSync();\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define a pointer (i.e., byte offset) for storing the input vector:\n* var xptr = 0;\n*\n* // Write vector values to module memory:\n* var xbuf = oneTo( N*2, 'float64' );\n* var x = new Complex128Array( xbuf.buffer );\n* mod.write( xptr, x );\n*\n* // Perform computation:\n* var out = mod.main( N, xptr, 1 );\n* // returns ~19.62\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"Module\": \"main.Module\" }\n"],
|
|
5
|
+
"mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,MAAO,EAAE,QAC5BC,EAAW,QAAS,sBAAuB,EAAE,KAK7CC,EAAOD,EAAUD,EAAS,UAAW,KAAM,MAAO,WAAY,CAAE,EAKpED,EAAO,QAAUG,ICjCjB,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAwBA,IAAIC,EAAsB,QAAS,+BAAgC,EAC/DC,EAAc,QAAS,uDAAwD,EAC/EC,EAAW,QAAS,uBAAwB,EAC5CC,EAAa,QAAS,6BAA8B,EACpDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAa,IA8CjB,SAASC,EAAQC,EAAS,CACzB,GAAK,EAAG,gBAAgBD,GACvB,OAAO,IAAIA,EAAQC,CAAO,EAE3B,GAAK,CAACP,EAAqBO,CAAO,EACjC,MAAM,IAAI,UAAWH,EAAQ,6EAA8EG,CAAO,CAAE,EAGrH,OAAAJ,EAAW,KAAM,KAAME,EAAYE,EAAQ,CAC1C,IAAO,CACN,OAAUA,CACX,CACD,CAAC,EAEM,IACR,CAGAL,EAAUI,EAAQH,CAAW,EA+C7BF,EAAaK,EAAO,UAAW,OAAQ,SAAiBE,EAAGC,EAAMC,EAAU,CAC1E,OAAO,KAAK,UAAU,QAAQ,SAAUF,EAAGC,EAAMC,CAAQ,CAC1D,CAAC,EAgDDT,EAAaK,EAAO,UAAW,UAAW,SAAiBE,EAAGC,EAAMC,EAASC,EAAU,CACtF,OAAO,KAAK,UAAU,QAAQ,iBAAkBH,EAAGC,EAAMC,EAASC,CAAQ,CAC3E,CAAC,EAKDZ,EAAO,QAAUO,ICrMjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAwBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAW,QAAS,uBAAwB,EAC5CC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAS,QAAS,qBAAsB,EACxCC,EAAc,QAAS,+BAAgC,EACvDC,EAAiB,QAAS,kCAAmC,EAC7DC,EAAS,IA4Cb,SAASC,GAAU,CAClB,OAAQ,gBAAgBA,GAGxBD,EAAO,KAAM,KAAM,IAAIH,EAAO,CAC7B,QAAW,CACZ,CAAC,CAAC,EACK,MALC,IAAII,CAMb,CAGAN,EAAUM,EAASD,CAAO,EA8B1BN,EAAaO,EAAQ,UAAW,OAAQ,SAAiBC,EAAGC,EAAGC,EAAU,CACxE,OAAO,KAAK,QAASF,EAAGC,EAAGC,EAASR,EAAeM,EAAGE,CAAQ,CAAE,CACjE,CAAC,EA+BDV,EAAaO,EAAQ,UAAW,UAAW,SAAiBC,EAAGC,EAAGC,EAASC,EAAU,CACpF,IAAIC,EACAC,EAGJ,OAAAD,EAAOR,EAAa,KAAM,CACzBC,EAAgBG,EAAGC,EAAGC,EAASC,CAAQ,CACxC,CAAC,EACDE,EAAKD,EAAM,CAAE,EAGNN,EAAO,UAAU,QAAQ,KAAM,KAAME,EAAGK,EAAG,IAAKA,EAAG,OAAQA,EAAG,MAAO,CAC7E,CAAC,EAKDd,EAAO,QAAUQ,ICrKjB,IAAAO,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAU,IACVC,EAAS,IA+BTC,EAAS,IAAIF,EACjBE,EAAO,eAAe,EACtBH,EAAaG,EAAQ,SAAUD,EAAO,KAAM,IAAK,CAAE,EAKnDH,EAAO,QAAUI,ICqBjB,IAAIC,EAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_binary", "__commonJSMin", "exports", "module", "resolve", "readWASM", "wasm", "require_module", "__commonJSMin", "exports", "module", "isWebAssemblyMemory", "setReadOnly", "inherits", "WasmModule", "format", "wasmBinary", "Module", "memory", "N", "xptr", "strideX", "offsetX", "require_routine", "__commonJSMin", "exports", "module", "setReadOnly", "inherits", "stride2offset", "Memory", "arrays2ptrs", "strided2object", "Module", "Routine", "N", "x", "strideX", "offsetX", "ptrs", "p0", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "Routine", "Module", "dznrm2", "main"]
|
|
7
|
+
}
|