src/linalg

Search:
Group by:

Procs

proc newMatmul(arr: NDArray; other: NDArray): NDArray {....raises: [ValueError],
    tags: [], forbids: [].}

Matrix multiplication (returns new array).

Performs matrix multiplication using BLAS-optimized routines.

Parameters:

  • other - Matrix to multiply with (inner dimensions must match)

Returns: New array with matrix product

Example:

let a = newOnes(@[2, 3])  # 2x3 matrix
let b = newOnes(@[3, 4])  # 3x4 matrix
let c = a.newMatmul(b)    # 2x4 result
proc newTensordot(arr: NDArray; other: NDArray; axesA: openArray[int];
                  axesB: openArray[int]): NDArray {....raises: [ValueError],
    tags: [], forbids: [].}

Tensor contraction over specified axes (returns new array).

Generalized tensor product contracting specified axes.

Parameters:

  • other - Tensor to contract with
  • axesA - Axes of arr to contract
  • axesB - Axes of other to contract (must match length of axesA)

Returns: New array with contracted tensor

Example:

let a = newOnes(@[2, 3, 4])
let b = newOnes(@[4, 5])
let c = a.newTensordot(b, @[2], @[0])  # Contract axis 2 of a with axis 0 of b