Vectors, matrix multiply, Cholesky, SVD, LU solve. Optional WebGPU comparison for matmul. ← Back to hub
Run add, dot, and norm on CPU vs GPU (f32). When WebGPU is available, click Init GPU in the Matrix section first, then run the benchmark.
Vector size:
—
Column-major: elements in same column are consecutive. mathlib uses column-major (like BLAS, Fortran, MATLAB). In matrix multiply and matvec, rows of A are used as dot-product vectors with columns of B or with v; columns of A are the vectors that get scaled and summed in A×v. Storage order does not change the math, only how the same numbers are laid out in a flat array.
Two vectors added in WASM. Dot product and norm (GPU-accelerated on native after init).
Loading…
Two matrices; C = A × B. Column-major storage.
Compare CPU (f64), CPU (f32), and GPU (f32) when WebGPU is available. Each run uses a warmup then reports the median of several runs. Thresholds for when to use GPU are configured in Rust (ExecutorThresholds).
Size:
—
Element-wise add, scale, dot product, and matrix×vector using f32. When WebGPU is initialized, these use the same backend as the large matmul above.
Vector size: Matvec: 256×256.
At small sizes CPU is often faster due to GPU upload/readback cost. Try vector size 1,000,000 or 2,000,000 to see GPU win.
—
y = A × v. Vectors are column vectors.
Square matrix A; solve Ax = b via LU (using WasmMatrix.solve(b)).
SPD matrix A, solve Ax = b via Cholesky; show L and solution x.
Economical SVD; singular values σ and U, V dimensions.
General square matrix A; solve Ax = b via LU decomposition.
Rectangular A (m×n); minimize ‖Ax − b‖² + λ²‖x‖². Use the slider to change λ².
λ²: 1
A = Q R where Q has orthonormal columns and R is upper triangular. For least squares min ‖Ax − b‖.
For matrices with few non-zeros, sparse storage saves memory and can speed up operations. CSR (Compressed Sparse Row) stores row_ptr (start index per row), col_ind (column index of each entry), and values. CCS is column-wise; COO is a list of (row, col, value). mathlib provides CRS and other formats.