@@ -26,8 +26,8 @@ repositories {
2626}
2727
2828dependencies {
29- implementation "org.jetbrains.kotlinx:multik-api:0.0.1 "
30- implementation "org.jetbrains.kotlinx:multik-default:0.0.1 "
29+ implementation "org.jetbrains.kotlinx:multik-api:0.1.0 "
30+ implementation "org.jetbrains.kotlinx:multik-default:0.1.0 "
3131}
3232```
3333
@@ -38,8 +38,8 @@ repositories {
3838}
3939
4040dependencies {
41- implementation(" org.jetbrains.kotlinx:multik-api:0.0.1 " )
42- implementation(" org.jetbrains.kotlinx:multik-default:0.0.1 " )
41+ implementation(" org.jetbrains.kotlinx:multik-api:0.1.0 " )
42+ implementation(" org.jetbrains.kotlinx:multik-default:0.1.0 " )
4343}
4444```
4545
@@ -52,11 +52,13 @@ Visit [Multik documentation](https://kotlin.github.io/multik) for a detailed fea
5252``` kotlin
5353val a = mk.ndarray(mk[1 , 2 , 3 ])
5454/* [1, 2, 3] */
55+
5556val b = mk.ndarray(mk[mk[1.5 , 2.1 , 3.0 ], mk[4.0 , 5.0 , 6.0 ]])
5657/*
5758[[1.5, 2.1, 3.0],
5859[4.0, 5.0, 6.0]]
5960*/
61+
6062val c = mk.ndarray(mk[mk[mk[1.5f , 2f , 3f ], mk[4f , 5f , 6f ]], mk[mk[3f , 2f , 1f ], mk[4f , 5f , 6f ]]])
6163/*
6264[[[1.5, 2.0, 3.0],
@@ -67,7 +69,7 @@ val c = mk.ndarray(mk[mk[mk[1.5f, 2f, 3f], mk[4f, 5f, 6f]], mk[mk[3f, 2f, 1f], m
6769*/
6870
6971
70- mk.empty <Double , D2 >(3 , 4 ) // create an array of zeros
72+ mk.zeros <Double >(3 , 4 ) // create an array of zeros
7173/*
7274[[0.0, 0.0, 0.0, 0.0],
7375[0.0, 0.0, 0.0, 0.0],
@@ -91,10 +93,20 @@ mk.d3array(2, 2, 3) { it * it } // create an array of 3 dimension
9193[[36, 49, 64],
9294[81, 100, 121]]]
9395*/
96+
97+ mk.d2arrayIndices(3 , 3 ) { i, j -> ComplexFloat (i, j) }
98+ /*
99+ [[0.0+(0.0)i, 0.0+(1.0)i, 0.0+(2.0)i],
100+ [1.0+(0.0)i, 1.0+(1.0)i, 1.0+(2.0)i],
101+ [2.0+(0.0)i, 2.0+(1.0)i, 2.0+(2.0)i]]
102+ */
103+
94104mk.arange<Long >(10 , 25 , 5 ) // creare an array with elements in the interval [19, 25) with step 5
95105/* [10, 15, 20] */
106+
96107mk.linspace<Double >(0 , 2 , 9 ) // create an array of 9 elements in the interval [0, 2]
97108/* [0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0] */
109+
98110val e = mk.identity<Double >(3 ) // create an identity array of shape (3, 3)
99111/*
100112[[1.0, 0.0, 0.0],
@@ -141,13 +153,15 @@ f * d // multiplication
141153
142154#### Array mathematics
143155``` kotlin
144- mk.math. sin(a ) // element-wise sin
145- mk.math. cos(a ) // element-wise cos
146- mk.math. log(b ) // element-wise natural logarithm
147- mk.math. exp(b ) // element-wise exp
148- mk.linalg.dot(d, e) // dot product
156+ a. sin() // element-wise sin, equivalent to mk.math.sin(a)
157+ a. cos() // element-wise cos, equivalent to mk.math.cos(a)
158+ b. log() // element-wise natural logarithm, equivalent to mk.math.log(b)
159+ b. exp() // element-wise exp, equivalent to mk.math.exp(b)
160+ d dot e // dot product, equivalent to mk.linalg.dot(d, e)
149161```
150162
163+ See [ documentation] ( https://kotlin.github.io/multik ) for other linear algebra methods.
164+
151165#### Aggregate functions
152166``` kotlin
153167mk.math.sum(c) // array-wise sum
@@ -160,7 +174,7 @@ mk.stat.median(b) // meadian
160174
161175#### Copying arrays
162176``` kotlin
163- val f = a.clone () // create a copy of the array and its data
177+ val f = a.copy () // create a copy of the array and its data
164178val h = b.deepCopy() // create a copy of the array and copy the meaningful data
165179```
166180
@@ -177,7 +191,7 @@ c.sorted() // sort elements
177191a[2 ] // select the element at the 2 index
178192b[1 , 2 ] // select the element at row 1 column 2
179193b[1 ] // select row 1
180- b[0 .r . .2 , 1 ] // select elements at rows 0 and 1 in column 1
194+ b[0 .. 2 , 1 ] // select elements at rows 0 and 1 in column 1
181195b[0 .. 1 .. 1 ] // select all elements at row 0
182196
183197for (el in b) {
@@ -215,19 +229,24 @@ a.inplace {
215229```
216230
217231## Building
218- Multik uses blas for implementing algebraic operations. Therefore, you would need a C ++ compiler.
232+ Multik uses BLAS and LAPACK for implementing algebraic operations.
233+ Therefore, you would need a C ++ compiler and gfortran.
219234Run ` ./gradlew assemble ` to build all modules.
220235* To build api module run ` ./gradlew multik-api:assemble ` .
221236* To build jvm module run ` ./gradlew multik-jvm:assemble ` .
222- * To build native module run ` ./gradlew multik-native: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 `
223240* To build default module run ` ./gradlew multik-native:assemble ` then ` ./gradlew multik-default:assemble ` .
224241
225242## Testing
226243` ./gradlew test `
227244
228245## Contributing
229246There is an opportunity to contribute to the project:
230- 1 . Implement [ math] ( multik-api/src/main/kotlin/org/jetbrains/kotlinx/multik/api/Math.kt ) and [ linalg] ( multik-api/src/main/kotlin/org/jetbrains/kotlinx/multik/api/LinAlg.kt ) interfaces.
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.
2312502 . 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 ) .
2322513 . 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 )
233252to use your implementation.
0 commit comments