GPUDevice from init()
'lower' to use the lower triangle, 'upper' to use the upper triangle
order of the matrix A (number of rows and columns)
scalar multiplier for A*x
Float32Array, row-major or column-major (see layout), at least (n-1)*lda+n elements
leading dimension of A (>= n either way — A is square)
Float32Array input vector, length at least (n-1)*incx+1
stride for x (must be a positive integer)
scalar multiplier for y
Float32Array input/output vector, length at least (n-1)*incy+1
stride for y (must be a positive integer)
Optionallayout: "column-major" | "row-major"storage layout of A (default: 'row-major'); for a symmetric
matrix, column-major storage just means the other triangle is the one
physically referenced for a given uplo
Performs the symmetric matrix-vector operation y = alpha * A * x + beta * y
A is kept GPU-resident; x and y are CPU Float32Arrays. A's own layout
(set at GpuMatrix.from time) determines the operation — there is no
separate layout argument here.
GPUDevice from init()
'lower' to use the lower triangle, 'upper' to use the upper triangle
order of the matrix A
scalar multiplier for A*x
GpuMatrix, GPU-resident
leading dimension of A (must equal A.lda)
Float32Array input vector
stride for x (must be a positive integer)
scalar multiplier for y
Float32Array input/output vector
stride for y (must be a positive integer)
Performs the symmetric matrix-vector operation y = alpha * A * x + beta * y
x and y are kept resident on the GPU. A must be a GpuMatrix; its own
layout (set at GpuMatrix.from time) determines the operation — there is
no separate layout argument here.
import { init, cleanup } from "wgblas";
import { ssymv } from "wgblas/ssymv";
import { GpuVector } from "wgblas/classes/GpuVector";
import { GpuMatrix } from "wgblas/classes/GpuMatrix";
import { randomFloat32Array } from "wgblas/random";
const device = await init();
const n = 4;
const A = randomFloat32Array(n * n, -10, 10); // lower triangle is the stored triangle
const x = randomFloat32Array(n, -10, 10);
const y = randomFloat32Array(n, -10, 10);
const AGpu = GpuMatrix.from(A, n, n, n, "row-major");
const xGpu = GpuVector.from(x);
const yGpu = GpuVector.from(y);
console.log("A (lower triangle):", A);
console.log("x:", x);
// results stay on the GPU between steps
await ssymv(device, "lower", n, 1.0, AGpu, AGpu.lda, xGpu, 1, 0.0, yGpu, 1); // y = A*x
await ssymv(device, "lower", n, 1.0, AGpu, AGpu.lda, yGpu, 1, 0.0, xGpu, 1); // x = A*y = A²*x
// single readback
const result = await xGpu.read();
console.log("A²x:", result);
AGpu.destroy();
xGpu.destroy();
yGpu.destroy();
if (typeof process !== "undefined") cleanup();
GPUDevice from init()
'lower' to use the lower triangle, 'upper' to use the upper triangle
order of the matrix A
scalar multiplier for A*x
GpuMatrix, GPU-resident
leading dimension of A (must equal A.lda)
GpuVector input vector (not mutated)
stride for x (must be a positive integer)
scalar multiplier for y
GpuVector input/output vector (mutated in place)
stride for y (must be a positive integer)
Performs the symmetric matrix-vector operation y = alpha * A * x + beta * y
A is an n×n symmetric matrix stored in row-major order. Only the triangle specified by
uplois referenced; the other triangle is inferred by symmetry.Browser (standalone HTML):