d4array
Creates a 4D array of the given shape, where each element is computed by a flat-index init function. Elements are filled in row-major order. For per-element (i, j, k, m) indices, use d4arrayIndices.
Signature
inline fun <reified T : Any> Multik.d4array(
sizeD1: Int,
sizeD2: Int,
sizeD3: Int,
sizeD4: Int,
noinline init: (Int) -> T
): D4Array<T>
Parameters
Parameter | Type | Description |
|---|---|---|
|
| Size of the first axis. Must be positive. |
|
| Size of the second axis. Must be positive. |
|
| Size of the third axis. Must be positive. |
|
| Size of the fourth axis. Must be positive. |
|
| Lambda that receives a flat index (0 to |
Returns: D4Array<T>
Example
val a = mk.d4array<Double>(2, 3, 4, 5) { it.toDouble() }
// shape (2, 3, 4, 5), 120 elements
28 February 2026