NDWasmArray

NDWasmArray

NDWasmArray

Constructor

new NDWasmArray(buffer, shape, dtype)

Source:
Parameters:
Name Type Description
buffer WasmBuffer

The WASM memory bridge (contains .ptr and .view).

shape Int32Array | Array

Dimensions of the array.

dtype string

Data type (e.g., 'float64').

Classes

NDWasmArray

Methods

dispose()

Description:
  • Manually releases WASM heap memory.

Source:

matMul(right, result) → {NDWasmArray}

Description:
  • Matrix Multiplication: C = this * right

Source:
Parameters:
Name Type Description
right NDWasmArray
result NDWasmArray

Pre-allocated result array.

Returns:

the result array.

Type
NDWasmArray

matMulBatch(other, result) → {NDWasmArray}

Description:
  • Batched Matrix Multiplication: C[i] = this[i] * other[i]

Source:
Parameters:
Name Type Description
other NDWasmArray
result NDWasmArray

Pre-allocated result array.

Returns:
Type
NDWasmArray

pull(disposeopt)

Description:
  • Pulls data from WASM to a JS-managed NDArray.

Source:
Parameters:
Name Type Attributes Default Description
dispose boolean <optional>
true

Release WASM memory after pulling.

(static) fromArray(source, dtypeopt) → {NDWasmArray}

Description:
  • Static factory: Creates a WASM-resident array.

    1. If source is an NDArray, it calls .push() to move it to WASM.
    2. If source is a JS Array, it allocates WASM memory and fills it directly via recursive traversal to avoid intermediate flattening.
    3. If source is a single number, it creates a 1-element WASM array. Must dispose() manually to free WASM memory.
Source:
Parameters:
Name Type Attributes Default Description
source NDArray | Array | number

Source data.

dtype string <optional>
'float64'

Data type.

Returns:
Type
NDWasmArray

(static) newArray(shape, dtype) → {NDWasmArray}

Description:
  • Static factory: Creates an uninitialized WASM-resident array.

Source:
Parameters:
Name Type Default Description
shape *

Shape of the array.

dtype * float64

Data type.

Returns:
Type
NDWasmArray