Multik 0.3.0 Help

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

sizeD1

Int

Number of elements. Must be positive.

init

(Int) -> T

Lambda that receives the index (0 to sizeD1 - 1) and returns the element value.

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