@danielsimonjr/mathts-matrix 0.1.8 → 0.1.10
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 +1 -1
- package/dist/chunk-HT4ZF3LN.js +886 -0
- package/dist/{eig-A5GJGSJJ.js → eig-G72TLEBA.js} +1 -1
- package/dist/index.d.ts +42 -337
- package/dist/index.js +192 -1190
- package/dist/wasm/mathts-as.wasm +0 -0
- package/dist/wasm/wasm-manifest.json +1 -1
- package/package.json +61 -61
- package/dist/chunk-VCPLE6ED.js +0 -473
package/dist/index.d.ts
CHANGED
|
@@ -629,7 +629,7 @@ declare function isSparseMatrix(value: unknown): value is SparseMatrix;
|
|
|
629
629
|
/**
|
|
630
630
|
* Backend type identifier
|
|
631
631
|
*/
|
|
632
|
-
type BackendType = 'js' | 'wasm' | '
|
|
632
|
+
type BackendType = 'js' | 'wasm' | 'gpu' | 'parallel';
|
|
633
633
|
/**
|
|
634
634
|
* Backend selection hints
|
|
635
635
|
*/
|
|
@@ -892,7 +892,7 @@ declare module 'workerpool' {
|
|
|
892
892
|
debugPortStart?: number;
|
|
893
893
|
}
|
|
894
894
|
|
|
895
|
-
export interface WorkerpoolPromise<T
|
|
895
|
+
export interface WorkerpoolPromise<T> extends Promise<T> {
|
|
896
896
|
readonly resolved: boolean;
|
|
897
897
|
readonly rejected: boolean;
|
|
898
898
|
readonly pending: boolean;
|
|
@@ -1142,13 +1142,14 @@ declare function getCachedFeatures(): WasmFeatures | null;
|
|
|
1142
1142
|
* 5. Copy caller data into the buffer
|
|
1143
1143
|
* 6. `__unpin(buffer)` — the header now owns the buffer reference
|
|
1144
1144
|
*
|
|
1145
|
-
* The
|
|
1146
|
-
* ABI (camelCase exports, flat-memory raw pointers)
|
|
1147
|
-
*
|
|
1145
|
+
* The legacy artifact had no managed runtime and used a completely
|
|
1146
|
+
* different ABI (camelCase exports, flat-memory raw pointers). It was
|
|
1147
|
+
* retired in Phase 7b; the AssemblyScript binary is now the only WASM
|
|
1148
|
+
* backend.
|
|
1148
1149
|
*
|
|
1149
|
-
* Naming map (
|
|
1150
|
+
* Naming map (legacy backend ↔ AssemblyScript) — kept for historical reference:
|
|
1150
1151
|
*
|
|
1151
|
-
* Op
|
|
1152
|
+
* Op Legacy (camelCase, flat ptrs) AS (snake_case, header refs)
|
|
1152
1153
|
* ------------------ --------------------------------- -------------------------------
|
|
1153
1154
|
* add add(aPtr,bPtr,n,resPtr) matrix_add(a,b,result)
|
|
1154
1155
|
* subtract subtract(aPtr,bPtr,n,resPtr) matrix_sub(a,b,result)
|
|
@@ -1163,9 +1164,10 @@ declare function getCachedFeatures(): WasmFeatures | null;
|
|
|
1163
1164
|
* norm simdNormF64(aPtr,n) array_norm(a)
|
|
1164
1165
|
* dot dotProduct(aPtr,bPtr,n) array_dot(a,b)
|
|
1165
1166
|
*
|
|
1166
|
-
* AssemblyScript
|
|
1167
|
-
*
|
|
1168
|
-
*
|
|
1167
|
+
* AssemblyScript also exports LU / QR / Cholesky / inverse / determinant
|
|
1168
|
+
* (see assembly/src/algebra/decomposition.ts); the methods below dispatch
|
|
1169
|
+
* to them when present and fall back to the in-process JS implementation
|
|
1170
|
+
* otherwise.
|
|
1169
1171
|
*
|
|
1170
1172
|
* @packageDocumentation
|
|
1171
1173
|
*/
|
|
@@ -1185,9 +1187,8 @@ interface WASMBackendConfig {
|
|
|
1185
1187
|
/**
|
|
1186
1188
|
* WASM Backend for matrix operations (AssemblyScript path).
|
|
1187
1189
|
*
|
|
1188
|
-
*
|
|
1189
|
-
*
|
|
1190
|
-
* `BackendManager` can route operations to the correct one.
|
|
1190
|
+
* This is the sole WASM backend after Phase 7b retired the legacy path; it
|
|
1191
|
+
* reports `type: 'wasm'` and is registered by `register-backends.ts`.
|
|
1191
1192
|
*/
|
|
1192
1193
|
declare class WASMBackend implements MatrixBackend {
|
|
1193
1194
|
readonly type: BackendType;
|
|
@@ -1212,7 +1213,7 @@ declare class WASMBackend implements MatrixBackend {
|
|
|
1212
1213
|
/**
|
|
1213
1214
|
* Compile + instantiate the AssemblyScript WASM artifact. Each
|
|
1214
1215
|
* WASMBackend instance owns its own instance — this is intentional so
|
|
1215
|
-
* tests and
|
|
1216
|
+
* tests and multiple backend instances can coexist in the same process.
|
|
1216
1217
|
*/
|
|
1217
1218
|
private loadAsModule;
|
|
1218
1219
|
private shouldUseWasm;
|
|
@@ -2178,307 +2179,6 @@ declare const gpuMatrixBackend: GPUMatrixBackend;
|
|
|
2178
2179
|
*/
|
|
2179
2180
|
declare function createGPUMatrixBackend(config?: GPUMatrixBackendConfig): GPUMatrixBackend;
|
|
2180
2181
|
|
|
2181
|
-
/**
|
|
2182
|
-
* Rust WASM Matrix Backend
|
|
2183
|
-
*
|
|
2184
|
-
* Implements MatrixBackend using the Rust-compiled WebAssembly module (648 KB).
|
|
2185
|
-
* Designed for heavy operations: large matrix multiply (faer), FFT (rustfft),
|
|
2186
|
-
* eigendecomposition, sparse algebra, and SIMD-accelerated array operations.
|
|
2187
|
-
*
|
|
2188
|
-
* This backend sits alongside the existing WASMBackend (AssemblyScript) and
|
|
2189
|
-
* is selected by BackendManager for large matrices and heavy operations.
|
|
2190
|
-
*
|
|
2191
|
-
* Memory model:
|
|
2192
|
-
* Uses a bump allocator on the JS side to write data into WASM linear
|
|
2193
|
-
* memory. The allocator is reset between operations (batch-free pattern).
|
|
2194
|
-
* This avoids the overhead of per-allocation malloc/free calls.
|
|
2195
|
-
*
|
|
2196
|
-
* @packageDocumentation
|
|
2197
|
-
*/
|
|
2198
|
-
|
|
2199
|
-
/**
|
|
2200
|
-
* Rust WASM Backend configuration
|
|
2201
|
-
*/
|
|
2202
|
-
interface RustWASMBackendConfig {
|
|
2203
|
-
/** Minimum elements to use Rust WASM (default: 1000) */
|
|
2204
|
-
minElements?: number;
|
|
2205
|
-
/** Path to the Rust WASM binary */
|
|
2206
|
-
wasmPath?: string;
|
|
2207
|
-
}
|
|
2208
|
-
/**
|
|
2209
|
-
* Rust WASM Backend for matrix operations.
|
|
2210
|
-
*
|
|
2211
|
-
* Uses the Rust WASM module for heavy computation, with automatic
|
|
2212
|
-
* fallback to JSBackend when the module is unavailable or for small matrices.
|
|
2213
|
-
*
|
|
2214
|
-
* The backend registers as type 'wasm' so it can serve as a drop-in
|
|
2215
|
-
* replacement or complement to the AssemblyScript WASMBackend. When both
|
|
2216
|
-
* are needed, use BackendManager's operation-specific routing.
|
|
2217
|
-
*/
|
|
2218
|
-
declare class RustWASMBackend implements MatrixBackend {
|
|
2219
|
-
/**
|
|
2220
|
-
* Backend type identifier.
|
|
2221
|
-
* Uses 'rust-wasm' to distinguish from the AssemblyScript WASMBackend.
|
|
2222
|
-
*/
|
|
2223
|
-
readonly type: BackendType;
|
|
2224
|
-
private config;
|
|
2225
|
-
private exports;
|
|
2226
|
-
private initPromise;
|
|
2227
|
-
constructor(config?: RustWASMBackendConfig);
|
|
2228
|
-
/**
|
|
2229
|
-
* Check if WebAssembly is available in the current environment.
|
|
2230
|
-
*/
|
|
2231
|
-
isAvailable(): boolean;
|
|
2232
|
-
/**
|
|
2233
|
-
* Initialize the Rust WASM backend.
|
|
2234
|
-
* Loads the WASM binary and caches the exports.
|
|
2235
|
-
*/
|
|
2236
|
-
initialize(): Promise<void>;
|
|
2237
|
-
private doInitialize;
|
|
2238
|
-
/**
|
|
2239
|
-
* Whether to use Rust WASM for this operation size.
|
|
2240
|
-
*/
|
|
2241
|
-
private shouldUseRustWasm;
|
|
2242
|
-
/**
|
|
2243
|
-
* Whether the Rust WASM module is loaded and ready.
|
|
2244
|
-
*/
|
|
2245
|
-
get isRustLoaded(): boolean;
|
|
2246
|
-
add(a: DenseMatrix, b: DenseMatrix): DenseMatrix;
|
|
2247
|
-
subtract(a: DenseMatrix, b: DenseMatrix): DenseMatrix;
|
|
2248
|
-
multiplyElementwise(a: DenseMatrix, b: DenseMatrix): DenseMatrix;
|
|
2249
|
-
divideElementwise(a: DenseMatrix, b: DenseMatrix): DenseMatrix;
|
|
2250
|
-
scale(a: DenseMatrix, scalar: number): DenseMatrix;
|
|
2251
|
-
abs(a: DenseMatrix): DenseMatrix;
|
|
2252
|
-
negate(a: DenseMatrix): DenseMatrix;
|
|
2253
|
-
multiply(a: DenseMatrix, b: DenseMatrix): DenseMatrix;
|
|
2254
|
-
transpose(a: DenseMatrix): DenseMatrix;
|
|
2255
|
-
sum(a: DenseMatrix): number;
|
|
2256
|
-
sumAxis(a: DenseMatrix, axis: 0 | 1): DenseMatrix;
|
|
2257
|
-
norm(a: DenseMatrix): number;
|
|
2258
|
-
dot(a: DenseMatrix, b: DenseMatrix): number;
|
|
2259
|
-
/**
|
|
2260
|
-
* LU Decomposition using Rust WASM.
|
|
2261
|
-
*/
|
|
2262
|
-
luDecomposition(a: DenseMatrix): Promise<{
|
|
2263
|
-
lu: DenseMatrix;
|
|
2264
|
-
perm: Int32Array;
|
|
2265
|
-
singular: boolean;
|
|
2266
|
-
}>;
|
|
2267
|
-
/**
|
|
2268
|
-
* Eigenvalue decomposition for symmetric matrices using Rust WASM.
|
|
2269
|
-
*/
|
|
2270
|
-
eigsSymmetric(a: DenseMatrix, precision?: number): Promise<{
|
|
2271
|
-
eigenvalues: Float64Array;
|
|
2272
|
-
eigenvectors: DenseMatrix;
|
|
2273
|
-
iterations: number;
|
|
2274
|
-
}>;
|
|
2275
|
-
/**
|
|
2276
|
-
* Matrix inversion using Rust WASM.
|
|
2277
|
-
*/
|
|
2278
|
-
inverse(a: DenseMatrix): Promise<{
|
|
2279
|
-
inverse: DenseMatrix;
|
|
2280
|
-
singular: boolean;
|
|
2281
|
-
}>;
|
|
2282
|
-
/**
|
|
2283
|
-
* FFT using Rust WASM (rustfft).
|
|
2284
|
-
* Data is interleaved complex: [re0, im0, re1, im1, ...].
|
|
2285
|
-
*/
|
|
2286
|
-
fft(data: Float64Array, n: number, inverse?: boolean): Float64Array;
|
|
2287
|
-
/**
|
|
2288
|
-
* Update configuration.
|
|
2289
|
-
*/
|
|
2290
|
-
updateConfig(config: Partial<RustWASMBackendConfig>): void;
|
|
2291
|
-
/**
|
|
2292
|
-
* Get current configuration.
|
|
2293
|
-
*/
|
|
2294
|
-
getConfig(): Required<RustWASMBackendConfig>;
|
|
2295
|
-
}
|
|
2296
|
-
/**
|
|
2297
|
-
* Global Rust WASM backend instance
|
|
2298
|
-
*/
|
|
2299
|
-
declare const rustWasmBackend: RustWASMBackend;
|
|
2300
|
-
/**
|
|
2301
|
-
* Create a Rust WASM backend with custom configuration
|
|
2302
|
-
*/
|
|
2303
|
-
declare function createRustWASMBackend(config?: RustWASMBackendConfig): RustWASMBackend;
|
|
2304
|
-
|
|
2305
|
-
/**
|
|
2306
|
-
* Rust WASM Loader
|
|
2307
|
-
*
|
|
2308
|
-
* Loads and manages the Rust-compiled WebAssembly module (648 KB).
|
|
2309
|
-
* The Rust WASM provides heavy computation: matrix multiply (faer),
|
|
2310
|
-
* FFT (rustfft), eigendecomposition, sparse algebra, statistics (statrs),
|
|
2311
|
-
* and SIMD-accelerated array operations.
|
|
2312
|
-
*
|
|
2313
|
-
* Memory model:
|
|
2314
|
-
* The Rust WASM uses `#[no_mangle] extern "C"` raw exports with
|
|
2315
|
-
* a linear memory model. Unlike the AssemblyScript WASM, there is
|
|
2316
|
-
* no managed GC heap (`__new`/`__pin`/`__unpin`/`__collect`).
|
|
2317
|
-
* Instead, JavaScript writes data directly into WASM linear memory
|
|
2318
|
-
* at computed offsets and passes those offsets as pointers.
|
|
2319
|
-
*
|
|
2320
|
-
* @packageDocumentation
|
|
2321
|
-
*/
|
|
2322
|
-
/**
|
|
2323
|
-
* Typed interface for Rust WASM exports.
|
|
2324
|
-
*
|
|
2325
|
-
* This is a subset of the full export surface, covering the operations
|
|
2326
|
-
* most useful for the matrix backend. The full module has 150+ exports
|
|
2327
|
-
* across algebra, arithmetic, signal, statistics, etc.
|
|
2328
|
-
*/
|
|
2329
|
-
interface RustWasmExports {
|
|
2330
|
-
memory: WebAssembly.Memory;
|
|
2331
|
-
multiplyDense: (aPtr: number, aRows: number, aCols: number, bPtr: number, bRows: number, bCols: number, resultPtr: number) => void;
|
|
2332
|
-
multiplyDenseSIMD: (aPtr: number, aRows: number, aCols: number, bPtr: number, bRows: number, bCols: number, resultPtr: number) => void;
|
|
2333
|
-
multiplyVector: (aPtr: number, aRows: number, aCols: number, xPtr: number, resultPtr: number) => void;
|
|
2334
|
-
transpose: (dataPtr: number, rows: number, cols: number, resultPtr: number) => void;
|
|
2335
|
-
/** Thin SVD: writes U (m*k), S (k), V (n*k); k = min(m,n). */
|
|
2336
|
-
svd: (aPtr: number, m: number, n: number, uPtr: number, sPtr: number, vPtr: number, workPtr: number) => number;
|
|
2337
|
-
/** Singular values only: writes S (k); k = min(m,n). */
|
|
2338
|
-
singularValues: (aPtr: number, m: number, n: number, sPtr: number, workPtr: number) => number;
|
|
2339
|
-
/** Scratch length (in f64s) required by `svd`. */
|
|
2340
|
-
svdWorkSize: (m: number, n: number) => number;
|
|
2341
|
-
/** Scratch length (in f64s) required by `singularValues`. */
|
|
2342
|
-
singularValuesWorkSize: (m: number, n: number) => number;
|
|
2343
|
-
simdAddF64: (aPtr: number, bPtr: number, resultPtr: number, length: number) => void;
|
|
2344
|
-
simdSubF64: (aPtr: number, bPtr: number, resultPtr: number, length: number) => void;
|
|
2345
|
-
simdMulF64: (aPtr: number, bPtr: number, resultPtr: number, length: number) => void;
|
|
2346
|
-
simdScaleF64: (aPtr: number, scalar: number, resultPtr: number, length: number) => void;
|
|
2347
|
-
simdAbsF64: (aPtr: number, resultPtr: number, length: number) => void;
|
|
2348
|
-
simdDotF64: (aPtr: number, bPtr: number, length: number) => number;
|
|
2349
|
-
simdSumF64: (aPtr: number, length: number) => number;
|
|
2350
|
-
simdNormF64: (aPtr: number, length: number) => number;
|
|
2351
|
-
simdMatMulF64: (aPtr: number, bPtr: number, cPtr: number, m: number, k: number, n: number) => void;
|
|
2352
|
-
simdMinF64: (aPtr: number, length: number) => number;
|
|
2353
|
-
simdMaxF64: (aPtr: number, length: number) => number;
|
|
2354
|
-
simdMeanF64: (aPtr: number, length: number) => number;
|
|
2355
|
-
simdVarianceF64: (aPtr: number, length: number, ddof: number) => number;
|
|
2356
|
-
simdStdF64: (aPtr: number, length: number, ddof: number) => number;
|
|
2357
|
-
luDecomposition: (aPtr: number, n: number, permPtr: number) => number;
|
|
2358
|
-
qrDecomposition: (aPtr: number, m: number, n: number, qPtr: number) => void;
|
|
2359
|
-
choleskyDecomposition: (aPtr: number, n: number, lPtr: number) => number;
|
|
2360
|
-
eigsSymmetric: (matrixPtr: number, n: number, precision: number, eigenvaluesPtr: number, eigenvectorsPtr: number, workPtr: number) => number;
|
|
2361
|
-
laInv: (aPtr: number, n: number, resultPtr: number, workPtr: number) => number;
|
|
2362
|
-
laDet: (aPtr: number, n: number, workPtr: number) => number;
|
|
2363
|
-
laSolve: (aPtr: number, bPtr: number, n: number, resultPtr: number, workPtr: number) => number;
|
|
2364
|
-
fft: (dataPtr: number, n: number, inverse: number) => void;
|
|
2365
|
-
fft2d: (dataPtr: number, rows: number, cols: number, inverse: number) => void;
|
|
2366
|
-
convolve: (signalPtr: number, n: number, kernelPtr: number, m: number, resultPtr: number) => void;
|
|
2367
|
-
rfft: (dataPtr: number, n: number, resultPtr: number) => void;
|
|
2368
|
-
statsMean: (aPtr: number, n: number) => number;
|
|
2369
|
-
statsMedian: (aPtr: number, n: number) => number;
|
|
2370
|
-
statsVariance: (aPtr: number, n: number, ddof: number) => number;
|
|
2371
|
-
statsStd: (aPtr: number, n: number, ddof: number) => number;
|
|
2372
|
-
statsSum: (aPtr: number, n: number) => number;
|
|
2373
|
-
statsMin: (aPtr: number, n: number) => number;
|
|
2374
|
-
statsMax: (aPtr: number, n: number) => number;
|
|
2375
|
-
rust_mat_mul_2x2: (aPtr: number, bPtr: number, outPtr: number) => void;
|
|
2376
|
-
rust_fft_4: (inPtr: number, outPtr: number) => void;
|
|
2377
|
-
rust_gamma: (x: number, outPtr: number) => void;
|
|
2378
|
-
[key: string]: unknown;
|
|
2379
|
-
}
|
|
2380
|
-
/**
|
|
2381
|
-
* Loading metrics for performance monitoring
|
|
2382
|
-
*/
|
|
2383
|
-
interface RustLoadingMetrics {
|
|
2384
|
-
loadMs: number;
|
|
2385
|
-
compileMs: number;
|
|
2386
|
-
instantiateMs: number;
|
|
2387
|
-
totalMs: number;
|
|
2388
|
-
binarySize: number;
|
|
2389
|
-
}
|
|
2390
|
-
/**
|
|
2391
|
-
* Loader for the Rust-compiled WASM module.
|
|
2392
|
-
*
|
|
2393
|
-
* Singleton pattern with lazy loading. The WASM binary is loaded
|
|
2394
|
-
* on first use and cached for subsequent calls.
|
|
2395
|
-
*/
|
|
2396
|
-
declare class RustWasmLoader {
|
|
2397
|
-
private static instance;
|
|
2398
|
-
private wasmInstance;
|
|
2399
|
-
private wasmMemory;
|
|
2400
|
-
private allocator;
|
|
2401
|
-
private _isLoaded;
|
|
2402
|
-
private loading;
|
|
2403
|
-
private lastMetrics;
|
|
2404
|
-
private constructor();
|
|
2405
|
-
static getInstance(): RustWasmLoader;
|
|
2406
|
-
get isLoaded(): boolean;
|
|
2407
|
-
/**
|
|
2408
|
-
* Load the Rust WASM module.
|
|
2409
|
-
* Returns true on success, false if the binary is not available.
|
|
2410
|
-
* Safe to call multiple times (idempotent).
|
|
2411
|
-
*/
|
|
2412
|
-
load(wasmPath?: string): Promise<boolean>;
|
|
2413
|
-
private doLoad;
|
|
2414
|
-
/**
|
|
2415
|
-
* Resolve the WASM binary path.
|
|
2416
|
-
* Checks several locations relative to the project root.
|
|
2417
|
-
*/
|
|
2418
|
-
private findWasmPath;
|
|
2419
|
-
private getImports;
|
|
2420
|
-
/**
|
|
2421
|
-
* Get the typed exports from the WASM instance.
|
|
2422
|
-
*/
|
|
2423
|
-
getExports(): RustWasmExports | null;
|
|
2424
|
-
/**
|
|
2425
|
-
* Get WASM linear memory.
|
|
2426
|
-
*/
|
|
2427
|
-
getMemory(): WebAssembly.Memory | null;
|
|
2428
|
-
/**
|
|
2429
|
-
* Get loading metrics.
|
|
2430
|
-
*/
|
|
2431
|
-
getLoadingMetrics(): RustLoadingMetrics | null;
|
|
2432
|
-
/**
|
|
2433
|
-
* Write a Float64Array into WASM memory and return the pointer.
|
|
2434
|
-
*/
|
|
2435
|
-
writeF64(data: Float64Array | number[]): number;
|
|
2436
|
-
/**
|
|
2437
|
-
* Allocate an empty Float64Array in WASM memory (for output buffers).
|
|
2438
|
-
* Returns the pointer.
|
|
2439
|
-
*/
|
|
2440
|
-
allocF64(length: number): number;
|
|
2441
|
-
/**
|
|
2442
|
-
* Write an Int32Array into WASM memory and return the pointer.
|
|
2443
|
-
*/
|
|
2444
|
-
writeI32(data: Int32Array | number[]): number;
|
|
2445
|
-
/**
|
|
2446
|
-
* Allocate an empty Int32Array in WASM memory.
|
|
2447
|
-
*/
|
|
2448
|
-
allocI32(length: number): number;
|
|
2449
|
-
/**
|
|
2450
|
-
* Read a Float64Array from WASM memory.
|
|
2451
|
-
* Note: the returned array is a *copy* (safe after memory reset).
|
|
2452
|
-
*/
|
|
2453
|
-
readF64(ptr: number, length: number): Float64Array;
|
|
2454
|
-
/**
|
|
2455
|
-
* Read an Int32Array from WASM memory.
|
|
2456
|
-
*/
|
|
2457
|
-
readI32(ptr: number, length: number): Int32Array;
|
|
2458
|
-
/**
|
|
2459
|
-
* Reset the bump allocator. Call between independent operations
|
|
2460
|
-
* to reclaim temporary memory.
|
|
2461
|
-
*/
|
|
2462
|
-
resetAllocator(): void;
|
|
2463
|
-
/**
|
|
2464
|
-
* Reset the loader (for testing).
|
|
2465
|
-
*/
|
|
2466
|
-
reset(): void;
|
|
2467
|
-
/**
|
|
2468
|
-
* Reset the singleton (for testing).
|
|
2469
|
-
*/
|
|
2470
|
-
static resetInstance(): void;
|
|
2471
|
-
}
|
|
2472
|
-
/**
|
|
2473
|
-
* Global Rust WASM loader instance
|
|
2474
|
-
*/
|
|
2475
|
-
declare const rustWasmLoader: RustWasmLoader;
|
|
2476
|
-
/**
|
|
2477
|
-
* Initialize the Rust WASM module (call once at startup).
|
|
2478
|
-
* Returns true if loaded successfully, false if not available.
|
|
2479
|
-
*/
|
|
2480
|
-
declare function initRustWasm(wasmPath?: string): Promise<boolean>;
|
|
2481
|
-
|
|
2482
2182
|
/**
|
|
2483
2183
|
* MathTS Matrix Configuration
|
|
2484
2184
|
*
|
|
@@ -2515,16 +2215,11 @@ interface ExtendedBackendHints extends BackendHints {
|
|
|
2515
2215
|
operationThresholds?: Partial<Record<OperationType, {
|
|
2516
2216
|
wasm?: number;
|
|
2517
2217
|
gpu?: number;
|
|
2518
|
-
rustWasm?: number;
|
|
2519
2218
|
}>>;
|
|
2520
2219
|
/** Enable automatic SIMD detection for WASM */
|
|
2521
2220
|
autoSIMD?: boolean;
|
|
2522
2221
|
/** Fallback to JS on backend failure */
|
|
2523
2222
|
fallbackOnError?: boolean;
|
|
2524
|
-
/** Minimum elements to use Rust WASM backend (default: 1000) */
|
|
2525
|
-
rustWasmThreshold?: number;
|
|
2526
|
-
/** Operations that always prefer Rust WASM regardless of size */
|
|
2527
|
-
rustWasmPreferredOps?: OperationType[];
|
|
2528
2223
|
}
|
|
2529
2224
|
/**
|
|
2530
2225
|
* Default extended hints
|
|
@@ -2566,11 +2261,9 @@ declare class BackendManager {
|
|
|
2566
2261
|
*
|
|
2567
2262
|
* Selection priority:
|
|
2568
2263
|
* 1. Preferred backend (if explicitly set)
|
|
2569
|
-
* 2.
|
|
2570
|
-
* 3. Elements >
|
|
2571
|
-
* 4.
|
|
2572
|
-
* 5. Elements > wasmThreshold -> AS WASM (if loaded)
|
|
2573
|
-
* 6. JS fallback
|
|
2264
|
+
* 2. Elements > gpuThreshold -> GPU (if available)
|
|
2265
|
+
* 3. Elements > wasmThreshold -> AS WASM (if loaded)
|
|
2266
|
+
* 4. JS fallback
|
|
2574
2267
|
*/
|
|
2575
2268
|
selectBackend(elementCount: number, operation?: OperationType): MatrixBackend;
|
|
2576
2269
|
/**
|
|
@@ -2823,23 +2516,33 @@ declare function normFro(matrix: number[][]): number;
|
|
|
2823
2516
|
* WASM-accelerated Eigendecomposition
|
|
2824
2517
|
*
|
|
2825
2518
|
* Provides eigenvalue/eigenvector computation with optional WASM acceleration
|
|
2826
|
-
* via the
|
|
2519
|
+
* via the AssemblyScript-compiled Jacobi eigenvalue algorithm. Falls back to the pure
|
|
2827
2520
|
* JavaScript QR-based implementation when WASM is unavailable.
|
|
2828
2521
|
*
|
|
2829
2522
|
* WASM acceleration path:
|
|
2830
|
-
* - Symmetric matrices: Jacobi eigenvalue algorithm (
|
|
2831
|
-
*
|
|
2523
|
+
* - Symmetric matrices: Jacobi eigenvalue algorithm (AssemblyScript
|
|
2524
|
+
* `matrix_eig_symmetric`, `assembly/src/ops/eig.ts`)
|
|
2525
|
+
* - Non-symmetric matrices: Hessenberg reduction + Francis double-shift
|
|
2526
|
+
* implicit QR to the real Schur form, with eigenvector back-substitution
|
|
2527
|
+
* (AssemblyScript `matrix_eig_general`, `assembly/src/ops/eig.ts`)
|
|
2832
2528
|
*
|
|
2833
|
-
* JS fallback path:
|
|
2529
|
+
* JS fallback path (wasm unavailable, n < threshold, or missing export):
|
|
2834
2530
|
* - Full QR algorithm with implicit shifts (eig.ts)
|
|
2835
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).
|
|
2538
|
+
*
|
|
2836
2539
|
* @packageDocumentation
|
|
2837
2540
|
*/
|
|
2838
2541
|
|
|
2839
2542
|
/**
|
|
2840
2543
|
* WASM-accelerated eigendecomposition for symmetric matrices.
|
|
2841
2544
|
*
|
|
2842
|
-
* Uses the
|
|
2545
|
+
* Uses the AssemblyScript Jacobi eigenvalue algorithm when WASM is loaded,
|
|
2843
2546
|
* otherwise falls back to the JavaScript QR algorithm.
|
|
2844
2547
|
*
|
|
2845
2548
|
* @param matrix - Square matrix as 2D array
|
|
@@ -2861,7 +2564,7 @@ declare function eigvalsWasm(matrix: number[][], options?: Omit<EigOptions, 'com
|
|
|
2861
2564
|
}>>;
|
|
2862
2565
|
/**
|
|
2863
2566
|
* WASM-accelerated spectral radius.
|
|
2864
|
-
* Uses
|
|
2567
|
+
* Uses AssemblyScript power iteration when WASM is available.
|
|
2865
2568
|
*
|
|
2866
2569
|
* @param matrix - Square matrix as 2D array
|
|
2867
2570
|
* @param options - Iteration options
|
|
@@ -2875,10 +2578,12 @@ declare function spectralRadiusWasm(matrix: number[][], options?: {
|
|
|
2875
2578
|
/**
|
|
2876
2579
|
* WASM-accelerated Singular Value Decomposition.
|
|
2877
2580
|
*
|
|
2878
|
-
* Routes through the
|
|
2879
|
-
* (`
|
|
2880
|
-
*
|
|
2881
|
-
* unavailable.
|
|
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.)
|
|
2882
2587
|
*
|
|
2883
2588
|
* Unlike the synchronous {@link svd} (which returns the *full* `m x m` /
|
|
2884
2589
|
* `n x n` factors), `svdWasm` always returns the **thin / economy** form —
|
|
@@ -2890,7 +2595,7 @@ declare function spectralRadiusWasm(matrix: number[][], options?: {
|
|
|
2890
2595
|
|
|
2891
2596
|
/**
|
|
2892
2597
|
* WASM-accelerated thin SVD. Always safe to call — falls back to the
|
|
2893
|
-
* synchronous JS SVD when the
|
|
2598
|
+
* synchronous JS SVD when the AssemblyScript WASM module is not available.
|
|
2894
2599
|
*
|
|
2895
2600
|
* @param matrix - Input matrix (m x n) as a row-major 2D array
|
|
2896
2601
|
* @param options - SVD options; `rankTolerance` controls the rank estimate
|
|
@@ -3630,4 +3335,4 @@ declare function initializeParallelMatrix(): Promise<void>;
|
|
|
3630
3335
|
*/
|
|
3631
3336
|
declare function terminateParallelMatrix(): Promise<void>;
|
|
3632
3337
|
|
|
3633
|
-
export { BUILTIN_SHADERS, type BackendHints, BackendManager, BackendRegistry, type BackendType, BatchExecutor, BufferPool, type CholeskyResult, DEFAULT_BACKEND_HINTS, DEFAULT_EXTENDED_HINTS, DenseMatrix, type EigOptions, type EigResult, type ExpmOptions, type ExtendedBackendHints, GPUBackend, type GPUBackendOptions, type GPUBackendStatus, type GPUCapabilities, GPUContext, type GPUContextOptions, GPUMatrixBackend, type GPUMatrixBackendConfig, JSBackend, type LUResult, type LogmOptions, Matrix, type MatrixBackend, type MatrixDimensions, type MatrixEntry, type MatrixIndex, type MatrixType, type OperationType, ParallelBackend, type ParallelBackendConfig, type PinvOptions, type QROptions, type QRResult, type
|
|
3338
|
+
export { BUILTIN_SHADERS, type BackendHints, BackendManager, BackendRegistry, type BackendType, BatchExecutor, BufferPool, type CholeskyResult, DEFAULT_BACKEND_HINTS, DEFAULT_EXTENDED_HINTS, DenseMatrix, type EigOptions, type EigResult, type ExpmOptions, type ExtendedBackendHints, GPUBackend, type GPUBackendOptions, type GPUBackendStatus, type GPUCapabilities, GPUContext, type GPUContextOptions, GPUMatrixBackend, type GPUMatrixBackendConfig, JSBackend, type LUResult, type LogmOptions, Matrix, type MatrixBackend, type MatrixDimensions, type MatrixEntry, type MatrixIndex, type MatrixType, type OperationType, ParallelBackend, type ParallelBackendConfig, type PinvOptions, type QROptions, type QRResult, type SVDOptions, type SVDResult, type SchurOptions, type SchurResult, ShaderManager, type SliceSpec, SparseMatrix, type SqrtmOptions, type SyncConfig, SyncManager, type SyncStrategy, WASMBackend, type WASMBackendConfig, type WasmFeatures, abs, add, backendManager, backendRegistry, cholesky, clearFeatureCache, column, cond, createBackendManager, createGPUMatrixBackend, createParallelBackend, createSyncManager, createWASMBackend, destroyGlobalGPU, destroyGlobalGPUBackend, detectGPUCapabilities, detectWasmFeatures, diag, diagonal, divide, dotMultiply, eig, eigWasm, eigvals, eigvalsWasm, exp, getCachedFeatures, getGlobalGPUBackend, getGlobalGPUContext, getRecommendedWorkgroupSize, gpuMatrixBackend, hasWebGPU, identity, initializeGlobalGPUBackend, initializeParallelMatrix, isAtomicsAvailable, isDenseMatrix, isMatrix, isSharedMemoryAvailable, isSparseMatrix, isWasmAvailable, jsBackend, log, lowRankApprox, lu, matrix, matrixExpm, matrixLogm, pinv as matrixPinv, matrixSchur, matrixSqrtm, max, mean, min, multiply, norm, norm2, normFro, ones, parallelBackend, parallelDiag, parallelDotMultiply, parallelIdentity, parallelMatrix, parallelMatrixAbs, parallelMatrixAdd, parallelMatrixColumn, parallelMatrixCos, parallelMatrixDiagonal, parallelMatrixDistance, parallelMatrixDivide, parallelMatrixDot, parallelMatrixExp, parallelMatrixHistogram, parallelMatrixLog, parallelMatrixMatvec, parallelMatrixMax, parallelMatrixMean, parallelMatrixMin, parallelMatrixMultiply, parallelMatrixNorm, parallelMatrixOperations, parallelMatrixOuter, parallelMatrixRow, parallelMatrixSin, parallelMatrixSize, parallelMatrixSqrt, parallelMatrixSquare, parallelMatrixStd, parallelMatrixSubset, parallelMatrixSubtract, parallelMatrixSum, parallelMatrixTan, parallelMatrixTrace, parallelMatrixTranspose, parallelMatrixVariance, parallelOnes, parallelRandom, parallelUnaryMinus, parallelZeros, pinv$1 as pinv, pow, powerIteration, qr, random, row, singularValues, size, spectralRadiusWasm, sqrt, square, subset, subtract, sum, svd, svdWasm, terminateParallelMatrix, trace, transpose, typedMatrixOperations, unaryMinus, wasmBackend, zeros };
|