@danielsimonjr/mathts-matrix 0.1.12 → 0.1.13
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/dist/index.d.ts +29 -55
- package/dist/index.js +636 -331
- package/dist/wasm/mathts-as.wasm +0 -0
- package/dist/wasm/wasm-manifest.json +1 -1
- package/package.json +1 -1
- package/dist/chunk-JRSQE7LB.js +0 -607
- package/dist/eig-PIFFHFJF.js +0 -11
package/dist/index.d.ts
CHANGED
|
@@ -1216,6 +1216,13 @@ declare class WASMBackend implements MatrixBackend {
|
|
|
1216
1216
|
* tests and multiple backend instances can coexist in the same process.
|
|
1217
1217
|
*/
|
|
1218
1218
|
private loadAsModule;
|
|
1219
|
+
/**
|
|
1220
|
+
* WASM is only worth its copy/alloc overhead for compute-dense ops. The 2026-07-01
|
|
1221
|
+
* backend audit (`tools/benchmarks/backend-audit`) measured element-wise / transpose
|
|
1222
|
+
* ops 4–6× SLOWER on WASM than JS (memory-bound; the SIMD matmul kernel is the only
|
|
1223
|
+
* clear win, 9–12×). So WASM is reserved for `opKind: 'matmul'`; everything else stays
|
|
1224
|
+
* on JS via each method's existing `jsBackend` fallback.
|
|
1225
|
+
*/
|
|
1219
1226
|
private shouldUseWasm;
|
|
1220
1227
|
getFeatures(): WasmFeatures | null;
|
|
1221
1228
|
add(a: DenseMatrix, b: DenseMatrix): DenseMatrix;
|
|
@@ -2513,62 +2520,34 @@ declare function norm2(matrix: number[][], options?: SVDOptions): number;
|
|
|
2513
2520
|
declare function normFro(matrix: number[][]): number;
|
|
2514
2521
|
|
|
2515
2522
|
/**
|
|
2516
|
-
*
|
|
2517
|
-
*
|
|
2518
|
-
* Provides eigenvalue/eigenvector computation with optional WASM acceleration
|
|
2519
|
-
* via the AssemblyScript-compiled Jacobi eigenvalue algorithm. Falls back to the pure
|
|
2520
|
-
* JavaScript QR-based implementation when WASM is unavailable.
|
|
2523
|
+
* `eigWasm` / `eigvalsWasm` / `spectralRadiusWasm` — thin wrappers kept for API
|
|
2524
|
+
* compatibility (consumed by `tensor` and `linalg`).
|
|
2521
2525
|
*
|
|
2522
|
-
* WASM
|
|
2523
|
-
*
|
|
2524
|
-
*
|
|
2525
|
-
*
|
|
2526
|
-
*
|
|
2527
|
-
*
|
|
2528
|
-
*
|
|
2529
|
-
* JS fallback path (wasm unavailable, n < threshold, or missing export):
|
|
2530
|
-
* - Full QR algorithm with implicit shifts (eig.ts)
|
|
2531
|
-
*
|
|
2532
|
-
* Packing of the AS return values (both decoded via `readReturnedFloat64Array`):
|
|
2533
|
-
* - matrix_eig_symmetric: `[ eigenvalues(n) | eigenvectors(n*n) ]`
|
|
2534
|
-
* - matrix_eig_general: `[ re(n) | im(n) | eigenvectors(n*n) ]`
|
|
2535
|
-
* Eigenvectors are stored as COLUMNS (`V[i*n+j]` = component `i` of
|
|
2536
|
-
* eigenvector `j`). Complex-eigenvalue columns are zero (the real `number[][]`
|
|
2537
|
-
* vector contract cannot represent complex eigenvectors).
|
|
2526
|
+
* The WASM eig path was RETIRED and REMOVED (2026-07-01): the AssemblyScript Jacobi
|
|
2527
|
+
* (symmetric) / Hessenberg+Francis (general) kernels were scalar + async and measured
|
|
2528
|
+
* 0.2–0.7× of the pure-JS path, worsening with size (~5× slower at 128²) — see
|
|
2529
|
+
* `tools/benchmarks/decomp-audit`. Since a genuinely fast version would be a from-scratch
|
|
2530
|
+
* SIMD implementation (not the removed scalar code), these now simply delegate to the
|
|
2531
|
+
* synchronous JS `eig` / `eigvals` / `powerIteration`. The `async` signature is retained so
|
|
2532
|
+
* existing callers (which `await`) are unaffected.
|
|
2538
2533
|
*
|
|
2539
2534
|
* @packageDocumentation
|
|
2540
2535
|
*/
|
|
2541
2536
|
|
|
2542
2537
|
/**
|
|
2543
|
-
* WASM
|
|
2544
|
-
*
|
|
2545
|
-
* Uses the AssemblyScript Jacobi eigenvalue algorithm when WASM is loaded,
|
|
2546
|
-
* otherwise falls back to the JavaScript QR algorithm.
|
|
2547
|
-
*
|
|
2548
|
-
* @param matrix - Square matrix as 2D array
|
|
2549
|
-
* @param options - Computation options
|
|
2550
|
-
* @returns Eigenvalues and eigenvectors
|
|
2538
|
+
* Eigendecomposition. Delegates to the JS {@link eig} (WASM path retired — see file header).
|
|
2551
2539
|
*/
|
|
2552
2540
|
declare function eigWasm(matrix: number[][], options?: EigOptions): Promise<EigResult>;
|
|
2553
2541
|
/**
|
|
2554
|
-
*
|
|
2555
|
-
* Faster than full eigWasm when only eigenvalues are needed.
|
|
2556
|
-
*
|
|
2557
|
-
* @param matrix - Square matrix as 2D array
|
|
2558
|
-
* @param options - Computation options (computeVectors is ignored)
|
|
2559
|
-
* @returns Array of eigenvalues
|
|
2542
|
+
* Eigenvalues only. Delegates to the JS {@link eigvals} (WASM path retired).
|
|
2560
2543
|
*/
|
|
2561
2544
|
declare function eigvalsWasm(matrix: number[][], options?: Omit<EigOptions, 'computeVectors'>): Promise<Array<{
|
|
2562
2545
|
re: number;
|
|
2563
2546
|
im: number;
|
|
2564
2547
|
}>>;
|
|
2565
2548
|
/**
|
|
2566
|
-
*
|
|
2567
|
-
*
|
|
2568
|
-
*
|
|
2569
|
-
* @param matrix - Square matrix as 2D array
|
|
2570
|
-
* @param options - Iteration options
|
|
2571
|
-
* @returns Spectral radius (absolute value of largest eigenvalue)
|
|
2549
|
+
* Spectral radius (|largest eigenvalue|). Delegates to the JS {@link powerIteration}
|
|
2550
|
+
* (WASM path retired).
|
|
2572
2551
|
*/
|
|
2573
2552
|
declare function spectralRadiusWasm(matrix: number[][], options?: {
|
|
2574
2553
|
maxIterations?: number;
|
|
@@ -2576,26 +2555,21 @@ declare function spectralRadiusWasm(matrix: number[][], options?: {
|
|
|
2576
2555
|
}): Promise<number>;
|
|
2577
2556
|
|
|
2578
2557
|
/**
|
|
2579
|
-
*
|
|
2580
|
-
*
|
|
2581
|
-
* Routes through the AssemblyScript binary's one-sided Jacobi SVD
|
|
2582
|
-
* (`matrix_svd` export, `assembly/src/ops/svd.ts`) for any real `m x n`
|
|
2583
|
-
* matrix, and falls back to the synchronous JavaScript Golub-Reinsch
|
|
2584
|
-
* {@link svd} when the WASM module is unavailable. (Phase 7b: repointed onto
|
|
2585
|
-
* the AssemblyScript binary; singular values are bit-identical to the JS
|
|
2586
|
-
* reference per the 7a parity validation.)
|
|
2558
|
+
* `svdWasm` — thin wrapper kept for API compatibility (consumed by `tensor` and `linalg`).
|
|
2587
2559
|
*
|
|
2588
|
-
*
|
|
2589
|
-
*
|
|
2590
|
-
*
|
|
2591
|
-
*
|
|
2560
|
+
* The WASM SVD path was RETIRED and REMOVED (2026-07-01): the AssemblyScript one-sided
|
|
2561
|
+
* Jacobi kernel was scalar + async and measured 0.4–0.7× of the pure-JS Golub-Reinsch
|
|
2562
|
+
* {@link svd}, worsening with size — see `tools/benchmarks/decomp-audit`. It now delegates
|
|
2563
|
+
* to the JS `svd`, truncated to the **thin / economy** form (`U` is `m×k`, `V` is `n×k`,
|
|
2564
|
+
* `k = min(m, n)`) so the result shape is unchanged. The `async` signature is retained so
|
|
2565
|
+
* existing callers (which `await`) are unaffected.
|
|
2592
2566
|
*
|
|
2593
2567
|
* @packageDocumentation
|
|
2594
2568
|
*/
|
|
2595
2569
|
|
|
2596
2570
|
/**
|
|
2597
|
-
*
|
|
2598
|
-
*
|
|
2571
|
+
* Thin SVD. Delegates to the JS {@link svd} and truncates to the economy form
|
|
2572
|
+
* (WASM path retired — see file header).
|
|
2599
2573
|
*
|
|
2600
2574
|
* @param matrix - Input matrix (m x n) as a row-major 2D array
|
|
2601
2575
|
* @param options - SVD options; `rankTolerance` controls the rank estimate
|