Multik 0.3.0 Help

d4arrayIndices

Creates a 4D array of the given shape, where each element is computed from its four axis indices (i, j, k, m). Useful when the element value depends on its position in the 4D space.

Signature

inline fun <reified T : Any> Multik.d4arrayIndices( sizeD1: Int, sizeD2: Int, sizeD3: Int, sizeD4: Int, init: (i: Int, j: Int, k: Int, m: Int) -> T ): D4Array<T>

Parameters

Parameter

Type

Description

sizeD1

Int

Size of the first axis. Must be positive.

sizeD2

Int

Size of the second axis. Must be positive.

sizeD3

Int

Size of the third axis. Must be positive.

sizeD4

Int

Size of the fourth axis. Must be positive.

init

(i: Int, j: Int, k: Int, m: Int) -> T

Lambda that receives indices along each of the four axes.

Returns: D4Array<T>

Example

val a = mk.d4arrayIndices<Int>(2, 2, 2, 2) { i, j, k, m -> i * 8 + j * 4 + k * 2 + m } // a[1, 1, 1, 1] == 15
28 February 2026