d1array
Creates a 1D array of the given size, where each element is computed by the init function that receives the element's index.
Signature
inline fun <reified T : Any> Multik.d1array(
sizeD1: Int,
noinline init: (Int) -> T
): D1Array<T>
Parameters
Parameter | Type | Description |
|---|---|---|
|
| Number of elements. Must be positive. |
|
| Lambda that receives the index (0 to |
Returns: D1Array<T>
Example
val a = mk.d1array<Int>(5) { it * 2 }
// [0, 2, 4, 6, 8]
val b = mk.d1array<Double>(3) { it + 0.5 }
// [0.5, 1.5, 2.5]
28 February 2026