diff --git a/LICENSE b/LICENSE
index 8541f77f..2f682441 100644
--- a/LICENSE
+++ b/LICENSE
@@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright 2000-2021 JetBrains s.r.o.
+ Copyright 2000-2022 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/README.md b/README.md
index e54dedc4..4a0f3847 100644
--- a/README.md
+++ b/README.md
@@ -8,12 +8,13 @@
Multidimensional array library for Kotlin.
## Modules
-* multik-core — contains ndarrays, methods called on them and [math], [stat] and [linalg] interfaces.
-* multik-default — implementation including `jvm` and `native` 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.
+* `multik-core` — contains ndarrays, methods called on them and [math], [stat] and [linalg] interfaces.
+* `multik-default` — implementation including `multik-kotlin` and `multik-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.
@@ -27,8 +28,8 @@ repositories {
}
dependencies {
- implementation "org.jetbrains.kotlinx:multik-core:0.1.1"
- implementation "org.jetbrains.kotlinx:multik-default:0.1.1"
+ implementation "org.jetbrains.kotlinx:multik-core:0.2.0"
+ implementation "org.jetbrains.kotlinx:multik-default:0.2.0"
}
```
@@ -39,11 +40,73 @@ repositories {
}
dependencies {
- implementation("org.jetbrains.kotlinx:multik-core:0.1.1")
- implementation("org.jetbrains.kotlinx:multik-default:0.1.1")
+ implementation("org.jetbrains.kotlinx:multik-core:0.2.0")
+ implementation("org.jetbrains.kotlinx:multik-default:0.2.0")
}
```
+For a multiplatform project, set the dependency in a common block:
+
+```kotlin
+kotlin {
+ sourceSets {
+ val commonMain by getting {
+ dependencies {
+ implementation("org.jetbrains.kotlinx:multik-core:0.2.0")
+ }
+ }
+ }
+}
+```
+
+or in a platform-specific block:
+
+```kotlin
+kotlin {
+ sourceSets {
+ val jvmName by getting {
+ dependencies {
+ implementation("org.jetbrains.kotlinx:multik-core-jvm:0.2.0")
+ }
+ }
+ }
+}
+```
+
+### Jupyter Notebook
+Install [Kotlin kernel](https://github.com/Kotlin/kotlin-jupyter) for
+[Jupyter](https://jupyter.org/)
+or just visit to [Datalore](https://datalore.jetbrains.com/).
+
+Import stable `multik` version into notebook:
+```
+%use multik
+```
+
+## Support platforms
+
+| Platforms | `multik-core` | `multik-kotlin` | `multik-openblas` | `multik-default` |
+|:---------------------:|:------------------:|:------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
+| **JS** | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
+| **linuxX64** | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
+| **mingwX64** | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
+| **macosX64** | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
+| **macosArm64** | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
+| **iosArm64** | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
+| **iosX64** | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
+| **iosSimulatorArm64** | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |
+| **JVM** | :white_check_mark: | :white_check_mark: | linuxX64 - :white_check_mark:
mingwX64 - :white_check_mark:
macosX64 - :white_check_mark:
macosArm64 - :white_check_mark:
androidArm64 - :white_check_mark: | linuxX64 - :white_check_mark:
mingwX64 - :white_check_mark:
macosX64 - :white_check_mark:
macosArm64 - :white_check_mark:
androidArm64 - :white_check_mark: |
+
+For Kotlin/JS, we use the new [IR](https://kotlinlang.org/docs/js-ir-compiler.html).
+We also use the [new memory model](https://blog.jetbrains.com/kotlin/2021/08/try-the-new-kotlin-native-memory-manager-development-preview/)
+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](https://kotlin.github.io/multik) for a detailed feature overview.
@@ -153,6 +216,12 @@ f * d // multiplication
```
#### Array mathematics
+
+See documentation for other methods of
+[mathematics](https://kotlin.github.io/multik/multik-core/org.jetbrains.kotlinx.multik.api.math/index.html),
+[linear algebra](https://kotlin.github.io/multik/multik-core/org.jetbrains.kotlinx.multik.api.linalg/index.html),
+[statistics](https://kotlin.github.io/multik/multik-core/org.jetbrains.kotlinx.multik.api.stat/index.html).
+
```kotlin
a.sin() // element-wise sin, equivalent to mk.math.sin(a)
a.cos() // element-wise cos, equivalent to mk.math.cos(a)
@@ -161,8 +230,6 @@ b.exp() // element-wise exp, equivalent to mk.math.exp(b)
d dot e // dot product, equivalent to mk.linalg.dot(d, e)
```
-See [documentation](https://kotlin.github.io/multik) for other linear algebra methods.
-
#### Aggregate functions
```kotlin
mk.math.sum(c) // array-wise sum
@@ -230,18 +297,15 @@ a.inplace {
```
## Building
-Multik uses BLAS and LAPACK for implementing algebraic operations.
-Therefore, you would need a C ++ compiler and gfortran.
+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.
-* To build api module run `./gradlew multik-core:assemble`.
-* To build jvm module run `./gradlew multik-kotlin:assemble`.
-* To build native module run `./gradlew multik-openblas:assemble`.
-To reuse `multik-openblas` in the future, you must first build `multik_jni` and place the native library in
-`multik-openblas/build/libs`
-* To build default module run `./gradlew multik-openblas:assemble` then `./gradlew multik-default:assemble`.
-
-## Testing
-`./gradlew test`
+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:
diff --git a/build.gradle.kts b/build.gradle.kts
index 58d45d49..9bf4d567 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
import java.time.Duration
diff --git a/gradle.properties b/gradle.properties
index a5b83270..d9ad1910 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,5 +1,5 @@
kotlin.code.style=official
-multik_version=0.2.0-dev-4
+multik_version=0.2.0
# Kotlin
systemProp.kotlin_version=1.7.10
@@ -7,7 +7,7 @@ group=org.jetbrains.kotlinx
# Dependencies
systemProp.nexus_version=1.1.0
-systemProp.dokka_version=1.6.0
+systemProp.dokka_version=1.7.10
openblas_version=0.3.19
common_csv_version=1.9.0
diff --git a/gradle/publish.gradle b/gradle/publish.gradle
index d2b8161c..8b1f090e 100644
--- a/gradle/publish.gradle
+++ b/gradle/publish.gradle
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 85b299a2..ffbf66c2 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
#Thu Apr 09 14:05:51 MSK 2020
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
diff --git a/multik-core/build.gradle.kts b/multik-core/build.gradle.kts
index 4744bf82..dc47d888 100644
--- a/multik-core/build.gradle.kts
+++ b/multik-core/build.gradle.kts
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
plugins {
@@ -87,15 +87,22 @@ kotlin {
tasks.dokkaHtml.configure {
outputDirectory.set(rootProject.buildDir.resolve("dokka"))
+ suppressObviousFunctions.set(true)
+ suppressInheritedMembers.set(true)
dokkaSourceSets {
configureEach {
- includeNonPublic.set(false)
- skipEmptyPackages.set(false)
+ documentedVisibilities.set(
+ setOf(
+ org.jetbrains.dokka.DokkaConfiguration.Visibility.PUBLIC,
+ org.jetbrains.dokka.DokkaConfiguration.Visibility.PROTECTED
+ )
+ )
+ skipDeprecated.set(false)
jdkVersion.set(8)
noStdlibLink.set(false)
noJdkLink.set(false)
- samples.from(files("src/test/kotlin/samples/creation.kt"))
+ samples.from(files("src/commonTest/kotlin/samples/creation.kt"))
}
}
}
\ No newline at end of file
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/CreateNDArray.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/CreateNDArray.kt
index 7999c964..f01c9610 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/CreateNDArray.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/CreateNDArray.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api
@@ -15,10 +15,6 @@ import kotlin.math.ceil
/**
* Returns a new zero array with the specified shape.
- *
- * @param dims shape of the array.
- * @return [NDArray] of [D] dimension
- * @sample samples.NDArrayTest.empty
*/
@Deprecated("Use zeros instead.", ReplaceWith("mk.zeros(dims)"))
public inline fun Multik.empty(vararg dims: Int): NDArray {
@@ -34,11 +30,6 @@ public inline fun Multik.empty(vararg d
* Returns a new zero array of type [dtype] with the specified shape.
*
* Note: Generic type of elements [T] must match [dtype].
- *
- * @param dims shape of the array.
- * @param dtype array type.
- * @return [NDArray] of [D] dimension.
- * @sample samples.NDArrayTest.emptyWithDtype
*/
@Deprecated("Use zeros instead.", ReplaceWith("mk.zeros(dims)"))
public fun Multik.empty(dims: IntArray, dtype: DataType): NDArray {
@@ -50,25 +41,52 @@ public fun Multik.empty(dims: IntArray, dtype: DataType): NDA
}
/**
- * Returns a new zero array of type [T] with the specified shape.
+ * Returns a new zero array of 1 dim of type [T] with [dim1] size.
+ *
+ * @sample samples.NDArrayTest.zerosD1
*/
public inline fun Multik.zeros(dim1: Int): D1Array =
zeros(intArrayOf(dim1), DataType.ofKClass(T::class))
+/**
+ * Returns a new zero array of 2 dim of type [T] with ([dim1], [dim2]) shape.
+ *
+ * @sample samples.NDArrayTest.zerosD2
+ */
public inline fun Multik.zeros(dim1: Int, dim2: Int): D2Array =
zeros(intArrayOf(dim1, dim2), DataType.ofKClass(T::class))
+/**
+ * Returns a new zero array of 3 dim of type [T] with ([dim1], [dim2], [dim3]) shape.
+ *
+ * @sample samples.NDArrayTest.zerosD3
+ */
public inline fun Multik.zeros(dim1: Int, dim2: Int, dim3: Int): D3Array =
zeros(intArrayOf(dim1, dim2, dim3), DataType.ofKClass(T::class))
+/**
+ * Returns a new zero array of 4 dim of type [T] with ([dim1], [dim2], [dim3], [dim4]) shape.
+ *
+ * @sample samples.NDArrayTest.zerosD4
+ */
public inline fun Multik.zeros(dim1: Int, dim2: Int, dim3: Int, dim4: Int): D4Array =
zeros(intArrayOf(dim1, dim2, dim3, dim4), DataType.ofKClass(T::class))
+/**
+ * Returns a new zero array of N dim of type [T] with ([dim1], [dim2], [dim3], [dim4], [dims]) shape.
+ *
+ * @sample samples.NDArrayTest.zerosDN
+ */
public inline fun Multik.zeros(
dim1: Int, dim2: Int, dim3: Int, dim4: Int, vararg dims: Int
): NDArray =
zeros(intArrayOf(dim1, dim2, dim3, dim4) + dims, DataType.ofKClass(T::class))
+/**
+ * Returns a new zero array of type [T] with specify shape.
+ *
+ * @sample samples.NDArrayTest.zerosDNWithDtype
+ */
public fun Multik.zeros(dims: IntArray, dtype: DataType): NDArray {
val dim = dimensionOf(dims.size)
requireDimension(dim, dims.size)
@@ -78,25 +96,52 @@ public fun Multik.zeros(dims: IntArray, dtype: DataType): NDA
}
/**
- * Returns a new ones array of type [T] with the specified shape.
+ * Returns a new ones array of 1 dim of type [T] with [dim1] size.
+ *
+ * @sample samples.NDArrayTest.onesD1
*/
public inline fun Multik.ones(dim1: Int): D1Array =
ones(intArrayOf(dim1), DataType.ofKClass(T::class))
+/**
+ * Returns a new ones array of 2 dim of type [T] with ([dim1], [dim2]) shape.
+ *
+ * @sample samples.NDArrayTest.onesD2
+ */
public inline fun Multik.ones(dim1: Int, dim2: Int): D2Array =
ones(intArrayOf(dim1, dim2), DataType.ofKClass(T::class))
+/**
+ * Returns a new ones array of 3 dim of type [T] with ([dim1], [dim2], [dim3]) shape.
+ *
+ * @sample samples.NDArrayTest.onesD3
+ */
public inline fun Multik.ones(dim1: Int, dim2: Int, dim3: Int): D3Array =
ones(intArrayOf(dim1, dim2, dim3), DataType.ofKClass(T::class))
+/**
+ * Returns a new ones array of 4 dim of type [T] with ([dim1], [dim2], [dim3], [dim4]) shape.
+ *
+ * @sample samples.NDArrayTest.onesD4
+ */
public inline fun Multik.ones(dim1: Int, dim2: Int, dim3: Int, dim4: Int): D4Array =
ones(intArrayOf(dim1, dim2, dim3, dim4), DataType.ofKClass(T::class))
+/**
+ * Returns a new ones array of N dim of type [T] with ([dim1], [dim2], [dim3], [dim4], [dims]) shape.
+ *
+ * @sample samples.NDArrayTest.onesDN
+ */
public inline fun Multik.ones(
dim1: Int, dim2: Int, dim3: Int, dim4: Int, vararg dims: Int
): NDArray =
ones(intArrayOf(dim1, dim2, dim3, dim4) + dims, DataType.ofKClass(T::class))
+/**
+ * Returns a new ones array of N dim of type [T] with specify shape.
+ *
+ * @sample samples.NDArrayTest.onesDNWithDtype
+ */
@Suppress("IMPLICIT_CAST_TO_ANY", "UNCHECKED_CAST")
public fun Multik.ones(dims: IntArray, dtype: DataType): NDArray {
val dim = dimensionOf(dims.size)
@@ -1216,12 +1261,11 @@ public inline fun Multik.d1array(sizeD1: Int, noinline init: (
}
/**
- * Returns a 2-dimensions array.
+ * Creates a new array of the specified ([sizeD1], [sizeD2]) shape, where each element is calculated by calling
+ * the specified [init] function.
*
- * @param sizeD1 value of 1-dimension.
- * @param sizeD2 value of 2-dimension.
- * @param init initialization function.
- * @return [D2Array].
+ * The function [init] is called for each array element sequentially starting from the first one.
+ * It should return the value for an array element given its index.
* @sample samples.NDArrayTest.d2array
*/
public inline fun Multik.d2array(sizeD1: Int, sizeD2: Int, noinline init: (Int) -> T): D2Array {
@@ -1235,7 +1279,12 @@ public inline fun Multik.d2array(sizeD1: Int, sizeD2: Int, noi
}
/**
+ * Creates a new 2-dimensions array of the specified ([sizeD1], [sizeD2]) shape, where each element is calculated by calling
+ * the specified [init] function.
*
+ * The function [init] is called for each array element sequentially starting from the first one.
+ * It should return the value for an array element given its indices.
+ * @sample samples.NDArrayTest.d2arrayIndices
*/
public inline fun Multik.d2arrayIndices(
sizeD1: Int, sizeD2: Int, init: (i: Int, j: Int) -> T
@@ -1255,13 +1304,11 @@ public inline fun Multik.d2arrayIndices(
}
/**
- * Returns a 3-dimensions array.
+ * Creates a new 3-dimensions array of the specified ([sizeD1], [sizeD2], [sizeD3]) shape, where each element is calculated by calling
+ * the specified [init] function.
*
- * @param sizeD1 value of 1-dimension.
- * @param sizeD2 value of 2-dimension.
- * @param sizeD3 value of 3-dimension.
- * @param init initialization function.
- * @return [D3Array].
+ * The function [init] is called for each array element sequentially starting from the first one.
+ * It should return the value for an array element given its index.
* @sample samples.NDArrayTest.d3array
*/
public inline fun Multik.d3array(
@@ -1277,7 +1324,12 @@ public inline fun Multik.d3array(
}
/**
+ * Creates a new 3-dimensions array of the specified ([sizeD1], [sizeD2], [sizeD3]) shape, where each element is calculated by calling
+ * the specified [init] function.
*
+ * The function [init] is called for each array element sequentially starting from the first one.
+ * It should return the value for an array element given its indices.
+ * @sample samples.NDArrayTest.d3arrayIndices
*/
public inline fun Multik.d3arrayIndices(
sizeD1: Int, sizeD2: Int, sizeD3: Int, init: (i: Int, j: Int, k: Int) -> T
@@ -1301,14 +1353,11 @@ public inline fun Multik.d3arrayIndices(
}
/**
- * Returns a 4-dimensions array.
+ * Creates a new 4-dimensions array of the specified ([sizeD1], [sizeD2], [sizeD3], [sizeD4]) shape,
+ * where each element is calculated by calling the specified [init] function.
*
- * @param sizeD1 value of 1-dimension.
- * @param sizeD2 value of 2-dimension.
- * @param sizeD3 value of 3-dimension.
- * @param sizeD4 value of 4-dimension.
- * @param init initialization function.
- * @return [D4Array].
+ * The function [init] is called for each array element sequentially starting from the first one.
+ * It should return the value for an array element given its index.
* @sample samples.NDArrayTest.d4array
*/
public inline fun Multik.d4array(
@@ -1323,6 +1372,14 @@ public inline fun Multik.d4array(
return D4Array(data, shape = shape, dim = D4)
}
+/**
+ * Creates a new 4-dimensions array of the specified ([sizeD1], [sizeD2], [sizeD3], [sizeD4]) shape,
+ * where each element is calculated by calling the specified [init] function.
+ *
+ * The function [init] is called for each array element sequentially starting from the first one.
+ * It should return the value for an array element given its indices.
+ * @sample samples.NDArrayTest.d4arrayIndices
+ */
public inline fun Multik.d4arrayIndices(
sizeD1: Int, sizeD2: Int, sizeD3: Int, sizeD4: Int, init: (i: Int, j: Int, k: Int, m: Int) -> T
): D4Array {
@@ -1347,16 +1404,11 @@ public inline fun Multik.d4arrayIndices(
}
/**
- * Returns a new array with the specified shape, where each element is calculated by calling the specified
- * [init] function.
+ * Creates a new 4-dimensions array of the specified ([sizeD1], [sizeD2], [sizeD3], [sizeD4], [dims]) shape,
+ * where each element is calculated by calling the specified [init] function.
*
- * @param sizeD1 value of 1-dimension.
- * @param sizeD2 value of 2-dimension.
- * @param sizeD3 value of 3-dimension.
- * @param sizeD4 value of 4-dimension.
- * @param dims values other dimensions.
- * @param init initialization function.
- * @return [NDArray] of [DN] dimension.
+ * The function [init] is called for each array element sequentially starting from the first one.
+ * It should return the value for an array element given its index.
* @sample samples.NDArrayTest.dnarray
*/
public inline fun Multik.dnarray(
@@ -1367,9 +1419,6 @@ public inline fun Multik.dnarray(
* Returns a new array with the specified [shape], where each element is calculated by calling the specified
* [init] function.
*
- * @param shape array shape.
- * @param init initialization function.
- * @return [NDArray] of [DN] dimension.
* @sample samples.NDArrayTest.dnarrayWithDims
*/
public inline fun Multik.dnarray(
@@ -1388,18 +1437,36 @@ public inline fun Multik.dnarray(
/**
* Returns a new 1-dimension array from [items].
- *
- * @param items specified elements.
- * @return [D1Array].
- * @sample samples.NDArrayTest.ndarrayOf
*/
public fun Multik.ndarrayOf(vararg items: Byte): D1Array = ndarrayOfCommon(items.toTypedArray(), DataType.ByteDataType)
+/**
+ * Returns a new 1-dimension array from [items].
+ */
public fun Multik.ndarrayOf(vararg items: Short): D1Array = ndarrayOfCommon(items.toTypedArray(), DataType.ShortDataType)
+/**
+ * Returns a new 1-dimension array from [items].
+ * @sample samples.NDArrayTest.ndarrayOf
+ */
public fun Multik.ndarrayOf(vararg items: Int): D1Array = ndarrayOfCommon(items.toTypedArray(), DataType.IntDataType)
+/**
+ * Returns a new 1-dimension array from [items].
+ */
public fun Multik.ndarrayOf(vararg items: Long): D1Array = ndarrayOfCommon(items.toTypedArray(), DataType.LongDataType)
+/**
+ * Returns a new 1-dimension array from [items].
+ */
public fun Multik.ndarrayOf(vararg items: Float): D1Array = ndarrayOfCommon(items.toTypedArray(), DataType.FloatDataType)
+/**
+ * Returns a new 1-dimension array from [items].
+ */
public fun Multik.ndarrayOf(vararg items: Double): D1Array = ndarrayOfCommon(items.toTypedArray(), DataType.DoubleDataType)
+/**
+ * Returns a new 1-dimension array from [items].
+ */
public fun Multik.ndarrayOf(vararg items: ComplexFloat): D1Array = ndarrayOfCommon(items, DataType.ComplexFloatDataType)
+/**
+ * Returns a new 1-dimension array from [items].
+ */
public fun Multik.ndarrayOf(vararg items: ComplexDouble): D1Array = ndarrayOfCommon(items, DataType.ComplexDoubleDataType)
@@ -1509,6 +1576,9 @@ public inline fun Multik.linspace(start: Double, stop: Doub
return ret.asType()
}
+/**
+ * Return coordinate matrices from coordinate vectors.
+ */
public fun Multik.meshgrid(x: MultiArray, y: MultiArray): Pair, D2Array> =
Pair(mk.stack(List(y.size) { x }), mk.stack(List(x.size) { y }, axis = 1))
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/Engine.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/Engine.kt
index ec108cd1..6eb38ab4 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/Engine.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/Engine.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api
@@ -8,19 +8,39 @@ import org.jetbrains.kotlinx.multik.api.linalg.LinAlg
import org.jetbrains.kotlinx.multik.api.math.Math
import org.jetbrains.kotlinx.multik.api.stat.Statistics
+/**
+ * Type engine implementations.
+ *
+ * @param name engine type name
+ */
public sealed class EngineType(public val name: String)
+/**
+ * Engine type for default implementation.
+ */
public object DefaultEngineType : EngineType("DEFAULT")
+/**
+ * Engine type for "pure kotlin" implementation.
+ */
public object KEEngineType : EngineType("KOTLIN")
+/**
+ * Engine type for implementation with OpenBLAS.
+ */
public object NativeEngineType : EngineType("NATIVE")
+/**
+ * Engine provider.
+ */
public expect fun enginesProvider(): Map
/**
* This class gives access to different implementations of [LinAlg], [Math], [Statistics].
* When initializing [Multik], it loads engines, by default `DEFAULT` implementation is used.
+ *
+ * @property name engine name
+ * @property type [EngineType]
*/
public abstract class Engine {
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/Multik.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/Multik.kt
index 18d1373f..1d0769a2 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/Multik.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/Multik.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/LinAlg.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/LinAlg.kt
index fc6e58d4..c521c5e5 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/LinAlg.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/LinAlg.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api.linalg
@@ -14,6 +14,9 @@ import org.jetbrains.kotlinx.multik.ndarray.data.NDArray
*/
public interface LinAlg {
+ /**
+ * instance of [LinAlgEx]
+ */
public val linAlgEx: LinAlgEx
/**
@@ -21,8 +24,4 @@ public interface LinAlg {
*/
public fun pow(mat: MultiArray, n: Int): NDArray
-// /**
-// * Matrix ov vector norm. The default is Frobenius norm.
-// */
-// public fun norm(mat: MultiArray, p: Int = 2): Double
}
\ No newline at end of file
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/LinAlgEx.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/LinAlgEx.kt
index a263b8d7..a7cc405c 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/LinAlgEx.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/LinAlgEx.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api.linalg
@@ -13,38 +13,121 @@ import org.jetbrains.kotlinx.multik.ndarray.data.*
* Extension interface for [LinAlg] for improved type support.
*/
public interface LinAlgEx {
+ /**
+ * Returns inverse of a double matrix from numeric matrix
+ */
public fun inv(mat: MultiArray): NDArray
+ /**
+ * Returns inverse float matrix
+ */
public fun invF(mat: MultiArray): NDArray
+ /**
+ * Returns inverse complex matrix
+ */
public fun invC(mat: MultiArray): NDArray
+ /**
+ * Solve a linear matrix equation, or system of linear scalar equations.
+ */
public fun solve(a: MultiArray, b: MultiArray): NDArray
+ /**
+ * Solve a linear matrix equation, or system of linear scalar equations.
+ */
public fun solveF(a: MultiArray, b: MultiArray): NDArray
+ /**
+ * Solve a linear matrix equation, or system of linear scalar equations.
+ */
public fun solveC(a: MultiArray, b: MultiArray): NDArray
+ /**
+ * Returns norm of float matrix
+ */
public fun normF(mat: MultiArray, norm: Norm = Norm.Fro): Float
-
+ /**
+ * Returns norm of double matrix
+ */
public fun norm(mat: MultiArray, norm: Norm = Norm.Fro): Double
+ /**
+ * Returns QR decomposition of the numeric matrix
+ */
public fun qr(mat: MultiArray): Pair, D2Array>
+ /**
+ * Returns QR decomposition of the float matrix
+ */
public fun qrF(mat: MultiArray): Pair, D2Array>
+ /**
+ * Returns QR decomposition of the complex matrix
+ */
public fun qrC(mat: MultiArray): Pair, D2Array>
+ /**
+ * Returns PLU decomposition of the numeric matrix
+ */
public fun plu(mat: MultiArray): Triple, D2Array, D2Array>
+ /**
+ * Returns PLU decomposition of the float matrix
+ */
public fun pluF(mat: MultiArray): Triple, D2Array, D2Array>
+ /**
+ * Returns PLU decomposition of the complex matrix
+ */
public fun pluC(mat: MultiArray): Triple, D2Array, D2Array>
+ /**
+ * Calculates the eigenvalues and eigenvectors of a numeric matrix
+ * @return a pair of a vector of eigenvalues and a matrix of eigenvectors
+ */
public fun eig(mat: MultiArray): Pair, D2Array>
+ /**
+ * Calculates the eigenvalues and eigenvectors of a float matrix
+ * @return a pair of a vector of eigenvalues and a matrix of eigenvectors
+ */
public fun eigF(mat: MultiArray): Pair, D2Array>
+ /**
+ * Calculates the eigenvalues and eigenvectors of a complex matrix
+ * @return a pair of a vector of eigenvalues and a matrix of eigenvectors
+ */
public fun eigC(mat: MultiArray): Pair, D2Array>
+ /**
+ * Calculates the eigenvalues of a numeric matrix.
+ * @return [ComplexDouble] vector
+ */
public fun eigVals(mat: MultiArray): D1Array
+ /**
+ * Calculates the eigenvalues of a float matrix
+ * @return [ComplexFloat] vector
+ */
public fun eigValsF(mat: MultiArray): D1Array
+ /**
+ * Calculates the eigenvalues of a float matrix
+ * @return complex vector
+ */
public fun eigValsC(mat: MultiArray): D1Array
+ /**
+ * Dot products of two number matrices.
+ */
public fun dotMM(a: MultiArray, b: MultiArray): NDArray
+ /**
+ * Dot products of two complex matrices.
+ */
public fun dotMMComplex(a: MultiArray, b: MultiArray): NDArray
+ /**
+ * Dot products of number matrix and number vector.
+ */
public fun dotMV(a: MultiArray, b: MultiArray): NDArray
+ /**
+ * Dot products of complex matrix and complex vector.
+ */
public fun dotMVComplex(a: MultiArray, b: MultiArray): NDArray
+ /**
+ * Dot products of two number vectors. Scalar product.
+ */
public fun dotVV(a: MultiArray, b: MultiArray): T
+ /**
+ * Dot products of two complex vectors. Scalar product.
+ */
public fun dotVVComplex(a: MultiArray, b: MultiArray): T
}
\ No newline at end of file
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/NormClassification.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/NormClassification.kt
index 72cd3b18..50133ba0 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/NormClassification.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/NormClassification.kt
@@ -1,8 +1,32 @@
+/*
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
package org.jetbrains.kotlinx.multik.api.linalg
+/**
+ * Matrix norm types.
+ *
+ * @property lapackCode value for lapack
+ */
public enum class Norm(public val lapackCode: Char) {
+ /**
+ * max(abs(A(i,j)))
+ */
Max('M'),
+
+ /**
+ * denotes the one norm of a matrix (maximum column sum)
+ */
N1('1'),
+
+ /**
+ * denotes the infinity norm of a matrix (maximum row sum)
+ */
Inf('I'),
+
+ /**
+ * denotes the Frobenius norm of a matrix (square root of sum of squares)
+ */
Fro('F')
}
\ No newline at end of file
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/_linalg.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/_linalg.kt
index b6be0bb4..5a29c51b 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/_linalg.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/_linalg.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api.linalg
@@ -12,20 +12,50 @@ import org.jetbrains.kotlinx.multik.ndarray.data.MultiArray
import org.jetbrains.kotlinx.multik.ndarray.data.NDArray
import kotlin.jvm.JvmName
+/**
+ * Returns the matrix product of two numeric matrices.
+ *
+ * same as [LinAlg.dot]
+ */
@JvmName("dotDefMMNumber")
public infix fun MultiArray.dot(b: MultiArray): NDArray = mk.linalg.linAlgEx.dotMM(this, b)
+/**
+ * Returns the matrix product of two complex matrices.
+ *
+ * same as [LinAlg.dot]
+ */
@JvmName("dotDefMMComplex")
public infix fun MultiArray.dot(b: MultiArray): NDArray = mk.linalg.linAlgEx.dotMMComplex(this, b)
+/**
+ * Returns the matrix product of a numeric matrix and a numeric vector.
+ *
+ * same as [LinAlg.dot]
+ */
@JvmName("dotDefMVNumber")
public infix fun MultiArray.dot(b: MultiArray): NDArray = mk.linalg.linAlgEx.dotMV(this, b)
+/**
+ * Returns the matrix product of a complex matrix and a complex vector.
+ *
+ * same as [LinAlg.dot]
+ */
@JvmName("dotDefMVComplex")
public infix fun MultiArray.dot(b: MultiArray): NDArray = mk.linalg.linAlgEx.dotMVComplex(this, b)
+/**
+ * Returns the product of two numeric vectors.
+ *
+ * same as [LinAlg.dot]
+ */
@JvmName("dotDefVVNumber")
public infix fun MultiArray.dot(b: MultiArray): T = mk.linalg.linAlgEx.dotVV(this, b)
+/**
+ * Returns the product of two complex vectors.
+ *
+ * same as [LinAlg.dot]
+ */
@JvmName("dotDefVVComplex")
public infix fun MultiArray.dot(b: MultiArray): T = mk.linalg.linAlgEx.dotVVComplex(this, b)
\ No newline at end of file
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/dot.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/dot.kt
index c9298e05..87f16f04 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/dot.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/dot.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api.linalg
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/eigvals.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/eigvals.kt
index 069d071c..2bc22845 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/eigvals.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/eigvals.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api.linalg
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/inverse.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/inverse.kt
index b2f48d53..1cdfd3ce 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/inverse.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/inverse.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api.linalg
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/norm.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/norm.kt
index 78d6e7eb..835a99ed 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/norm.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/norm.kt
@@ -1,3 +1,7 @@
+/*
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
package org.jetbrains.kotlinx.multik.api.linalg
import org.jetbrains.kotlinx.multik.ndarray.data.D2
@@ -11,7 +15,7 @@ import kotlin.jvm.JvmName
public fun LinAlg.norm(mat: MultiArray, norm: Norm = Norm.Fro): Float = this.linAlgEx.normF(mat, norm)
/**
- * Returns norm of float matrix
+ * Returns norm of double matrix
*/
@JvmName("normD")
public fun LinAlg.norm(mat: MultiArray, norm: Norm = Norm.Fro): Double = this.linAlgEx.norm(mat, norm)
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/plu.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/plu.kt
index 90cd66f7..be30627e 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/plu.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/plu.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api.linalg
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/qr.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/qr.kt
index 2ac206b9..fb0da1f7 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/qr.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/qr.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api.linalg
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/solve.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/solve.kt
index 8aadf889..46c4f2c1 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/solve.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/linalg/solve.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api.linalg
@@ -12,13 +12,17 @@ import org.jetbrains.kotlinx.multik.ndarray.data.NDArray
import kotlin.jvm.JvmName
/**
- * Returns the solution to a system of linear equations
+ * Solves a linear matrix equation, or system of linear scalar equations.
*/
@JvmName("solveF")
public fun LinAlg.solve(a: MultiArray, b: MultiArray): NDArray = this.linAlgEx.solveF(a, b)
-
+/**
+ * Solves a linear matrix equation, or system of linear scalar equations.
+ */
@JvmName("solveD")
public fun LinAlg.solve(a: MultiArray, b: MultiArray): NDArray = this.linAlgEx.solve(a, b)
-
+/**
+ * Solves a linear matrix equation, or system of linear scalar equations.
+ */
@JvmName("solveC")
public fun LinAlg.solve(a: MultiArray, b: MultiArray): NDArray = this.linAlgEx.solveC(a, b)
\ No newline at end of file
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/math/Math.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/math/Math.kt
index 9723a473..f4716603 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/math/Math.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/math/Math.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api.math
@@ -11,6 +11,9 @@ import org.jetbrains.kotlinx.multik.ndarray.data.*
*/
public interface Math {
+ /**
+ * instance of [MathEx]
+ */
public val mathEx: MathEx
/**
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/math/MathEx.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/math/MathEx.kt
index 115212ae..6e461a9b 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/math/MathEx.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/math/MathEx.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api.math
@@ -14,23 +14,71 @@ import org.jetbrains.kotlinx.multik.ndarray.data.NDArray
* Extension interface for [Math] for improved type support.
*/
public interface MathEx {
+ /**
+ * Returns a ndarray of Double from the given ndarray to each element of which an exp function has been applied.
+ */
public fun exp(a: MultiArray): NDArray
+ /**
+ * Returns a ndarray of Float from the given ndarray to each element of which an exp function has been applied.
+ */
public fun expF(a: MultiArray): NDArray
+ /**
+ * Returns a ndarray of [ComplexFloat] from the given ndarray to each element of which an exp function has been applied.
+ */
public fun expCF(a: MultiArray): NDArray
+ /**
+ * Returns a ndarray of [ComplexDouble] from the given ndarray to each element of which an exp function has been applied.
+ */
public fun expCD(a: MultiArray): NDArray
+ /**
+ * Returns a ndarray of Double from the given ndarray to each element of which a log function has been applied.
+ */
public fun log(a: MultiArray): NDArray
+ /**
+ * Returns a ndarray of Float from the given ndarray to each element of which a log function has been applied.
+ */
public fun logF(a: MultiArray): NDArray
+ /**
+ * Returns a ndarray of [ComplexFloat] from the given ndarray to each element of which a log function has been applied.
+ */
public fun logCF(a: MultiArray): NDArray
+ /**
+ * Returns a ndarray of [ComplexDouble] from the given ndarray to each element of which a log function has been applied.
+ */
public fun logCD(a: MultiArray): NDArray
+ /**
+ * Returns an ndarray of Double from the given ndarray to each element of which a sin function has been applied.
+ */
public fun sin(a: MultiArray): NDArray
+ /**
+ * Returns an ndarray of Float from the given ndarray to each element of which a sin function has been applied.
+ */
public fun sinF(a: MultiArray): NDArray
+ /**
+ * Returns an ndarray of [ComplexFloat] from the given ndarray to each element of which a sin function has been applied.
+ */
public fun sinCF(a: MultiArray): NDArray
+ /**
+ * Returns an ndarray of [ComplexDouble] from the given ndarray to each element of which a sin function has been applied.
+ */
public fun sinCD(a: MultiArray): NDArray
+ /**
+ * Returns a ndarray of Double from the given ndarray to each element of which a cos function has been applied.
+ */
public fun cos(a: MultiArray): NDArray
+ /**
+ * Returns a ndarray of Float from the given ndarray to each element of which a cos function has been applied.
+ */
public fun cosF(a: MultiArray): NDArray
+ /**
+ * Returns a ndarray of [ComplexFloat] from the given ndarray to each element of which a cos function has been applied.
+ */
public fun cosCF(a: MultiArray): NDArray
+ /**
+ * Returns a ndarray of [ComplexDouble] from the given ndarray to each element of which a cos function has been applied.
+ */
public fun cosCD(a: MultiArray): NDArray
}
\ No newline at end of file
diff --git a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/math/_math.kt b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/math/_math.kt
index 8e89447f..8bddd392 100644
--- a/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/math/_math.kt
+++ b/multik-core/src/commonMain/kotlin/org/jetbrains/kotlinx/multik/api/math/_math.kt
@@ -1,5 +1,5 @@
/*
- * Copyright 2020-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ * Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.multik.api.math
@@ -15,71 +15,131 @@ import kotlin.jvm.JvmName
/**
* Returns flat index of maximum element in an ndarray.
+ *
+ * same as [Math.argMax]
*/
public fun MultiArray.argMax(): Int = mk.math.argMax(this)
/**
* Returns flat index of minimum element in an ndarray.
+ *
+ * same as [Math.argMin]
*/
public fun MultiArray.argMin(): Int = mk.math.argMin(this)
/**
* Returns an ndarray of Double from the given ndarray to each element of which an exp function has been applied.
+ *
+ * same as [Math.exp]
*/
@JvmName("expTD")
public fun MultiArray.exp(): NDArray = mk.math.exp(this)
-
+/**
+ * Returns an ndarray of Float from the given ndarray to each element of which an exp function has been applied.
+ *
+ * same as [Math.exp]
+ */
@JvmName("expFloatD")
public fun MultiArray.exp(): NDArray = mk.math.mathEx.expF(this)
-
+/**
+ * Returns an ndarray of [ComplexFloat] from the given ndarray to each element of which an exp function has been applied.
+ *
+ * same as [Math.exp]
+ */
@JvmName("expComplexFloatD")
public fun