NDWasmBlas

Namespace

NDWasmBlas

Description:
  • NDWasmBlas: BLAS (Basic Linear Algebra Subprograms) Handles O(n^2) and O(n^3) matrix-matrix and matrix-vector operations.

Source:

Methods

(static) ger(x, y) → {NDArray}

Description:
  • Vector Outer Product (Rank-1 Update): A = x * y^T. Complexity: O(m * n)

Source:
Parameters:
Name Type Description
x NDArray

Vector of shape [m].

y NDArray

Vector of shape [n].

Returns:

Result matrix of shape [m, n].

Type
NDArray

(static) matMul(a, b) → {NDArray}

Description:
  • General Matrix Multiplication (GEMM): C = A * B. Complexity: O(m * n * k)

Source:
Parameters:
Name Type Description
a NDArray

Left matrix of shape [m, n].

b NDArray

Right matrix of shape [n, k].

Returns:

Result matrix of shape [m, k].

Type
NDArray

(static) matMulBatch(a, b) → {NDArray}

Description:
  • Batched Matrix Multiplication: C[i] = A[i] * B[i]. Common in deep learning inference. Complexity: O(batch * m * n * k)

Source:
Parameters:
Name Type Description
a NDArray

Batch of matrices of shape [batch, m, n].

b NDArray

Batch of matrices of shape [batch, n, k].

Returns:

Result batch of shape [batch, m, k].

Type
NDArray

(static) matPow(a) → {NDArray}

Description:
  • matPow computes A^k (Matrix Power). Matrix Functions (O(n^3))

Source:
Parameters:
Name Type Description
a NDArray

Matrix of shape [n, n].

Returns:

Result matrix of shape [n, n].

Type
NDArray

(static) matVecMul(a, x) → {NDArray}

Description:
  • Matrix-Vector Multiplication: y = A * x. Complexity: O(m * n)

Source:
Parameters:
Name Type Description
a NDArray

Matrix of shape [m, n].

x NDArray

Vector of shape [n].

Returns:

Result vector of shape [m].

Type
NDArray

(static) syrk(a) → {NDArray}

Description:
  • Symmetric Rank-K Update: C = alpha * A * A^T + beta * C. Used for efficiently computing covariance matrices or Gram matrices. Complexity: O(n^2 * k)

Source:
Parameters:
Name Type Description
a NDArray

Input matrix of shape [n, k].

Returns:

Symmetric result matrix of shape [n, n].

Type
NDArray

(static) trace(a) → {number}

Description:
  • Calculates the trace of a 2D square matrix (sum of diagonal elements). Complexity: O(n)

Source:
Parameters:
Name Type Description
a NDArray
Throws:

If the array is not 2D or not a square matrix.

Type
Error
Returns:

The sum of the diagonal elements.

Type
number

(static) trsm(a, b) → {NDArray}

Description:
  • Triangular System Solver: Solves A * X = B for X, where A is a triangular matrix. Complexity: O(m^2 * n)

Source:
Parameters:
Name Type Description
a NDArray

Triangular matrix of shape [m, m].

b NDArray

Right-hand side matrix/vector of shape [m, n].

Returns:

Solution matrix X of shape [m, n].

Type
NDArray