
Multik
Multidimensional array library for Kotlin.
Multik provides N-dimensional arrays with type-safe dimensions, math operations, linear algebra, and statistics.
It works across JVM, JS, WasmJS, iOS, and desktop native targets via Kotlin Multiplatform,
with optional OpenBLAS acceleration for high performance.
Modules
Installation
Latest
version: 
Gradle Kotlin DSL
multik-core provides ndarray types, creation functions, and basic operations.
For linear algebra, statistics, and math engines, add an engine dependency —
multik-default, multik-kotlin, or multik-openblas.
Engine dependencies transitively include multik-core.
build.gradle.kts:
repositories {
mavenCentral()
}
dependencies {
implementation("org.jetbrains.kotlinx:multik-default:$multikVersion")
}
Gradle Groovy DSL
build.gradle:
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlinx:multik-default:$multikVersion"
}
Kotlin Multiplatform
kotlin {
sourceSets {
commonMain {
dependencies {
implementation("org.jetbrains.kotlinx:multik-default:$multikVersion")
}
}
}
}
Jupyter Notebook
Install Kotlin kernel for
Jupyter
or just visit to Datalore.
Import stable multik version into notebook:
%use multik
Supported Platforms
[!IMPORTANT]
- On Linux distributions with older than 2.31, doesn't work.
Quickstart
Visit Multik documentation for a detailed feature overview.
Creating arrays
Array properties
a.shape
a.size
a.dim
a.dim.d
a.dtype
Arithmetic operations
val f = b - d
d + f
b / d
f * d
Math, Linear Algebra, and Statistics
See documentation for other methods of
mathematics,
linear algebra,
statistics.
a.sin()
a.cos()
b.log()
b.exp()
d dot e
mk.math.sum(c)
mk.math.min(c)
mk.math.maxD3(c, axis = 0)
mk.math.cumSum(b, axis = 1)
mk.stat.mean(a)
mk.stat.median(b)
Copying arrays
val f = a.copy()
val h = b.deepCopy()
Collection Operations
c.filter { it < 3 }
b.map { (it * it).toInt() }
c.groupNDArrayBy { it % 2 }
c.sorted()
Indexing/Slicing/Iterating
Inplace
val a = mk.linspace<Float>(0, 1, 10)
val b = mk.linspace<Float>(8, 9, 10)
a.inplace {
math {
( - b) * b
abs()
}
}
Building
Full build (with OpenBLAS)
Requires:
JAVA_HOME environment variable set
gcc, g++, gfortran version 8 or higher (must be the same version)
./gradlew assemble
Without OpenBLAS
./gradlew assemble -x build_cmake
Individual modules
./gradlew :multik-core:build
Running tests
./gradlew :multik-core:jvmTest
Contributing
See CONTRIBUTING.md for guidelines on submitting issues, pull requests, and building the project.
License
Multik is licensed under the Apache License 2.0.