1+ [ ![ Kotlin Alpha] ( https://kotl.in/badges/alpha.svg )] ( https://kotlinlang.org/docs/components-stability.html )
12[ ![ JetBrains incubator project] ( https://jb.gg/badges/incubator.svg )] ( https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub )
2- [ ![ Maven Central] ( https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/multik-api )] ( https://mvnrepository.com/artifact/org.jetbrains.kotlinx/multik-api )
3+ [ ![ Maven Central] ( https://img.shields.io/maven-central/v/org.jetbrains.kotlinx/multik-core )] ( https://mvnrepository.com/artifact/org.jetbrains.kotlinx/multik-core )
34[ ![ GitHub license] ( https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat )] ( https://www.apache.org/licenses/LICENSE-2.0 )
45
56# Multik
67
78Multidimensional array library for Kotlin.
89
910## Modules
10- * multik-api &mdash ; contains ndarrays, methods called on them and [ math] , [ stat] and [ linalg] interfaces.
11- * multik-default &mdash ; implementation including ` jvm ` and ` native ` for performance.
12- * multik-jvm &mdash ; implementation of [ math] , [ stat] and [ linalg] interfaces on JVM.
13- * multik-native &mdash ; implementation of [ math] , [ stat] and [ linalg] interfaces in native code using OpenBLAS.
11+ * ` multik-core ` &mdash ; contains ndarrays, methods called on them and [ math] , [ stat] and [ linalg] interfaces.
12+ * ` multik-default ` &mdash ; implementation including ` multik-kotlin ` and ` multik-openblas ` for performance.
13+ * ` multik-kotlin ` &mdash ; implementation of [ math] , [ stat] and [ linalg] interfaces on JVM.
14+ * ` multik-openblas ` &mdash ; implementation of [ math] , [ stat] and [ linalg] interfaces in native code using OpenBLAS.
1415
1516## Using in your projects
17+ ### Gradle
1618In your Gradle build script:
17191 . Add the Maven Central Repository.
18- 2 . Add the ` org.jetbrains.kotlinx:multik-api :$multik_version ` api dependency.
20+ 2 . Add the ` org.jetbrains.kotlinx:multik-core :$multik_version ` api dependency.
19213 . Add an implementation dependency: ` org.jetbrains.kotlinx:multik-default:$multik_version ` ,
20- ` org.jetbrains.kotlinx:multik-jvm :$multik_version ` or ` org.jetbrains.kotlinx:multik-native :$multik_version ` .
22+ ` org.jetbrains.kotlinx:multik-kotlin :$multik_version ` or ` org.jetbrains.kotlinx:multik-openblas :$multik_version ` .
2123
2224` build.gradle ` :
2325``` groovy
@@ -26,8 +28,8 @@ repositories {
2628}
2729
2830dependencies {
29- implementation "org.jetbrains.kotlinx:multik-api :0.1.1 "
30- implementation "org.jetbrains.kotlinx:multik-default:0.1.1 "
31+ implementation "org.jetbrains.kotlinx:multik-core :0.2.0 "
32+ implementation "org.jetbrains.kotlinx:multik-default:0.2.0 "
3133}
3234```
3335
@@ -38,11 +40,73 @@ repositories {
3840}
3941
4042dependencies {
41- implementation(" org.jetbrains.kotlinx:multik-api :0.1.1 " )
42- implementation(" org.jetbrains.kotlinx:multik-default:0.1.1 " )
43+ implementation(" org.jetbrains.kotlinx:multik-core :0.2.0 " )
44+ implementation(" org.jetbrains.kotlinx:multik-default:0.2.0 " )
4345}
4446```
4547
48+ For a multiplatform project, set the dependency in a common block:
49+
50+ ``` kotlin
51+ kotlin {
52+ sourceSets {
53+ val commonMain by getting {
54+ dependencies {
55+ implementation(" org.jetbrains.kotlinx:multik-core:0.2.0" )
56+ }
57+ }
58+ }
59+ }
60+ ```
61+
62+ or in a platform-specific block:
63+
64+ ``` kotlin
65+ kotlin {
66+ sourceSets {
67+ val jvmName by getting {
68+ dependencies {
69+ implementation(" org.jetbrains.kotlinx:multik-core-jvm:0.2.0" )
70+ }
71+ }
72+ }
73+ }
74+ ```
75+
76+ ### Jupyter Notebook
77+ Install [ Kotlin kernel] ( https://github.com/Kotlin/kotlin-jupyter ) for
78+ [ Jupyter] ( https://jupyter.org/ )
79+ or just visit to [ Datalore] ( https://datalore.jetbrains.com/ ) .
80+
81+ Import stable ` multik ` version into notebook:
82+ ```
83+ %use multik
84+ ```
85+
86+ ## Support platforms
87+
88+ | Platforms | ` multik-core ` | ` multik-kotlin ` | ` multik-openblas ` | ` multik-default ` |
89+ | :---------------------:| :------------------:| :------------------:| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
90+ | ** JS** | :white_check_mark : | :white_check_mark : | :x : | :white_check_mark : |
91+ | ** linuxX64** | :white_check_mark : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
92+ | ** mingwX64** | :white_check_mark : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
93+ | ** macosX64** | :white_check_mark : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
94+ | ** macosArm64** | :white_check_mark : | :white_check_mark : | :white_check_mark : | :white_check_mark : |
95+ | ** iosArm64** | :white_check_mark : | :white_check_mark : | :x : | :white_check_mark : |
96+ | ** iosX64** | :white_check_mark : | :white_check_mark : | :x : | :white_check_mark : |
97+ | ** iosSimulatorArm64** | :white_check_mark : | :white_check_mark : | :x : | :white_check_mark : |
98+ | ** JVM** | :white_check_mark : | :white_check_mark : | linuxX64 - :white_check_mark : <br />mingwX64 - :white_check_mark : <br />macosX64 - :white_check_mark : <br />macosArm64 - :white_check_mark : <br />androidArm64 - :white_check_mark : | linuxX64 - :white_check_mark : <br />mingwX64 - :white_check_mark : <br />macosX64 - :white_check_mark : <br />macosArm64 - :white_check_mark : <br />androidArm64 - :white_check_mark : |
99+
100+ For Kotlin/JS, we use the new [ IR] ( https://kotlinlang.org/docs/js-ir-compiler.html ) .
101+ We also use the [ new memory model] ( https://blog.jetbrains.com/kotlin/2021/08/try-the-new-kotlin-native-memory-manager-development-preview/ )
102+ in Kotlin/Native. Keep this in mind when using Multik in your multiplatform projects.
103+
104+ ** Note** :
105+ * on ubuntu 18.04 and older ` multik-openblas ` doesn't work due to older versions of _ ** glibc** _ .
106+ * ` multik-openblas ` for desktop targets (_ linuxX64_ , _ mingwX64_ , _ macosX64_ , _ macosArm64_ ) is experimental and unstable.
107+ We will improve stability and perfomance as _ Kotlin/Native_ evolves.
108+ * JVM target ` multik-openblas ` for Android only supports ** arm64-v8a** processors.
109+
46110## Quickstart
47111
48112Visit [ Multik documentation] ( https://kotlin.github.io/multik ) for a detailed feature overview.
@@ -101,7 +165,7 @@ mk.d2arrayIndices(3, 3) { i, j -> ComplexFloat(i, j) }
101165[2.0+(0.0)i, 2.0+(1.0)i, 2.0+(2.0)i]]
102166 */
103167
104- mk.arange<Long >(10 , 25 , 5 ) // creare an array with elements in the interval [19 , 25) with step 5
168+ mk.arange<Long >(10 , 25 , 5 ) // creare an array with elements in the interval [10 , 25) with step 5
105169/* [10, 15, 20] */
106170
107171mk.linspace<Double >(0 , 2 , 9 ) // create an array of 9 elements in the interval [0, 2]
@@ -152,6 +216,12 @@ f * d // multiplication
152216```
153217
154218#### Array mathematics
219+
220+ See documentation for other methods of
221+ [ mathematics] ( https://kotlin.github.io/multik/multik-core/org.jetbrains.kotlinx.multik.api.math/index.html ) ,
222+ [ linear algebra] ( https://kotlin.github.io/multik/multik-core/org.jetbrains.kotlinx.multik.api.linalg/index.html ) ,
223+ [ statistics] ( https://kotlin.github.io/multik/multik-core/org.jetbrains.kotlinx.multik.api.stat/index.html ) .
224+
155225``` kotlin
156226a.sin() // element-wise sin, equivalent to mk.math.sin(a)
157227a.cos() // element-wise cos, equivalent to mk.math.cos(a)
@@ -160,8 +230,6 @@ b.exp() // element-wise exp, equivalent to mk.math.exp(b)
160230d dot e // dot product, equivalent to mk.linalg.dot(d, e)
161231```
162232
163- See [ documentation] ( https://kotlin.github.io/multik ) for other linear algebra methods.
164-
165233#### Aggregate functions
166234``` kotlin
167235mk.math.sum(c) // array-wise sum
@@ -229,24 +297,21 @@ a.inplace {
229297```
230298
231299## Building
232- Multik uses BLAS and LAPACK for implementing algebraic operations.
233- Therefore, you would need a C ++ compiler and gfortran.
234- Run ` ./gradlew assemble ` to build all modules.
235- * To build api module run ` ./gradlew multik-api:assemble ` .
236- * To build jvm module run ` ./gradlew multik-jvm:assemble ` .
237- * To build native module run ` ./gradlew multik-native:assemble ` .
238- To reuse ` multik-native ` in the future, you must first build ` multik_jni ` and place the native library in
239- ` multik-native/build/libs `
240- * To build default module run ` ./gradlew multik-native:assemble ` then ` ./gradlew multik-default:assemble ` .
300+ To build the entire project, you need to set up an environment for building ` multik-openblas ` :
301+ * JDK 1.8 or higher
302+ * _ JAVA_HOME_ environment - to search for jni files
303+ * Compilers _ gcc_ , _ g++_ , _ gfortran_ version 8 or higher.
304+ It is important that they are of the same version.
241305
242- ## Testing
243- ` ./gradlew test `
306+ Run ` ./gradlew assemble ` to build all modules.
307+ If you don't need to build ` multik-openblas ` ,
308+ just disable the ` cmake_build ` task and build the module you need.
244309
245310## Contributing
246311There is an opportunity to contribute to the project:
247- 1 . Implement [ math] ( multik-api /src/main/kotlin/org/jetbrains/kotlinx/multik/api/math/Math.kt ) ,
248- [ linalg] ( multik-api /src/main/kotlin/org/jetbrains/kotlinx/multik/api/linalg/LinAlg.kt ) ,
249- [ stat] ( multik-api /src/main/kotlin/org/jetbrains/kotlinx/multik/api/Statistics.kt ) interfaces.
250- 2 . Create your own engine successor from [ Engine] ( multik-api /src/main/kotlin/org/jetbrains/kotlinx/multik/api/Engine.kt ) , for example - [ JvmEngine] ( multik-jvm /src/main/kotlin/org/jetbrains/kotlinx/multik/jvm/JvmEngine.kt ) .
251- 3 . Use [ mk.addEngine] ( https://github.com/devcrocod/multik/blob/972b18cfd2952abd811fabf34461d238e55c5587/multik-api /src/main/kotlin/org/jetbrains/multik/api/Multik.kt#L23 ) and [ mk.setEngine] ( https://github.com/devcrocod/multik/blob/972b18cfd2952abd811fabf34461d238e55c5587/multik-api /src/main/kotlin/org/jetbrains/multik/api/Multik.kt#L27 )
312+ 1 . Implement [ math] ( multik-core /src/main/kotlin/org/jetbrains/kotlinx/multik/api/math/Math.kt ) ,
313+ [ linalg] ( multik-core /src/main/kotlin/org/jetbrains/kotlinx/multik/api/linalg/LinAlg.kt ) ,
314+ [ stat] ( multik-core /src/main/kotlin/org/jetbrains/kotlinx/multik/api/Statistics.kt ) interfaces.
315+ 2 . Create your own engine successor from [ Engine] ( multik-core /src/main/kotlin/org/jetbrains/kotlinx/multik/api/Engine.kt ) , for example - [ JvmEngine] ( multik-kotlin /src/main/kotlin/org/jetbrains/kotlinx/multik/jvm/JvmEngine.kt ) .
316+ 3 . Use [ mk.addEngine] ( https://github.com/devcrocod/multik/blob/972b18cfd2952abd811fabf34461d238e55c5587/multik-core /src/main/kotlin/org/jetbrains/multik/api/Multik.kt#L23 ) and [ mk.setEngine] ( https://github.com/devcrocod/multik/blob/972b18cfd2952abd811fabf34461d238e55c5587/multik-core /src/main/kotlin/org/jetbrains/multik/api/Multik.kt#L27 )
252317to use your implementation.
0 commit comments