WasmGPU.compute.CPUndarray.get¶
Summary¶
WasmGPU.compute.CPUndarray.get reads one element by multidimensional indices. Indices are checked against shape bounds and converted through strides/offset. Use this for generic indexing on contiguous or strided layouts. It returns a JavaScript number regardless of underlying dtype.
Syntax¶
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
...indices |
number[] |
Yes | One index per dimension, in shape order. |
Returns¶
number - Numeric value at the indexed element.
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const a = wgpu.compute.CPUndarray.fromArray("u32", [2, 3], new Uint32Array([10, 20, 30, 40, 50, 60]));
console.log(a.get(0, 2), a.get(1, 1));