Multik 0.3.0 Help

Type

DataType enum

DataType identifies the element type of an NDArray at runtime. It is stored in the dtype property of every array.

public enum class DataType( public val nativeCode: Int, public val itemSize: Int, public val clazz: KClass<out Any> )

Values

Constant

nativeCode

itemSize

Kotlin class

ByteDataType

1

1

Byte

ShortDataType

2

2

Short

IntDataType

3

4

Int

LongDataType

4

8

Long

FloatDataType

5

4

Float

DoubleDataType

6

8

Double

ComplexFloatDataType

7

8

ComplexFloat

ComplexDoubleDataType

8

16

ComplexDouble

Properties

Property

Type

Description

nativeCode

Int

Integer identifier used by the JNI layer (1–8).

itemSize

Int

Bytes per element.

clazz

KClass<out Any>

Corresponding Kotlin class.

Instance methods

isNumber

fun isNumber(): Boolean

Returns true for types 1–6 (non-complex numeric types).

isComplex

fun isComplex(): Boolean

Returns true for ComplexFloatDataType and ComplexDoubleDataType.

Companion methods

of (by native code)

fun of(i: Int): DataType

Returns the DataType matching the given nativeCode. Throws if i is out of range.

of (by element)

fun <T : Any> of(element: T): DataType

Infers the DataType from an element instance.

ofKClass

fun <T : Any> ofKClass(type: KClass<out T>): DataType

Resolves a DataType from a KClass.

Usage

val a = mk.ndarray(mk[1.0, 2.0, 3.0]) a.dtype // DataType.DoubleDataType a.dtype.nativeCode // 6 a.dtype.itemSize // 8 a.dtype.isNumber() // true a.dtype.isComplex() // false DataType.of(3) // DataType.IntDataType DataType.ofKClass(Float::class) // DataType.FloatDataType
19 February 2026