Multik 0.3.0 Help

windowed

Returns a 2D array of sliding window segments over the array's elements. Each row in the result is a window of the specified size. The step parameter controls how far the window moves on each iteration, and limit controls whether partial windows at the end are included (zero-padded).

Signature

fun <T, D : Dimension> MultiArray<T, D>.windowed( size: Int, step: Int = 1, limit: Boolean = true ): NDArray<T, D2>

Parameters

Parameter

Type

Description

size

Int

Number of elements in each window.

step

Int

Distance between the start of consecutive windows. Default: 1.

limit

Boolean

If true (default), only full windows are included. If false, partial windows at the end are zero-padded.

Returns: NDArray<T, D2> — a 2D array where each row is a window.

Example

val a = mk.ndarray(mk[1, 2, 3, 4, 5]) a.windowed(3) // [[1, 2, 3], // [2, 3, 4], // [3, 4, 5]] a.windowed(3, step = 2) // [[1, 2, 3], // [3, 4, 5]]
28 February 2026