GPUDevice from init()
number of elements to scale (must be a positive integer)
scalar multiplier
Float64Array input/output vector
stride for x (must be a positive integer)
Scales a double-precision vector by a constant: $$x \leftarrow \alpha x$$
import { init, cleanup } from "wgblas";
import { dscal } from "wgblas/dscal";
import { GpuVector } from "wgblas/classes/GpuVector";
const device = await init();
const n = 5;
const alpha = 3;
const x = new Float64Array([1, 2, 3, 4, 5]);
const xGpu = GpuVector.from(x);
console.log("x: ", x);
await dscal(device, n, alpha, xGpu, 1);
const result = await xGpu.read();
console.log("result:", result);
xGpu.destroy();
if (typeof process !== "undefined") cleanup();
GPUDevice from init()
number of elements to scale (must be a positive integer)
scalar multiplier
Float64Array-backed GpuVector input/output vector (mutated in place)
stride for x (must be a positive integer)
Scales a double-precision vector by a constant: $$x \leftarrow \alpha x$$
xandalphaare each split into a (hi, lo) double-double f32 pair (seesplitDoubleDouble/f64.mjs) since WGSL has no f64 type; the multiply uses Dekker's double-double algorithm (seeshaders/f64/), giving ~48 bits of mantissa — more than a single f32 (24 bits) but less than true f64 (52 bits), so results are not bit-exact with a CPU double.Browser (standalone HTML):