GPUDevice from init()
'left' for op(A)B, 'right' for Bop(A)
'lower' if only A's lower triangle is stored, 'upper' for upper
'no-transpose' for A, 'transpose' for A^T
'unit' to treat A's diagonal as all-ones (A's diagonal is not read), 'non-unit' to read it
rows of B
columns of B
scalar multiplier for the matrix product
Float64Array, triangular, row-major or column-major (see layout)
leading dimension of A as stored
Float64Array input/output matrix, row-major or column-major
leading dimension of B as stored
Optionallayout: "row-major" | "column-major"
storage layout shared by A/B when they're Float64Array
(default: 'row-major') — column-major A is a genuine transpose (A isn't
symmetric like dsymm's), so both transA and uplo are adjusted
internally to compensate
updated B as a new Float64Array (the input array is not modified)
Performs the triangular matrix-matrix operation $$B \leftarrow \alpha \mathrm{op}(A) B \quad (\texttt{side='left'})$$ $$B \leftarrow \alpha B \mathrm{op}(A) \quad (\texttt{side='right'})$$ in double precision (double-double emulation).
A and B are both kept GPU-resident (Float64Array-backed GpuMatrix); B is
mutated in place. Each matrix's own layout (set at GpuMatrix.from
time) determines the operation — there is no separate layout argument
here. A and B must both be GpuMatrix or both be Float64Array — mixing is
not supported.
Range: double-double keeps its leading part in an f32, so it has ~48 bits of precision but f32's exponent range. A double beyond ±3.4e38 reads as ±Infinity and one below ~1.2e-38 in magnitude as 0 (f32 subnormals may flush too, depending on the GPU) — including elements of an output array the routine never touches (stride gaps, padding) — and a result or intermediate past ±3.4e38 overflows to ±Infinity, where real f64 would stay finite.
import { init, cleanup } from "wgblas";
import { dtrmm } from "wgblas/dtrmm";
import { GpuMatrix } from "wgblas/classes/GpuMatrix";
const device = await init();
// B := A*B in place, A lower triangular. Starting from the identity, B ends
// up holding the dense triangle of A.
const n = 3;
const A = new Float64Array([2, 0, 0, 3, 4, 0, 5, 6, 8]);
const B = new Float64Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
const AGpu = GpuMatrix.from(A, n, n, n, "row-major");
const BGpu = GpuMatrix.from(B, n, n, n, "row-major");
console.log("A (lower triangular) =");
console.table([A.slice(0, 3), A.slice(3, 6), A.slice(6, 9)]);
await dtrmm(
device,
"left",
"lower",
"no-transpose",
"non-unit",
n,
n,
1,
AGpu,
AGpu.lda,
BGpu,
BGpu.lda,
);
const result = await BGpu.read();
console.log("B = A*I = A =");
console.table([result.slice(0, 3), result.slice(3, 6), result.slice(6, 9)]);
AGpu.destroy();
BGpu.destroy();
if (typeof process !== "undefined") cleanup();
GPUDevice from init()
'left' for op(A)B, 'right' for Bop(A)
'lower' if only A's lower triangle is stored, 'upper' for upper
'no-transpose' for A, 'transpose' for A^T
'unit' to treat A's diagonal as all-ones (A's diagonal is not read), 'non-unit' to read it
rows of B
columns of B
scalar multiplier for the matrix product
GpuMatrix (Float64Array-backed), triangular
leading dimension of A (must equal A.lda)
GpuMatrix (Float64Array-backed, mutated in place)
leading dimension of B (must equal B.lda)
no B — it stays GPU-resident; call B.read() yourself for a CPU readback (see the example)
Performs the triangular matrix-matrix operation $$B \leftarrow \alpha \mathrm{op}(A) B \quad (\texttt{side='left'})$$ $$B \leftarrow \alpha B \mathrm{op}(A) \quad (\texttt{side='right'})$$ in double precision (double-double emulation — WGSL has no native f64 type).
Ais triangular, only itsuplotriangle stored;Bis a general m×n matrix, overwritten with the result.side='left':Ais m×m —ApremultipliesBside='right':Ais n×n —ApostmultipliesBNo dedicated fused kernel — a
triangularizepass over each half of the double-double pair materializes a dense copy ofop(A)(zero-filling the unstored triangle, substituting the implicit diagonal whendiag='unit'), thendgemm's kernel (dgemm_small.wgsl) does the multiply, all on one command encoder.Range: double-double keeps its leading part in an f32, so it has ~48 bits of precision but f32's exponent range. A double beyond ±3.4e38 reads as ±Infinity and one below ~1.2e-38 in magnitude as 0 (f32 subnormals may flush too, depending on the GPU) — including elements of an output array the routine never touches (stride gaps, padding) — and a result or intermediate past ±3.4e38 overflows to ±Infinity, where real f64 would stay finite.
Browser (standalone HTML):