ScranMatrix

ScranMatrix

Wrapper around a matrix allocated on the Wasm heap.

Classes

ScranMatrix

Methods

(static) createDenseMatrix(rows, columns, contents, optionsopt) → {ScranMatrix}

Source:

Create a dense matrix from an existing Wasm-allocated buffer.

Parameters:
Name Type Attributes Default Description
rows number

Number of rows.

columns number

Number of columns.

contents Float64WasmArray

Array of matrix contents.

options object <optional>
{}

Optional parameters.

Properties
Name Type Attributes Default Description
columnMajor boolean <optional>
true

Whether the array in contents is column-major.

copy boolean <optional>
true

Whether to copy contents when constructing the ScranMatrix. If false, the returned ScranMatrix will refer to the same allocation as contents, so callers should make sure that it does not outlive contents.

Returns:

A ScranMatrix containing the matrix contents.

Type
ScranMatrix

clone() → {ScranMatrix}

Source:
Returns:

A clone of the current ScranMatrix instance. This can be freed independently of the current instance.

Type
ScranMatrix

column(i, optionsopt) → {Float64Array}

Source:
Parameters:
Name Type Attributes Default Description
i number

Index of the column to extract. This should be a non-negative integer less than numberOfColumns.

options object <optional>
{}

Optional parameters.

Properties
Name Type Attributes Default Description
buffer Float64WasmArray <optional>
<nullable>
null

Buffer for storing the extracted data. If supplied, this should have length equal to numberOfRows.

Returns:

An array containing the contents of column i.

If buffer was supplied, the returned array is a view into it. Note that this may be invalidated on the next allocation on the Wasm heap.

Type
Float64Array

free()

Source:

Free the memory on the Wasm heap for this.#matrix. This invalidates this object and all of its references.

isSparse() → {boolean}

Source:
Returns:

Whether the matrix is sparse.

Type
boolean

numberOfColumns() → {number}

Source:
Returns:

Number of columns in the matrix.

Type
number

numberOfRows() → {number}

Source:
Returns:

Number of rows in the matrix.

Type
number

row(i, optionsopt) → {Float64Array}

Source:
Parameters:
Name Type Attributes Default Description
i number

Index of the row to extract. This should be a non-negative integer less than numberOfRows.

options object <optional>
{}

Optional parameters.

Properties
Name Type Attributes Default Description
buffer Float64WasmArray <optional>
<nullable>
null

Buffer for storing the extracted data. If supplied, this should have length equal to numberOfColumns.

Returns:

An array containing the contents of row i.

If buffer was supplied, the returned array is a view into it. Note that this may be invalidated on the next allocation on the Wasm heap.

Type
Float64Array