wgblas 2.1.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/wgblas.browser.js +1016 -43
- package/index.d.mts +26 -53
- package/index.mjs +11 -0
- package/package.json +132 -63
- package/src/classes/Complex32.d.mts +43 -0
- package/src/classes/Complex32.mjs +82 -0
- package/src/classes/Complex64.d.mts +44 -0
- package/src/classes/Complex64.mjs +76 -0
- package/src/classes/GpuMatrix.d.mts +41 -41
- package/src/classes/GpuMatrix.mjs +112 -10
- package/src/classes/GpuVector.d.mts +36 -40
- package/src/classes/GpuVector.mjs +39 -2
- package/src/cscal/cscal.d.mts +47 -0
- package/src/cscal/cscal.mjs +98 -0
- package/src/dasum/dasum.mjs +31 -15
- package/src/daxpy/daxpy.d.mts +56 -0
- package/src/daxpy/daxpy.mjs +150 -0
- package/src/dcopy/dcopy.d.mts +52 -0
- package/src/dcopy/dcopy.mjs +140 -0
- package/src/ddot/ddot.d.mts +62 -0
- package/src/ddot/ddot.mjs +184 -0
- package/src/dnrm2/dnrm2.d.mts +50 -0
- package/src/dnrm2/dnrm2.mjs +189 -0
- package/src/drot/drot.d.mts +67 -0
- package/src/drot/drot.mjs +170 -0
- package/src/drotm/drotm.d.mts +67 -0
- package/src/drotm/drotm.mjs +171 -0
- package/src/dscal/dscal.d.mts +52 -0
- package/src/dscal/dscal.mjs +119 -0
- package/src/dswap/dswap.d.mts +57 -0
- package/src/dswap/dswap.mjs +155 -0
- package/src/idamax/idamax.mjs +49 -19
- package/src/init.mjs +6 -3
- package/src/isamax/isamax.mjs +17 -14
- package/src/random/random.d.mts +37 -40
- package/src/random/random.mjs +39 -7
- package/src/sasum/sasum.mjs +13 -11
- package/src/saxpy/saxpy.mjs +9 -8
- package/src/scopy/scopy.mjs +8 -6
- package/src/sdot/sdot.mjs +13 -11
- package/src/sgemm/sgemm.d.mts +2 -2
- package/src/sgemm/sgemm.mjs +91 -35
- package/src/sgemmtr/sgemmtr.d.mts +3 -2
- package/src/sgemmtr/sgemmtr.mjs +92 -35
- package/src/sgemv/sgemv.d.mts +2 -2
- package/src/sgemv/sgemv.mjs +41 -25
- package/src/sger/sger.d.mts +2 -2
- package/src/sger/sger.mjs +38 -16
- package/src/shaders/__test_pipeline_a.wgsl +3 -0
- package/src/shaders/__test_pipeline_b.wgsl +2 -0
- package/src/shaders/cscal.wgsl +33 -0
- package/src/shaders/daxpy.wgsl +66 -0
- package/src/shaders/dcopy.wgsl +34 -0
- package/src/shaders/ddot.wgsl +106 -0
- package/src/shaders/dnrm2.wgsl +167 -0
- package/src/shaders/drot.wgsl +81 -0
- package/src/shaders/drotm.wgsl +99 -0
- package/src/shaders/dscal.wgsl +60 -0
- package/src/shaders/dswap.wgsl +38 -0
- package/src/shaders/f64/utils/add.wgsl +6 -0
- package/src/shaders/f64/utils/divide.wgsl +45 -0
- package/src/shaders/f64/utils/multiply.wgsl +29 -11
- package/src/shaders/f64/utils/sqrt.wgsl +45 -0
- package/src/shaders/index.mjs +69 -0
- package/src/shaders/reduction/scaledSumF64.wgsl +93 -0
- package/src/snrm2/snrm2.mjs +20 -14
- package/src/srot/srot.mjs +10 -7
- package/src/srotm/srotm.mjs +9 -12
- package/src/sscal/sscal.mjs +7 -7
- package/src/sswap/sswap.mjs +14 -8
- package/src/ssymm/ssymm.d.mts +5 -4
- package/src/ssymm/ssymm.mjs +142 -55
- package/src/ssymv/ssymv.d.mts +2 -2
- package/src/ssymv/ssymv.mjs +42 -23
- package/src/ssyr/ssyr.d.mts +2 -2
- package/src/ssyr/ssyr.mjs +34 -15
- package/src/ssyr2/ssyr2.d.mts +2 -2
- package/src/ssyr2/ssyr2.mjs +43 -18
- package/src/ssyr2k/ssyr2k.d.mts +3 -2
- package/src/ssyr2k/ssyr2k.mjs +132 -55
- package/src/ssyrk/ssyrk.d.mts +3 -2
- package/src/ssyrk/ssyrk.mjs +84 -33
- package/src/strmm/strmm.d.mts +5 -4
- package/src/strmm/strmm.mjs +153 -54
- package/src/strmv/strmv.d.mts +2 -2
- package/src/strmv/strmv.mjs +37 -17
- package/src/strsm/strsm.d.mts +6 -4
- package/src/strsm/strsm.mjs +418 -172
- package/src/strsv/strsv.d.mts +5 -3
- package/src/strsv/strsv.mjs +82 -31
- package/src/util/benchmark.mjs +5 -3
- package/src/util/buffer.mjs +33 -12
- package/src/util/complex.mjs +87 -0
- package/src/util/compute.mjs +14 -8
- package/src/util/device.mjs +18 -3
- package/src/util/pipeline.mjs +40 -5
- package/src/util/workgroup.mjs +23 -6
- package/src/shaders/f64add.wgsl +0 -281
package/index.d.mts
CHANGED
|
@@ -3,23 +3,34 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { GpuVector } from "./src/classes/GpuVector.mjs";
|
|
5
5
|
export { GpuMatrix } from "./src/classes/GpuMatrix.mjs";
|
|
6
|
+
export { Complex32, Complex32Array } from "./src/classes/Complex32.mjs";
|
|
7
|
+
export { Complex64, Complex64Array } from "./src/classes/Complex64.mjs";
|
|
6
8
|
export {
|
|
7
9
|
randomFloat32Array,
|
|
8
10
|
randomFloat64Array,
|
|
9
11
|
randomTriangularFloat32Array,
|
|
10
12
|
} from "./src/random/random.mjs";
|
|
11
13
|
export { sscal } from "./src/sscal/sscal.mjs";
|
|
14
|
+
export { cscal } from "./src/cscal/cscal.mjs";
|
|
15
|
+
export { dscal } from "./src/dscal/dscal.mjs";
|
|
12
16
|
export { sswap } from "./src/sswap/sswap.mjs";
|
|
17
|
+
export { dswap } from "./src/dswap/dswap.mjs";
|
|
13
18
|
export { saxpy } from "./src/saxpy/saxpy.mjs";
|
|
19
|
+
export { daxpy } from "./src/daxpy/daxpy.mjs";
|
|
14
20
|
export { scopy } from "./src/scopy/scopy.mjs";
|
|
21
|
+
export { dcopy } from "./src/dcopy/dcopy.mjs";
|
|
15
22
|
export { sdot } from "./src/sdot/sdot.mjs";
|
|
16
23
|
export { sasum } from "./src/sasum/sasum.mjs";
|
|
17
24
|
export { dasum } from "./src/dasum/dasum.mjs";
|
|
25
|
+
export { ddot } from "./src/ddot/ddot.mjs";
|
|
18
26
|
export { snrm2 } from "./src/snrm2/snrm2.mjs";
|
|
27
|
+
export { dnrm2 } from "./src/dnrm2/dnrm2.mjs";
|
|
19
28
|
export { isamax } from "./src/isamax/isamax.mjs";
|
|
20
29
|
export { idamax } from "./src/idamax/idamax.mjs";
|
|
21
30
|
export { srot } from "./src/srot/srot.mjs";
|
|
31
|
+
export { drot } from "./src/drot/drot.mjs";
|
|
22
32
|
export { srotm } from "./src/srotm/srotm.mjs";
|
|
33
|
+
export { drotm } from "./src/drotm/drotm.mjs";
|
|
23
34
|
export { sgemv } from "./src/sgemv/sgemv.mjs";
|
|
24
35
|
export { ssymv } from "./src/ssymv/ssymv.mjs";
|
|
25
36
|
export { strmv } from "./src/strmv/strmv.mjs";
|
|
@@ -57,45 +68,17 @@ export { strsm } from "./src/strsm/strsm.mjs";
|
|
|
57
68
|
* whichever Dawn picked) to stderr as it compiles. A Dawn passthrough, not a wgblas format —
|
|
58
69
|
* no effect in the browser, which gives pages no API to request compiled shader IR (default: `false`)
|
|
59
70
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* import { init, gpuName } from "wgblas";
|
|
63
|
-
* await init();
|
|
64
|
-
* const { description, device } = gpuName();
|
|
65
|
-
* console.log("description:", description, "device:", device);
|
|
66
|
-
* ```
|
|
71
|
+
* **Default (high-performance GPU):**
|
|
72
|
+
* {@includeCode examples/init/init.js}
|
|
67
73
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* import { init, gpuName } from "wgblas";
|
|
71
|
-
* await init({ powerPreference: "low-power" });
|
|
72
|
-
* const { description, device } = gpuName();
|
|
73
|
-
* console.log("description:", description, "device:", device);
|
|
74
|
-
* ```
|
|
74
|
+
* **Low-power (integrated GPU):**
|
|
75
|
+
* {@includeCode examples/init-low-power/init-low-power.js}
|
|
75
76
|
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* const alpha = 2.0;
|
|
82
|
-
* const x = new Float32Array([1, 2, 3, 4, 5]);
|
|
83
|
-
* const { x: result, gpuTimeMs } = await sscal(device, n, alpha, x, 1);
|
|
84
|
-
* console.log(`Result: [${Array.from(result).join(", ")}]`);
|
|
85
|
-
* console.log(`GPU time: ${gpuTimeMs.toFixed(3)} ms`);
|
|
86
|
-
* ```
|
|
87
|
-
* @example Two GPUs at once
|
|
88
|
-
* ```js
|
|
89
|
-
* import { init, cleanup, gpuName, sscal } from "wgblas";
|
|
90
|
-
* const dGpu = await init({ powerPreference: "high-performance" });
|
|
91
|
-
* const iGpu = await init({ powerPreference: "low-power" });
|
|
92
|
-
* console.log(gpuName(dGpu).description, "and", gpuName(iGpu).description);
|
|
93
|
-
* const [a, b] = await Promise.all([
|
|
94
|
-
* sscal(dGpu, 4, 2, new Float32Array([1, 2, 3, 4]), 1),
|
|
95
|
-
* sscal(iGpu, 4, 5, new Float32Array([1, 2, 3, 4]), 1),
|
|
96
|
-
* ]);
|
|
97
|
-
* cleanup(); // releases both
|
|
98
|
-
* ```
|
|
77
|
+
* **Benchmark mode:**
|
|
78
|
+
* {@includeCode examples/init-benchmark/init-benchmark.js}
|
|
79
|
+
*
|
|
80
|
+
* **Two GPUs at once:**
|
|
81
|
+
* {@includeCode examples/init-two-gpus/init-two-gpus.js}
|
|
99
82
|
*
|
|
100
83
|
* @see [Source code: init.mjs](https://github.com/manit2004/wgblas/blob/main/src/init.mjs#L18-L54)
|
|
101
84
|
* @category Core
|
|
@@ -117,14 +100,7 @@ export declare function init(options?: {
|
|
|
117
100
|
*
|
|
118
101
|
* @param device - the device to release; omit to release all of them.
|
|
119
102
|
*
|
|
120
|
-
* @
|
|
121
|
-
* ```js
|
|
122
|
-
* import { init, cleanup, gpuName } from "wgblas";
|
|
123
|
-
*
|
|
124
|
-
* await init();
|
|
125
|
-
* console.log("GPU:", gpuName().description);
|
|
126
|
-
* if (typeof process !== "undefined") cleanup(); // Node.js only — browser cleanup is automatic
|
|
127
|
-
* ```
|
|
103
|
+
* {@includeCode examples/cleanup/cleanup.js}
|
|
128
104
|
* @see [Source code: init.mjs](https://github.com/manit2004/wgblas/blob/main/src/init.mjs#L56-L65)
|
|
129
105
|
* @category Core
|
|
130
106
|
*/
|
|
@@ -136,14 +112,11 @@ export declare function cleanup(device?: GPUDevice): void;
|
|
|
136
112
|
* @param device - which device to report on; defaults to the one from the first
|
|
137
113
|
* `init()` call. Pass it explicitly when driving more than one GPU.
|
|
138
114
|
*
|
|
139
|
-
* @
|
|
140
|
-
* ```js
|
|
141
|
-
* import { init, gpuName } from "wgblas";
|
|
142
|
-
* await init();
|
|
143
|
-
* const { description, device } = gpuName();
|
|
144
|
-
* console.log("description:", description, "device:", device);
|
|
145
|
-
* ```
|
|
115
|
+
* {@includeCode examples/init/init.js}
|
|
146
116
|
* @see [Source code: init.mjs](https://github.com/manit2004/wgblas/blob/main/src/init.mjs#L81-L87)
|
|
147
117
|
* @category Core
|
|
148
118
|
*/
|
|
149
|
-
export declare function gpuName(device?: GPUDevice): {
|
|
119
|
+
export declare function gpuName(device?: GPUDevice): {
|
|
120
|
+
description: string;
|
|
121
|
+
device: string;
|
|
122
|
+
};
|
package/index.mjs
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
export { init, cleanup, gpuName } from "./src/init.mjs";
|
|
2
2
|
export { GpuVector } from "./src/classes/GpuVector.mjs";
|
|
3
3
|
export { GpuMatrix } from "./src/classes/GpuMatrix.mjs";
|
|
4
|
+
export { Complex32, Complex32Array } from "./src/classes/Complex32.mjs";
|
|
5
|
+
export { Complex64, Complex64Array } from "./src/classes/Complex64.mjs";
|
|
4
6
|
export {
|
|
5
7
|
randomFloat32Array,
|
|
6
8
|
randomFloat64Array,
|
|
7
9
|
randomTriangularFloat32Array,
|
|
8
10
|
} from "./src/random/random.mjs";
|
|
9
11
|
export { sscal } from "./src/sscal/sscal.mjs";
|
|
12
|
+
export { cscal } from "./src/cscal/cscal.mjs";
|
|
13
|
+
export { dscal } from "./src/dscal/dscal.mjs";
|
|
10
14
|
export { sswap } from "./src/sswap/sswap.mjs";
|
|
15
|
+
export { dswap } from "./src/dswap/dswap.mjs";
|
|
11
16
|
export { saxpy } from "./src/saxpy/saxpy.mjs";
|
|
17
|
+
export { daxpy } from "./src/daxpy/daxpy.mjs";
|
|
12
18
|
export { scopy } from "./src/scopy/scopy.mjs";
|
|
19
|
+
export { dcopy } from "./src/dcopy/dcopy.mjs";
|
|
13
20
|
export { sdot } from "./src/sdot/sdot.mjs";
|
|
14
21
|
export { sasum } from "./src/sasum/sasum.mjs";
|
|
15
22
|
export { dasum } from "./src/dasum/dasum.mjs";
|
|
23
|
+
export { ddot } from "./src/ddot/ddot.mjs";
|
|
16
24
|
export { snrm2 } from "./src/snrm2/snrm2.mjs";
|
|
25
|
+
export { dnrm2 } from "./src/dnrm2/dnrm2.mjs";
|
|
17
26
|
export { isamax } from "./src/isamax/isamax.mjs";
|
|
18
27
|
export { idamax } from "./src/idamax/idamax.mjs";
|
|
19
28
|
export { srot } from "./src/srot/srot.mjs";
|
|
29
|
+
export { drot } from "./src/drot/drot.mjs";
|
|
20
30
|
export { srotm } from "./src/srotm/srotm.mjs";
|
|
31
|
+
export { drotm } from "./src/drotm/drotm.mjs";
|
|
21
32
|
export { sgemv } from "./src/sgemv/sgemv.mjs";
|
|
22
33
|
export { ssymv } from "./src/ssymv/ssymv.mjs";
|
|
23
34
|
export { strmv } from "./src/strmv/strmv.mjs";
|
package/package.json
CHANGED
|
@@ -1,131 +1,175 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wgblas",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "BLAS on WebGPU",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.mjs",
|
|
7
7
|
"types": "./index.d.mts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"types": "./index.d.mts",
|
|
11
|
+
"import": "./index.mjs"
|
|
12
12
|
},
|
|
13
13
|
"./browser": "./dist/wgblas.browser.js",
|
|
14
14
|
"./classes/GpuVector": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"types": "./src/classes/GpuVector.d.mts",
|
|
16
|
+
"import": "./src/classes/GpuVector.mjs"
|
|
17
17
|
},
|
|
18
18
|
"./classes/GpuMatrix": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"types": "./src/classes/GpuMatrix.d.mts",
|
|
20
|
+
"import": "./src/classes/GpuMatrix.mjs"
|
|
21
|
+
},
|
|
22
|
+
"./classes/Complex32": {
|
|
23
|
+
"types": "./src/classes/Complex32.d.mts",
|
|
24
|
+
"import": "./src/classes/Complex32.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./classes/Complex64": {
|
|
27
|
+
"types": "./src/classes/Complex64.d.mts",
|
|
28
|
+
"import": "./src/classes/Complex64.mjs"
|
|
21
29
|
},
|
|
22
30
|
"./random": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
31
|
+
"types": "./src/random/random.d.mts",
|
|
32
|
+
"import": "./src/random/random.mjs"
|
|
25
33
|
},
|
|
26
34
|
"./sscal": {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
35
|
+
"types": "./src/sscal/sscal.d.mts",
|
|
36
|
+
"import": "./src/sscal/sscal.mjs"
|
|
37
|
+
},
|
|
38
|
+
"./cscal": {
|
|
39
|
+
"types": "./src/cscal/cscal.d.mts",
|
|
40
|
+
"import": "./src/cscal/cscal.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./dscal": {
|
|
43
|
+
"types": "./src/dscal/dscal.d.mts",
|
|
44
|
+
"import": "./src/dscal/dscal.mjs"
|
|
29
45
|
},
|
|
30
46
|
"./sswap": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
47
|
+
"types": "./src/sswap/sswap.d.mts",
|
|
48
|
+
"import": "./src/sswap/sswap.mjs"
|
|
49
|
+
},
|
|
50
|
+
"./dswap": {
|
|
51
|
+
"types": "./src/dswap/dswap.d.mts",
|
|
52
|
+
"import": "./src/dswap/dswap.mjs"
|
|
33
53
|
},
|
|
34
54
|
"./saxpy": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
55
|
+
"types": "./src/saxpy/saxpy.d.mts",
|
|
56
|
+
"import": "./src/saxpy/saxpy.mjs"
|
|
57
|
+
},
|
|
58
|
+
"./daxpy": {
|
|
59
|
+
"types": "./src/daxpy/daxpy.d.mts",
|
|
60
|
+
"import": "./src/daxpy/daxpy.mjs"
|
|
37
61
|
},
|
|
38
62
|
"./scopy": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
63
|
+
"types": "./src/scopy/scopy.d.mts",
|
|
64
|
+
"import": "./src/scopy/scopy.mjs"
|
|
65
|
+
},
|
|
66
|
+
"./dcopy": {
|
|
67
|
+
"types": "./src/dcopy/dcopy.d.mts",
|
|
68
|
+
"import": "./src/dcopy/dcopy.mjs"
|
|
41
69
|
},
|
|
42
70
|
"./sdot": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
71
|
+
"types": "./src/sdot/sdot.d.mts",
|
|
72
|
+
"import": "./src/sdot/sdot.mjs"
|
|
45
73
|
},
|
|
46
74
|
"./sasum": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
75
|
+
"types": "./src/sasum/sasum.d.mts",
|
|
76
|
+
"import": "./src/sasum/sasum.mjs"
|
|
49
77
|
},
|
|
50
78
|
"./dasum": {
|
|
51
|
-
"
|
|
52
|
-
"
|
|
79
|
+
"types": "./src/dasum/dasum.d.mts",
|
|
80
|
+
"import": "./src/dasum/dasum.mjs"
|
|
81
|
+
},
|
|
82
|
+
"./ddot": {
|
|
83
|
+
"types": "./src/ddot/ddot.d.mts",
|
|
84
|
+
"import": "./src/ddot/ddot.mjs"
|
|
53
85
|
},
|
|
54
86
|
"./snrm2": {
|
|
55
|
-
"
|
|
56
|
-
"
|
|
87
|
+
"types": "./src/snrm2/snrm2.d.mts",
|
|
88
|
+
"import": "./src/snrm2/snrm2.mjs"
|
|
89
|
+
},
|
|
90
|
+
"./dnrm2": {
|
|
91
|
+
"types": "./src/dnrm2/dnrm2.d.mts",
|
|
92
|
+
"import": "./src/dnrm2/dnrm2.mjs"
|
|
57
93
|
},
|
|
58
94
|
"./isamax": {
|
|
59
|
-
"
|
|
60
|
-
"
|
|
95
|
+
"types": "./src/isamax/isamax.d.mts",
|
|
96
|
+
"import": "./src/isamax/isamax.mjs"
|
|
61
97
|
},
|
|
62
98
|
"./idamax": {
|
|
63
|
-
"
|
|
64
|
-
"
|
|
99
|
+
"types": "./src/idamax/idamax.d.mts",
|
|
100
|
+
"import": "./src/idamax/idamax.mjs"
|
|
65
101
|
},
|
|
66
102
|
"./srot": {
|
|
67
|
-
"
|
|
68
|
-
"
|
|
103
|
+
"types": "./src/srot/srot.d.mts",
|
|
104
|
+
"import": "./src/srot/srot.mjs"
|
|
105
|
+
},
|
|
106
|
+
"./drot": {
|
|
107
|
+
"types": "./src/drot/drot.d.mts",
|
|
108
|
+
"import": "./src/drot/drot.mjs"
|
|
69
109
|
},
|
|
70
110
|
"./srotm": {
|
|
71
|
-
"
|
|
72
|
-
"
|
|
111
|
+
"types": "./src/srotm/srotm.d.mts",
|
|
112
|
+
"import": "./src/srotm/srotm.mjs"
|
|
113
|
+
},
|
|
114
|
+
"./drotm": {
|
|
115
|
+
"types": "./src/drotm/drotm.d.mts",
|
|
116
|
+
"import": "./src/drotm/drotm.mjs"
|
|
73
117
|
},
|
|
74
118
|
"./sgemv": {
|
|
75
|
-
"
|
|
76
|
-
"
|
|
119
|
+
"types": "./src/sgemv/sgemv.d.mts",
|
|
120
|
+
"import": "./src/sgemv/sgemv.mjs"
|
|
77
121
|
},
|
|
78
122
|
"./ssymv": {
|
|
79
|
-
"
|
|
80
|
-
"
|
|
123
|
+
"types": "./src/ssymv/ssymv.d.mts",
|
|
124
|
+
"import": "./src/ssymv/ssymv.mjs"
|
|
81
125
|
},
|
|
82
126
|
"./strmv": {
|
|
83
|
-
"
|
|
84
|
-
"
|
|
127
|
+
"types": "./src/strmv/strmv.d.mts",
|
|
128
|
+
"import": "./src/strmv/strmv.mjs"
|
|
85
129
|
},
|
|
86
130
|
"./strsv": {
|
|
87
|
-
"
|
|
88
|
-
"
|
|
131
|
+
"types": "./src/strsv/strsv.d.mts",
|
|
132
|
+
"import": "./src/strsv/strsv.mjs"
|
|
89
133
|
},
|
|
90
134
|
"./sger": {
|
|
91
|
-
"
|
|
92
|
-
"
|
|
135
|
+
"types": "./src/sger/sger.d.mts",
|
|
136
|
+
"import": "./src/sger/sger.mjs"
|
|
93
137
|
},
|
|
94
138
|
"./ssyr": {
|
|
95
|
-
"
|
|
96
|
-
"
|
|
139
|
+
"types": "./src/ssyr/ssyr.d.mts",
|
|
140
|
+
"import": "./src/ssyr/ssyr.mjs"
|
|
97
141
|
},
|
|
98
142
|
"./ssyr2": {
|
|
99
|
-
"
|
|
100
|
-
"
|
|
143
|
+
"types": "./src/ssyr2/ssyr2.d.mts",
|
|
144
|
+
"import": "./src/ssyr2/ssyr2.mjs"
|
|
101
145
|
},
|
|
102
146
|
"./sgemm": {
|
|
103
|
-
"
|
|
104
|
-
"
|
|
147
|
+
"types": "./src/sgemm/sgemm.d.mts",
|
|
148
|
+
"import": "./src/sgemm/sgemm.mjs"
|
|
105
149
|
},
|
|
106
150
|
"./sgemmtr": {
|
|
107
|
-
"
|
|
108
|
-
"
|
|
151
|
+
"types": "./src/sgemmtr/sgemmtr.d.mts",
|
|
152
|
+
"import": "./src/sgemmtr/sgemmtr.mjs"
|
|
109
153
|
},
|
|
110
154
|
"./ssyrk": {
|
|
111
|
-
"
|
|
112
|
-
"
|
|
155
|
+
"types": "./src/ssyrk/ssyrk.d.mts",
|
|
156
|
+
"import": "./src/ssyrk/ssyrk.mjs"
|
|
113
157
|
},
|
|
114
158
|
"./ssyr2k": {
|
|
115
|
-
"
|
|
116
|
-
"
|
|
159
|
+
"types": "./src/ssyr2k/ssyr2k.d.mts",
|
|
160
|
+
"import": "./src/ssyr2k/ssyr2k.mjs"
|
|
117
161
|
},
|
|
118
162
|
"./ssymm": {
|
|
119
|
-
"
|
|
120
|
-
"
|
|
163
|
+
"types": "./src/ssymm/ssymm.d.mts",
|
|
164
|
+
"import": "./src/ssymm/ssymm.mjs"
|
|
121
165
|
},
|
|
122
166
|
"./strmm": {
|
|
123
|
-
"
|
|
124
|
-
"
|
|
167
|
+
"types": "./src/strmm/strmm.d.mts",
|
|
168
|
+
"import": "./src/strmm/strmm.mjs"
|
|
125
169
|
},
|
|
126
170
|
"./strsm": {
|
|
127
|
-
"
|
|
128
|
-
"
|
|
171
|
+
"types": "./src/strsm/strsm.d.mts",
|
|
172
|
+
"import": "./src/strsm/strsm.mjs"
|
|
129
173
|
}
|
|
130
174
|
},
|
|
131
175
|
"files": [
|
|
@@ -179,7 +223,18 @@
|
|
|
179
223
|
"@commitlint/cli": "^21.2.1",
|
|
180
224
|
"@commitlint/config-conventional": "^21.2.0",
|
|
181
225
|
"@eslint/js": "^10.0.1",
|
|
226
|
+
"@size-limit/file": "^13.0.3",
|
|
227
|
+
"@stdlib/array-complex64": "^0.3.2",
|
|
228
|
+
"@stdlib/blas-base-cscal": "^0.1.1",
|
|
182
229
|
"@stdlib/blas-base-dasum": "^0.4.1",
|
|
230
|
+
"@stdlib/blas-base-daxpy": "^0.4.1",
|
|
231
|
+
"@stdlib/blas-base-dcopy": "^0.4.1",
|
|
232
|
+
"@stdlib/blas-base-ddot": "^0.4.1",
|
|
233
|
+
"@stdlib/blas-base-dnrm2": "^0.4.1",
|
|
234
|
+
"@stdlib/blas-base-drot": "^0.1.1",
|
|
235
|
+
"@stdlib/blas-base-drotm": "^0.2.1",
|
|
236
|
+
"@stdlib/blas-base-dscal": "^0.4.1",
|
|
237
|
+
"@stdlib/blas-base-dswap": "^0.4.1",
|
|
183
238
|
"@stdlib/blas-base-idamax": "^0.1.1",
|
|
184
239
|
"@stdlib/blas-base-isamax": "^0.1.1",
|
|
185
240
|
"@stdlib/blas-base-sasum": "^0.3.1",
|
|
@@ -199,8 +254,10 @@
|
|
|
199
254
|
"@stdlib/blas-base-ssyr2": "^0.1.1",
|
|
200
255
|
"@stdlib/blas-base-strmv": "^0.1.0",
|
|
201
256
|
"@stdlib/blas-base-strsv": "^0.1.1",
|
|
257
|
+
"@stdlib/complex-float32-ctor": "^0.1.1",
|
|
202
258
|
"@stdlib/random-array-uniform": "^0.2.2",
|
|
203
259
|
"@stdlib/random-base-uniform": "^0.2.3",
|
|
260
|
+
"c8": "^12.0.0",
|
|
204
261
|
"esbuild": "^0.28.1",
|
|
205
262
|
"eslint": "^10.6.0",
|
|
206
263
|
"fast-check": "^4.8.0",
|
|
@@ -208,6 +265,8 @@
|
|
|
208
265
|
"husky": "^9.1.7",
|
|
209
266
|
"lint-staged": "^17.0.8",
|
|
210
267
|
"prettier": "^3.9.4",
|
|
268
|
+
"publint": "^0.3.24",
|
|
269
|
+
"size-limit": "^13.0.3",
|
|
211
270
|
"typedoc": "^0.28.19",
|
|
212
271
|
"typedoc-plugin-katex": "^0.1.2",
|
|
213
272
|
"typescript": "^6.0.3",
|
|
@@ -217,12 +276,22 @@
|
|
|
217
276
|
"prepare": "husky",
|
|
218
277
|
"build:browser": "node scripts/build-browser.mjs",
|
|
219
278
|
"docs": "npx typedoc && npm run build:browser",
|
|
220
|
-
"prepublishOnly": "npm run build:browser"
|
|
279
|
+
"prepublishOnly": "npm run build:browser",
|
|
280
|
+
"coverage": "c8 --reporter=text --reporter=html node --test $(find tests \\( -name 'test.*.js' -o -name 'gpustorage.*.js' \\))",
|
|
281
|
+
"cpd": "jscpd src",
|
|
282
|
+
"size": "npm run build:browser && size-limit"
|
|
221
283
|
},
|
|
222
284
|
"lint-staged": {
|
|
223
285
|
"*.{js,mjs,cjs}": [
|
|
224
286
|
"prettier --write",
|
|
225
287
|
"eslint"
|
|
226
288
|
]
|
|
227
|
-
}
|
|
289
|
+
},
|
|
290
|
+
"size-limit": [
|
|
291
|
+
{
|
|
292
|
+
"name": "browser bundle (brotli)",
|
|
293
|
+
"path": "dist/wgblas.browser.js",
|
|
294
|
+
"limit": "50 KB"
|
|
295
|
+
}
|
|
296
|
+
]
|
|
228
297
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single 32-bit (f32) complex number: a real and an imaginary component.
|
|
3
|
+
* JavaScript has no native complex number type, so this is the value type
|
|
4
|
+
* every complex routine in this library builds on.
|
|
5
|
+
*
|
|
6
|
+
* @see <a href="https://github.com/manit2004/wgblas/blob/main/src/classes/Complex32.mjs#L8">Source code: Complex32.mjs (L8)</a>
|
|
7
|
+
* @category Classes
|
|
8
|
+
*/
|
|
9
|
+
export declare class Complex32 {
|
|
10
|
+
/**
|
|
11
|
+
* @param re - real component, rounded to the nearest f32
|
|
12
|
+
* @param im - imaginary component, rounded to the nearest f32
|
|
13
|
+
*
|
|
14
|
+
* {@includeCode ../../examples/complex32/complex32.js}
|
|
15
|
+
*/
|
|
16
|
+
constructor(re: number, im: number);
|
|
17
|
+
|
|
18
|
+
/** Real component (f32-rounded via `Math.fround`). */
|
|
19
|
+
re: number;
|
|
20
|
+
|
|
21
|
+
/** Imaginary component (f32-rounded via `Math.fround`). */
|
|
22
|
+
im: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* An array of Complex32 values — array-of-structs, each element its own
|
|
27
|
+
* independent Complex32 instance (as opposed to a struct-of-arrays layout
|
|
28
|
+
* with separate re/im buffers). Extends the native Array, so indexing
|
|
29
|
+
* (`arr[i]`), `.length`, iteration, `.map`, etc. all work as expected.
|
|
30
|
+
*
|
|
31
|
+
* @see <a href="https://github.com/manit2004/wgblas/blob/main/src/classes/Complex32.mjs#L38">Source code: Complex32.mjs (L38)</a>
|
|
32
|
+
* @category Classes
|
|
33
|
+
*/
|
|
34
|
+
export declare class Complex32Array extends Array<Complex32> {
|
|
35
|
+
/**
|
|
36
|
+
* @param arg - a length (fills with that many zero-valued Complex32
|
|
37
|
+
* entries), a flat interleaved `[re, im, re, im, ...]` list of numbers,
|
|
38
|
+
* or an iterable of existing Complex32 instances to copy
|
|
39
|
+
*
|
|
40
|
+
* {@includeCode ../../examples/complex32array/complex32array.js}
|
|
41
|
+
*/
|
|
42
|
+
constructor(arg?: number | Iterable<number> | Iterable<Complex32>);
|
|
43
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** @module devdocs/classes/Complex32 */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A single 32-bit (f32) complex number: a real and an imaginary component.
|
|
5
|
+
* JavaScript has no native complex number type, so this is the value type
|
|
6
|
+
* every complex routine in this library builds on.
|
|
7
|
+
*/
|
|
8
|
+
export class Complex32 {
|
|
9
|
+
/**
|
|
10
|
+
* @param {number} re - real component, rounded to the nearest f32 (same
|
|
11
|
+
* `Math.fround` truncation splitDoubleDouble uses for f64 emulation) —
|
|
12
|
+
* a plain JS number is an f64, and "32" in Complex32 means each
|
|
13
|
+
* component is genuinely f32-precision, not just f64 stored in an
|
|
14
|
+
* f32-sized slot
|
|
15
|
+
* @param {number} im - imaginary component, rounded to the nearest f32
|
|
16
|
+
*/
|
|
17
|
+
constructor(re, im) {
|
|
18
|
+
this.re = Math.fround(re);
|
|
19
|
+
this.im = Math.fround(im);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* An array of Complex32 values — array-of-structs, each element its own
|
|
25
|
+
* independent Complex32 instance (as opposed to a struct-of-arrays layout
|
|
26
|
+
* with separate re/im buffers). Extends the native Array so indexing
|
|
27
|
+
* (`arr[i]`), `.length`, iteration, `.map`, etc. all work as expected.
|
|
28
|
+
*
|
|
29
|
+
* Mirrors @stdlib/array-complex64's constructor overloads (minus the
|
|
30
|
+
* ArrayBuffer-view form, which needs a flat backing buffer — incompatible
|
|
31
|
+
* with storing genuine Complex32 instances one per slot):
|
|
32
|
+
*
|
|
33
|
+
* new Complex32Array() // empty
|
|
34
|
+
* new Complex32Array(length) // length zero-valued entries
|
|
35
|
+
* new Complex32Array([1, 5, 3, 8]) // flat [re, im, re, im, ...] pairs
|
|
36
|
+
* new Complex32Array([z1, z2]) // copies existing Complex32 instances
|
|
37
|
+
*/
|
|
38
|
+
export class Complex32Array extends Array {
|
|
39
|
+
/**
|
|
40
|
+
* @param {number|Iterable<number>|Iterable<Complex32>} [arg] - a length,
|
|
41
|
+
* a flat interleaved [re, im, ...] list of numbers, or an iterable of
|
|
42
|
+
* existing Complex32 instances
|
|
43
|
+
*/
|
|
44
|
+
constructor(arg) {
|
|
45
|
+
if (arg === undefined) {
|
|
46
|
+
super();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (typeof arg === "number") {
|
|
50
|
+
super(arg);
|
|
51
|
+
for (let i = 0; i < arg; i++) this[i] = new Complex32(0, 0);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const items = Array.from(arg);
|
|
56
|
+
super();
|
|
57
|
+
if (items.length === 0) return;
|
|
58
|
+
|
|
59
|
+
if (items[0] instanceof Complex32) {
|
|
60
|
+
for (const z of items) {
|
|
61
|
+
if (!(z instanceof Complex32))
|
|
62
|
+
throw new Error(
|
|
63
|
+
"Complex32Array expects every element to be a Complex32.",
|
|
64
|
+
);
|
|
65
|
+
this.push(z);
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (items.length % 2 !== 0)
|
|
71
|
+
throw new Error(
|
|
72
|
+
"Complex32Array expects an even number of interleaved [re, im, ...] values.",
|
|
73
|
+
);
|
|
74
|
+
for (let i = 0; i < items.length; i += 2) {
|
|
75
|
+
if (typeof items[i] !== "number" || typeof items[i + 1] !== "number")
|
|
76
|
+
throw new Error(
|
|
77
|
+
"Complex32Array expects interleaved [re, im, ...] values to be numbers.",
|
|
78
|
+
);
|
|
79
|
+
this.push(new Complex32(items[i], items[i + 1]));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single 64-bit (f64) complex number: a real and an imaginary component.
|
|
3
|
+
* Same shape as Complex32, with one deliberate difference: no f32 rounding
|
|
4
|
+
* — a plain JS number already is an f64, so re/im are kept at their full
|
|
5
|
+
* native double precision.
|
|
6
|
+
*
|
|
7
|
+
* @see <a href="https://github.com/manit2004/wgblas/blob/main/src/classes/Complex64.mjs#L11">Source code: Complex64.mjs (L11)</a>
|
|
8
|
+
* @category Classes
|
|
9
|
+
*/
|
|
10
|
+
export declare class Complex64 {
|
|
11
|
+
/**
|
|
12
|
+
* @param re - real component, full f64 precision
|
|
13
|
+
* @param im - imaginary component, full f64 precision
|
|
14
|
+
*
|
|
15
|
+
* {@includeCode ../../examples/complex64/complex64.js}
|
|
16
|
+
*/
|
|
17
|
+
constructor(re: number, im: number);
|
|
18
|
+
|
|
19
|
+
/** Real component (full f64 precision). */
|
|
20
|
+
re: number;
|
|
21
|
+
|
|
22
|
+
/** Imaginary component (full f64 precision). */
|
|
23
|
+
im: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An array of Complex64 values — array-of-structs, the f64 sibling of
|
|
28
|
+
* Complex32Array (same overloads, same interleaved-pairs convention),
|
|
29
|
+
* backed by full-precision Complex64 elements instead of f32-rounded
|
|
30
|
+
* Complex32 ones.
|
|
31
|
+
*
|
|
32
|
+
* @see <a href="https://github.com/manit2004/wgblas/blob/main/src/classes/Complex64.mjs#L34">Source code: Complex64.mjs (L34)</a>
|
|
33
|
+
* @category Classes
|
|
34
|
+
*/
|
|
35
|
+
export declare class Complex64Array extends Array<Complex64> {
|
|
36
|
+
/**
|
|
37
|
+
* @param arg - a length (fills with that many zero-valued Complex64
|
|
38
|
+
* entries), a flat interleaved `[re, im, re, im, ...]` list of numbers,
|
|
39
|
+
* or an iterable of existing Complex64 instances to copy
|
|
40
|
+
*
|
|
41
|
+
* {@includeCode ../../examples/complex64array/complex64array.js}
|
|
42
|
+
*/
|
|
43
|
+
constructor(arg?: number | Iterable<number> | Iterable<Complex64>);
|
|
44
|
+
}
|