Multik 0.3.0 Help

createAlignedNDArray

Signature

inline fun <reified T : Number> Multik.createAlignedNDArray( data: List<List<T>>, filling: Double = 0.0 ): D2Array<T> inline fun <reified T : Number> Multik.createAlignedNDArray( data: List<List<List<T>>>, filling: Double = 0.0 ): D3Array<T> inline fun <reified T : Number> Multik.createAlignedNDArray( data: List<List<List<List<T>>>>, filling: Double = 0.0 ): D4Array<T>

Each variant also has an Array overload that delegates to the List version.

Parameters

Parameter

Type

Description

data

nested List or Array

Ragged nested collection. Inner sequences may have different lengths.

filling

Double

Value used to pad shorter sequences to the maximum length at each depth. Converted to T. Defaults to 0.0.

Returns: D2Array<T>, D3Array<T>, or D4Array<T> depending on nesting depth.

Throws: IllegalArgumentException if data is empty.

Example

val ragged = listOf( listOf(1, 2, 3), listOf(4, 5), listOf(6) ) val aligned = mk.createAlignedNDArray(ragged) // [[1, 2, 3], // [4, 5, 0], // [6, 0, 0]] val padded = mk.createAlignedNDArray(ragged, filling = -1.0) // [[1, 2, 3], // [4, 5, -1], // [6, -1, -1]]
28 February 2026