GPUDevice from init()
number of rows in A (length of x)
number of columns in A (length of y)
scalar multiplier for x*y^T
Float64Array input vector, length at least (m-1)*incx+1
stride for x (must be a positive integer)
Float64Array input vector, length at least (n-1)*incy+1
stride for y (must be a positive integer)
Float64Array, row-major or column-major (see layout), at least
(m-1)*lda+n elements for row-major or (n-1)*lda+m elements for column-major
leading dimension of A (>= n for row-major, >= m for column-major)
Optionallayout: "column-major" | "row-major"
storage layout of A (default: 'row-major')
Performs the rank-1 update $$A \leftarrow \alpha x y^{T} + A$$ in double precision (double-double emulation).
x, y, and A are all kept resident on the GPU. A's own layout (set at
GpuMatrix.from time) determines the operation — there is no separate
layout argument here.
import { init, cleanup } from "wgblas";
import { dger } from "wgblas/dger";
import { GpuVector } from "wgblas/classes/GpuVector";
import { GpuMatrix } from "wgblas/classes/GpuMatrix";
const device = await init();
// A starts at zero, so every entry of the result is just x[i]*y[j].
const m = 2,
n = 3;
const x = new Float64Array([1, 2]);
const y = new Float64Array([10, 20, 30]);
const xGpu = GpuVector.from(x);
const yGpu = GpuVector.from(y);
const AGpu = GpuMatrix.from(new Float64Array(m * n), m, n, n, "row-major");
console.log("x =", x);
console.log("y =", y);
await dger(device, m, n, 1, xGpu, 1, yGpu, 1, AGpu, AGpu.lda);
const result = await AGpu.read();
console.log("A = x*y^T =");
console.table([result.slice(0, 3), result.slice(3, 6)]); // [[10,20,30],[20,40,60]]
xGpu.destroy();
yGpu.destroy();
AGpu.destroy();
if (typeof process !== "undefined") cleanup();
GPUDevice from init()
number of rows in A
number of columns in A
scalar multiplier for x*y^T
GpuVector input vector (Float64Array-backed, not mutated)
stride for x (must be a positive integer)
GpuVector input vector (Float64Array-backed, not mutated)
stride for y (must be a positive integer)
GpuMatrix (Float64Array-backed), mutated in place
leading dimension of A (must equal A.lda)
Performs the rank-1 update $$A \leftarrow \alpha x y^{T} + A$$ in double precision (double-double emulation — WGSL has no native f64 type).
A is an m×n matrix stored in row-major order, updated in place.
ldais the leading dimension (number of doubles between the start of consecutive rows — must be >= n).Browser (standalone HTML):