Multik
Multidimensional array library for Kotlin.
Modules
multik-core
— contains ndarrays, methods called on them and [math], [stat] and [linalg] interfaces.multik-default
— implementation includingmultik-kotlin
andmultik-openblas
for performance.multik-kotlin
— implementation of [math], [stat] and [linalg] interfaces on JVM.multik-openblas
— implementation of [math], [stat] and [linalg] interfaces in native code using OpenBLAS.
Using in your projects
Gradle
In your Gradle build script:
1. Add the Maven Central Repository.
2. Add the org.jetbrains.kotlinx:multik-core:$multik_version
api dependency.
3. Add an implementation dependency: org.jetbrains.kotlinx:multik-default:$multik_version
,
org.jetbrains.kotlinx:multik-kotlin:$multik_version
or org.jetbrains.kotlinx:multik-openblas:$multik_version
.
build.gradle
:
build.gradle.kts
:
For a multiplatform project, set the dependency in a common block:
or in a platform-specific block:
Jupyter Notebook
Install Kotlin kernel for Jupyter or just visit to Datalore.
Import stable multik
version into notebook:
Support platforms
Platforms | multik-core |
multik-kotlin |
multik-openblas |
multik-default |
---|---|---|---|---|
JS | ||||
linuxX64 | ||||
mingwX64 | ||||
macosX64 | ||||
macosArm64 | ||||
iosArm64 | ||||
iosX64 | ||||
iosSimulatorArm64 | ||||
JVM | linuxX64 - mingwX64 - macosX64 - macosArm64 - androidArm64 - |
androidArm32 - androidX86 - androidX64 - |
For Kotlin/JS, we use the new IR. We also use the new memory model in Kotlin/Native. Keep this in mind when using Multik in your multiplatform projects.
Note:
* on ubuntu 18.04 and older multik-openblas
doesn't work due to older versions of glibc.
* multik-openblas
for desktop targets (linuxX64, mingwX64, macosX64, macosArm64) is experimental and unstable.
We will improve stability and perfomance as Kotlin/Native evolves.
* JVM target multik-openblas
for Android only supports arm64-v8a processors.
Quickstart
Visit Multik documentation for a detailed feature overview.
Creating arrays
Array properties
Arithmetic operations
Array mathematics
See documentation for other methods of mathematics, linear algebra, statistics.
Aggregate functions
Copying arrays
Operations of Iterable
Indexing/Slicing/Iterating
Inplace
Building
To build the entire project, you need to set up an environment for building multik-openblas
:
* JDK 1.8 or higher
* JAVA_HOME environment - to search for jni files
* Compilers gcc, g++, gfortran version 8 or higher.
It is important that they are of the same version.
Run ./gradlew assemble
to build all modules.
If you don't need to build multik-openblas
,
just disable the cmake_build
task and build the module you need.
Contributing
There is an opportunity to contribute to the project: 1. Implement math, linalg, stat interfaces. 2. Create your own engine successor from Engine, for example - JvmEngine. 3. Use mk.addEngine and mk.setEngine to use your implementation.