GPUDevice from init()
'lower' to update only col <= row, 'upper' for col >= row
'no-transpose' for AA^T, 'transpose' for A^TA
order of C (C is n×n); rows of op(A)
columns of op(A) — the shared/contracted dimension
scalar multiplier for op(A)*op(A)^T
Float64Array, row-major or column-major (see layout)
leading dimension of A as stored
scalar multiplier for C
Float64Array input/output matrix, row-major or column-major
leading dimension of C as stored
Optionallayout: "row-major" | "column-major"
storage layout shared by A/C when they're Float64Array
(default: 'row-major') — same handling as dgemmtr; column-major C
flips uplo internally so it still names the triangle you asked for
updated C as a Float64Array (only the requested triangle changed)
Performs the symmetric rank-k update $$C \leftarrow \mathrm{uplo}(\alpha \mathrm{op}(A) \mathrm{op}(A)^{T} + \beta C)$$ in double precision (double-double emulation).
A and C are both kept GPU-resident (Float64Array-backed GpuMatrix). Each matrix's own layout (set at
GpuMatrix.from time) determines the operation — there is no separate
layout argument here. A must be a GpuMatrix whenever C is, and vice
versa — mixing a GpuMatrix with a plain Float64Array 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, an unreferenced triangle) — and a result or intermediate past ±3.4e38 overflows to ±Infinity, where real f64 would stay finite.
import { init, cleanup } from "wgblas";
import { dsyrk } from "wgblas/dsyrk";
import { GpuMatrix } from "wgblas/classes/GpuMatrix";
const device = await init();
// Entry (i,j) of C is the dot product of rows i and j of A; only the upper
// triangle is written.
const n = 3,
k = 2;
const A = new Float64Array([1, 0, 0, 1, 1, 1]);
const AGpu = GpuMatrix.from(A, n, k, k, "row-major");
const CGpu = GpuMatrix.from(new Float64Array(n * n), n, n, n, "row-major");
console.log("A =");
console.table([A.slice(0, 2), A.slice(2, 4), A.slice(4, 6)]);
await dsyrk(
device,
"upper",
"no-transpose",
n,
k,
1,
AGpu,
AGpu.lda,
0,
CGpu,
CGpu.lda,
);
const result = await CGpu.read();
console.log("C = upper(A*A^T) =");
console.table([result.slice(0, 3), result.slice(3, 6), result.slice(6, 9)]); // [[1,0,1],[0,1,1],[0,0,2]]
AGpu.destroy();
CGpu.destroy();
if (typeof process !== "undefined") cleanup();
GPUDevice from init()
'lower' to update only col <= row, 'upper' for col >= row
'no-transpose' for AA^T, 'transpose' for A^TA
order of C (C is n×n); rows of op(A)
columns of op(A) — the shared/contracted dimension
scalar multiplier for op(A)*op(A)^T
GpuMatrix (Float64Array-backed)
leading dimension of A (must equal A.lda)
scalar multiplier for C
GpuMatrix (Float64Array-backed, mutated in place; only the requested triangle changes)
leading dimension of C (must equal C.lda)
no C — it stays GPU-resident; call C.read() yourself for a CPU readback (see the example)
Performs the symmetric rank-k update $$C \leftarrow \mathrm{uplo}(\alpha \mathrm{op}(A) \mathrm{op}(A)^{T} + \beta C)$$ in double precision (double-double emulation — WGSL has no native f64 type).
Only the triangle of C named by
uplois read or written ('lower':col <= row,'upper':col >= row). C is always n×n.trans='no-transpose': op(A) = A (n×k), computes alphaAA^T + beta*Ctrans='transpose': op(A) = A^T (A stored k×n), computes alphaA^TA + beta*CNo dedicated kernel — this is
dgemmtr's exact kernel (dgemm_small.wgslin triangle mode) withAduplicated into both operand slots (B := A).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, an unreferenced triangle) — and a result or intermediate past ±3.4e38 overflows to ±Infinity, where real f64 would stay finite.
Browser (standalone HTML):