import type { MatmulMethod } from './types' // Plain triple loop, ikj order (row of A and row of C stay hot across the // inner loop) — the "no special effort" baseline the other methods are // measured against. function multiply(a: Float64Array, b: Float64Array, n: number): Float64Array { const c = new Float64Array(n * n) for (let i = 0; i < n; i++) { const ai = i * n for (let k = 0; k < n; k++) { const aik = a[ai + k] if (aik === 0) continue const bk = k * n for (let j = 0; j < n; j++) { c[ai + j] += aik * b[bk + j] } } } return c } export const jsMatmul: MatmulMethod = { id: 'js', label: 'JavaScript/TS', precision: 'f64', worker: true, available: () => true, async run(n, a, b) { const t0 = performance.now() const c = multiply(a, b, n) const ms = performance.now() - t0 return { ms, sample: c[0] } }, }