diff --git a/README.md b/README.md
index 2aaeb3150..7080c757e 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,8 @@
[![JetBrains Research](https://jb.gg/badges/research.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[![DOI](https://zenodo.org/badge/129486382.svg)](https://zenodo.org/badge/latestdoi/129486382)
-
![Gradle build](https://github.com/mipt-npm/kmath/workflows/Gradle%20build/badge.svg)
-
-[![Maven Central](https://img.shields.io/maven-central/v/space.kscience/kmath-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22space.kscience%22%20AND%20a:%22kmath-core%22)
+[![Maven Central](https://img.shields.io/maven-central/v/space.kscience/kmath-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22space.kscience%22)
+[![Space](https://img.shields.io/maven-metadata/v?label=Space&metadataUrl=https%3A%2F%2Fmaven.pkg.jetbrains.space%2Fmipt-npm%2Fp%2Fsci%2Fmaven%2Fkscience%2Fkmath%2Fkmath-core%2Fmaven-metadata.xml)](https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven/space/kscience/)
# KMath
@@ -120,10 +119,10 @@ KMath is a modular library. Different modules provide different features with di
>
> **Features:**
> - [algebras](kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt) : Algebraic structures like rings, spaces and fields.
-> - [nd](kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/StructureND.kt) : Many-dimensional structures and operations on them.
+> - [nd](kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/StructureND.kt) : Many-dimensional structures and operations on them.
> - [linear](kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt) : Basic linear algebra operations (sums, products, etc.), backed by the `Space` API. Advanced linear algebra operations like matrix inversion and LU decomposition.
-> - [buffers](kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/Buffer.kt) : One-dimensional structure
-> - [expressions](kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions) : By writing a single mathematical expression once, users will be able to apply different types of
+> - [buffers](kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/Buffers.kt) : One-dimensional structure
+> - [expressions](kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions) : By writing a single mathematical expression once, users will be able to apply different types of
objects to the expression by providing a context. Expressions can be used for a wide variety of purposes from high
performance calculations to code generation.
> - [domains](kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains) : Domains
@@ -147,6 +146,12 @@ performance calculations to code generation.
>
>
> **Maturity**: PROTOTYPE
+>
+> **Features:**
+> - [ejml-vector](kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlVector.kt) : The Point implementation using SimpleMatrix.
+> - [ejml-matrix](kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlMatrix.kt) : The Matrix implementation using SimpleMatrix.
+> - [ejml-linear-space](kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlLinearSpace.kt) : The LinearSpace implementation using SimpleMatrix.
+
* ### [kmath-for-real](kmath-for-real)
@@ -206,9 +211,9 @@ One can still use generic algebras though.
> **Maturity**: EXPERIMENTAL
>
> **Features:**
-> - [nd4jarraystructure](kmath-nd4j/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt) : NDStructure wrapper for INDArray
-> - [nd4jarrayrings](kmath-nd4j/src/commonMain/kotlin/space/kscience/kmath/structures/NDStructure.kt) : Rings over Nd4jArrayStructure of Int and Long
-> - [nd4jarrayfields](kmath-nd4j/src/commonMain/kotlin/space/kscience/kmath/structures/Buffers.kt) : Fields over Nd4jArrayStructure of Float and Double
+> - [nd4jarraystructure](kmath-nd4j/#) : NDStructure wrapper for INDArray
+> - [nd4jarrayrings](kmath-nd4j/#) : Rings over Nd4jArrayStructure of Int and Long
+> - [nd4jarrayfields](kmath-nd4j/#) : Fields over Nd4jArrayStructure of Float and Double
diff --git a/build.gradle.kts b/build.gradle.kts
index 9570d7744..d4453ad5c 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,3 +1,7 @@
+import org.jetbrains.dokka.gradle.DokkaTask
+import ru.mipt.npm.gradle.KSciencePublishingPlugin
+import java.net.URL
+
plugins {
id("ru.mipt.npm.gradle.project")
}
@@ -7,7 +11,6 @@ allprojects {
jcenter()
maven("https://clojars.org/repo")
maven("https://dl.bintray.com/egor-bogomolov/astminer/")
- maven("https://dl.bintray.com/hotkeytlt/maven")
maven("https://dl.bintray.com/kotlin/kotlin-eap")
maven("https://dl.bintray.com/kotlin/kotlinx")
maven("https://dl.bintray.com/mipt-npm/dev")
@@ -22,7 +25,28 @@ allprojects {
}
subprojects {
- if (name.startsWith("kmath")) apply(plugin = "maven-publish")
+ if (name.startsWith("kmath")) apply()
+
+ afterEvaluate {
+ tasks.withType {
+ dokkaSourceSets.all {
+ val readmeFile = File(this@subprojects.projectDir, "./README.md")
+ if (readmeFile.exists())
+ includes.setFrom(includes + readmeFile.absolutePath)
+
+ arrayOf(
+ "http://ejml.org/javadoc/",
+ "https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/",
+ "https://deeplearning4j.org/api/latest/"
+ ).map { URL("${it}package-list") to URL(it) }.forEach { (a, b) ->
+ externalDocumentationLink {
+ packageListUrl.set(a)
+ url.set(b)
+ }
+ }
+ }
+ }
+ }
}
readme {
diff --git a/docs/templates/ARTIFACT-TEMPLATE.md b/docs/templates/ARTIFACT-TEMPLATE.md
index cb741bc6f..01d9c51da 100644
--- a/docs/templates/ARTIFACT-TEMPLATE.md
+++ b/docs/templates/ARTIFACT-TEMPLATE.md
@@ -1,34 +1,28 @@
-> #### Artifact:
->
-> This module artifact: `${group}:${name}:${version}`.
->
-> Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/${name}/images/download.svg) ](https://bintray.com/mipt-npm/kscience/${name}/_latestVersion)
->
-> Bintray development version: [ ![Download](https://api.bintray.com/packages/mipt-npm/dev/${name}/images/download.svg) ](https://bintray.com/mipt-npm/dev/${name}/_latestVersion)
->
-> **Gradle:**
->
-> ```gradle
-> repositories {
-> maven { url 'https://repo.kotlin.link' }
-> maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
-> maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
-> }
->
-> dependencies {
-> implementation '${group}:${name}:${version}'
-> }
-> ```
-> **Gradle Kotlin DSL:**
->
-> ```kotlin
-> repositories {
-> maven("https://repo.kotlin.link")
-> maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
-> maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
-> }
->
-> dependencies {
-> implementation("${group}:${name}:${version}")
-> }
-> ```
\ No newline at end of file
+## Artifact:
+
+The Maven coordinates of this project are `${group}:${name}:${version}`.
+
+**Gradle:**
+```gradle
+repositories {
+ maven { url 'https://repo.kotlin.link' }
+ maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
+ maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
+}
+
+dependencies {
+ implementation '${group}:${name}:${version}'
+}
+```
+**Gradle Kotlin DSL:**
+```kotlin
+repositories {
+ maven("https://repo.kotlin.link")
+ maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
+ maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
+}
+
+dependencies {
+ implementation("${group}:${name}:${version}")
+}
+```
\ No newline at end of file
diff --git a/docs/templates/README-TEMPLATE.md b/docs/templates/README-TEMPLATE.md
index 4366c8fcd..3502cdccd 100644
--- a/docs/templates/README-TEMPLATE.md
+++ b/docs/templates/README-TEMPLATE.md
@@ -1,9 +1,8 @@
[![JetBrains Research](https://jb.gg/badges/research.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[![DOI](https://zenodo.org/badge/129486382.svg)](https://zenodo.org/badge/latestdoi/129486382)
-
![Gradle build](https://github.com/mipt-npm/kmath/workflows/Gradle%20build/badge.svg)
-
-[![Maven Central](https://img.shields.io/maven-central/v/space.kscience/kmath-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22space.kscience%22%20AND%20a:%22kmath-core%22)
+[![Maven Central](https://img.shields.io/maven-central/v/space.kscience/kmath-core.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22space.kscience%22)
+[![Space](https://img.shields.io/maven-metadata/v?label=Space&metadataUrl=https%3A%2F%2Fmaven.pkg.jetbrains.space%2Fmipt-npm%2Fp%2Fsci%2Fmaven%2Fkscience%2Fkmath%2Fkmath-core%2Fmaven-metadata.xml)](https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven/space/kscience/)
# KMath
diff --git a/gradle.properties b/gradle.properties
index 7ff50a435..50123b16c 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -4,5 +4,5 @@ kotlin.mpp.stability.nowarn=true
kotlin.native.enableDependencyPropagation=false
kotlin.parallel.tasks.in.project=true
org.gradle.configureondemand=true
-org.gradle.jvmargs=-XX:MaxMetaspaceSize=2G
+org.gradle.jvmargs=-XX:MaxMetaspaceSize=9G
org.gradle.parallel=true
diff --git a/kmath-ast/README.md b/kmath-ast/README.md
index 4c79b5b36..ff954b914 100644
--- a/kmath-ast/README.md
+++ b/kmath-ast/README.md
@@ -1,6 +1,6 @@
-# Abstract Syntax Tree Expression Representation and Operations (`kmath-ast`)
+# Module kmath-ast
-This subproject implements the following features:
+Abstract syntax tree expression representation and related optimizations.
- [expression-language](src/jvmMain/kotlin/space/kscience/kmath/ast/parser.kt) : Expression language and its parser
- [mst](src/commonMain/kotlin/space/kscience/kmath/ast/MST.kt) : MST (Mathematical Syntax Tree) as expression language's syntax intermediate representation
@@ -10,40 +10,34 @@ This subproject implements the following features:
- [mst-js-codegen](src/jsMain/kotlin/space/kscience/kmath/estree/estree.kt) : Dynamic MST to JS compiler
-> #### Artifact:
->
-> This module artifact: `space.kscience:kmath-ast:0.3.0-dev-3`.
->
-> Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-ast/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-ast/_latestVersion)
->
-> Bintray development version: [ ![Download](https://api.bintray.com/packages/mipt-npm/dev/kmath-ast/images/download.svg) ](https://bintray.com/mipt-npm/dev/kmath-ast/_latestVersion)
->
-> **Gradle:**
->
-> ```gradle
-> repositories {
-> maven { url 'https://repo.kotlin.link' }
-> maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
-> maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
-> }
->
-> dependencies {
-> implementation 'space.kscience:kmath-ast:0.3.0-dev-3'
-> }
-> ```
-> **Gradle Kotlin DSL:**
->
-> ```kotlin
-> repositories {
-> maven("https://repo.kotlin.link")
-> maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
-> maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
-> }
->
-> dependencies {
-> implementation("space.kscience:kmath-ast:0.3.0-dev-3")
-> }
-> ```
+## Artifact:
+
+The Maven coordinates of this project are `space.kscience:kmath-ast:0.3.0-dev-3`.
+
+**Gradle:**
+```gradle
+repositories {
+ maven { url 'https://repo.kotlin.link' }
+ maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
+ maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
+}
+
+dependencies {
+ implementation 'space.kscience:kmath-ast:0.3.0-dev-3'
+}
+```
+**Gradle Kotlin DSL:**
+```kotlin
+repositories {
+ maven("https://repo.kotlin.link")
+ maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
+ maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
+}
+
+dependencies {
+ implementation("space.kscience:kmath-ast:0.3.0-dev-3")
+}
+```
## Dynamic expression code generation
@@ -58,7 +52,7 @@ For example, the following builder:
DoubleField.mstInField { symbol("x") + 2 }.compile()
```
-… leads to generation of bytecode, which can be decompiled to the following Java class:
+… leads to generation of bytecode, which can be decompiled to the following Java class:
```java
package space.kscience.kmath.asm.generated;
diff --git a/kmath-ast/docs/README-TEMPLATE.md b/kmath-ast/docs/README-TEMPLATE.md
index 80e48008b..db071adb4 100644
--- a/kmath-ast/docs/README-TEMPLATE.md
+++ b/kmath-ast/docs/README-TEMPLATE.md
@@ -1,6 +1,6 @@
-# Abstract Syntax Tree Expression Representation and Operations (`kmath-ast`)
+# Module kmath-ast
-This subproject implements the following features:
+Abstract syntax tree expression representation and related optimizations.
${features}
diff --git a/kmath-complex/README.md b/kmath-complex/README.md
index 9e9cd5b6f..d7b2937fd 100644
--- a/kmath-complex/README.md
+++ b/kmath-complex/README.md
@@ -1,42 +1,36 @@
-# The Core Module (`kmath-core`)
+# Module kmath-complex
-Complex and hypercomplex number systems in KMath:
+Complex and hypercomplex number systems in KMath.
- [complex](src/commonMain/kotlin/space/kscience/kmath/complex/Complex.kt) : Complex Numbers
- [quaternion](src/commonMain/kotlin/space/kscience/kmath/complex/Quaternion.kt) : Quaternions
-> #### Artifact:
->
-> This module artifact: `space.kscience:kmath-complex:0.3.0-dev-3`.
->
-> Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-complex/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-complex/_latestVersion)
->
-> Bintray development version: [ ![Download](https://api.bintray.com/packages/mipt-npm/dev/kmath-complex/images/download.svg) ](https://bintray.com/mipt-npm/dev/kmath-complex/_latestVersion)
->
-> **Gradle:**
->
-> ```gradle
-> repositories {
-> maven { url 'https://repo.kotlin.link' }
-> maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
-> maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
-> }
->
-> dependencies {
-> implementation 'space.kscience:kmath-complex:0.3.0-dev-3'
-> }
-> ```
-> **Gradle Kotlin DSL:**
->
-> ```kotlin
-> repositories {
-> maven("https://repo.kotlin.link")
-> maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
-> maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
-> }
->
-> dependencies {
-> implementation("space.kscience:kmath-complex:0.3.0-dev-3")
-> }
-> ```
+## Artifact:
+
+The Maven coordinates of this project are `space.kscience:kmath-complex:0.3.0-dev-3`.
+
+**Gradle:**
+```gradle
+repositories {
+ maven { url 'https://repo.kotlin.link' }
+ maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
+ maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
+}
+
+dependencies {
+ implementation 'space.kscience:kmath-complex:0.3.0-dev-3'
+}
+```
+**Gradle Kotlin DSL:**
+```kotlin
+repositories {
+ maven("https://repo.kotlin.link")
+ maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
+ maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
+}
+
+dependencies {
+ implementation("space.kscience:kmath-complex:0.3.0-dev-3")
+}
+```
diff --git a/kmath-complex/docs/README-TEMPLATE.md b/kmath-complex/docs/README-TEMPLATE.md
index 462fd617e..106d4aff1 100644
--- a/kmath-complex/docs/README-TEMPLATE.md
+++ b/kmath-complex/docs/README-TEMPLATE.md
@@ -1,6 +1,6 @@
-# The Core Module (`kmath-core`)
+# Module kmath-complex
-Complex and hypercomplex number systems in KMath:
+Complex and hypercomplex number systems in KMath.
${features}
diff --git a/kmath-core/README.md b/kmath-core/README.md
index dd54b7aeb..096c7d833 100644
--- a/kmath-core/README.md
+++ b/kmath-core/README.md
@@ -1,49 +1,43 @@
-# The Core Module (`kmath-core`)
+# Module kmath-core
-The core features of KMath:
+The core interfaces of KMath.
- [algebras](src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt) : Algebraic structures like rings, spaces and fields.
- - [nd](src/commonMain/kotlin/space/kscience/kmath/structures/NDStructure.kt) : Many-dimensional structures and operations on them.
+ - [nd](src/commonMain/kotlin/space/kscience/kmath/structures/StructureND.kt) : Many-dimensional structures and operations on them.
- [linear](src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt) : Basic linear algebra operations (sums, products, etc.), backed by the `Space` API. Advanced linear algebra operations like matrix inversion and LU decomposition.
- [buffers](src/commonMain/kotlin/space/kscience/kmath/structures/Buffers.kt) : One-dimensional structure
- - [expressions](src/commonMain/kotlin/space/kscience/kmath/expressions) : By writing a single mathematical expression once, users will be able to apply different types of
+ - [expressions](src/commonMain/kotlin/space/kscience/kmath/expressions) : By writing a single mathematical expression once, users will be able to apply different types of
objects to the expression by providing a context. Expressions can be used for a wide variety of purposes from high
performance calculations to code generation.
- [domains](src/commonMain/kotlin/space/kscience/kmath/domains) : Domains
- [autodif](src/commonMain/kotlin/space/kscience/kmath/expressions/SimpleAutoDiff.kt) : Automatic differentiation
-> #### Artifact:
->
-> This module artifact: `space.kscience:kmath-core:0.3.0-dev-3`.
->
-> Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-core/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-core/_latestVersion)
->
-> Bintray development version: [ ![Download](https://api.bintray.com/packages/mipt-npm/dev/kmath-core/images/download.svg) ](https://bintray.com/mipt-npm/dev/kmath-core/_latestVersion)
->
-> **Gradle:**
->
-> ```gradle
-> repositories {
-> maven { url 'https://repo.kotlin.link' }
-> maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
-> maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
-> }
->
-> dependencies {
-> implementation 'space.kscience:kmath-core:0.3.0-dev-3'
-> }
-> ```
-> **Gradle Kotlin DSL:**
->
-> ```kotlin
-> repositories {
-> maven("https://repo.kotlin.link")
-> maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
-> maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
-> }
->
-> dependencies {
-> implementation("space.kscience:kmath-core:0.3.0-dev-3")
-> }
-> ```
+## Artifact:
+
+The Maven coordinates of this project are `space.kscience:kmath-core:0.3.0-dev-3`.
+
+**Gradle:**
+```gradle
+repositories {
+ maven { url 'https://repo.kotlin.link' }
+ maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
+ maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
+}
+
+dependencies {
+ implementation 'space.kscience:kmath-core:0.3.0-dev-3'
+}
+```
+**Gradle Kotlin DSL:**
+```kotlin
+repositories {
+ maven("https://repo.kotlin.link")
+ maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
+ maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
+}
+
+dependencies {
+ implementation("space.kscience:kmath-core:0.3.0-dev-3")
+}
+```
diff --git a/kmath-core/docs/README-TEMPLATE.md b/kmath-core/docs/README-TEMPLATE.md
index 83d1ebdce..41cfe1ccb 100644
--- a/kmath-core/docs/README-TEMPLATE.md
+++ b/kmath-core/docs/README-TEMPLATE.md
@@ -1,6 +1,6 @@
-# The Core Module (`kmath-core`)
+# Module kmath-core
-The core features of KMath:
+The core interfaces of KMath.
${features}
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/DoubleDomain.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/DoubleDomain.kt
index 057a4a344..154763159 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/DoubleDomain.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains/DoubleDomain.kt
@@ -24,7 +24,6 @@ import space.kscience.kmath.misc.UnstableKMathAPI
*/
@UnstableKMathAPI
public interface DoubleDomain : Domain {
-
/**
* Global lower edge
* @param num axis number
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSolver.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSolver.kt
index af136c552..3e2dbee3f 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSolver.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSolver.kt
@@ -3,7 +3,10 @@ package space.kscience.kmath.linear
import space.kscience.kmath.nd.as1D
/**
- * A group of methods to resolve equation A dot X = B, where A and B are matrices or vectors
+ * A group of methods to solve for *X* in equation *X = A -1 · B*, where *A* and *B* are matrices or
+ * vectors.
+ *
+ * @param T the type of items.
*/
public interface LinearSolver {
/**
@@ -23,7 +26,7 @@ public interface LinearSolver {
}
/**
- * Convert matrix to vector if it is possible
+ * Convert matrix to vector if it is possible.
*/
public fun Matrix.asVector(): Point =
if (this.colNum == 1)
@@ -31,4 +34,11 @@ public fun Matrix.asVector(): Point =
else
error("Can't convert matrix with more than one column to vector")
+/**
+ * Creates an n × 1 [VirtualMatrix], where n is the size of the given buffer.
+ *
+ * @param T the type of elements contained in the buffer.
+ * @receiver a buffer.
+ * @return the new matrix.
+ */
public fun Point.asMatrix(): VirtualMatrix = VirtualMatrix(size, 1) { i, _ -> get(i) }
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSpace.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSpace.kt
index dfc4c7c9b..7522978ec 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSpace.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSpace.kt
@@ -17,6 +17,8 @@ public typealias Matrix = Structure2D
/**
* Alias or using [Buffer] as a point/vector in a many-dimensional space.
+ *
+ * @param T the type of elements contained in the buffer.
*/
public typealias Point = Buffer
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/XYPointSet.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/XYPointSet.kt
index bc9052348..51582974f 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/XYPointSet.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/XYPointSet.kt
@@ -3,9 +3,28 @@ package space.kscience.kmath.misc
import space.kscience.kmath.nd.Structure2D
import space.kscience.kmath.structures.Buffer
+/**
+ * Pair of associated buffers for X and Y axes values.
+ *
+ * @param X the type of X values.
+ * @param Y the type of Y values.
+ */
+public interface XYPointSet {
+ /**
+ * The size of all the involved buffers.
+ */
+ public val size: Int
+
+ /**
+ * The buffer of X values.
+ */
@UnstableKMathAPI
public interface XYPointSet : ColumnarData {
public val x: Buffer
+
+ /**
+ * The buffer of Y values.
+ */
public val y: Buffer
override fun get(symbol: Symbol): Buffer = when (symbol) {
@@ -15,6 +34,17 @@ public interface XYPointSet : ColumnarData {
}
}
+/**
+ * Triple of associated buffers for X, Y, and Z axes values.
+ *
+ * @param X the type of X values.
+ * @param Y the type of Y values.
+ * @param Z the type of Z values.
+ */
+public interface XYZPointSet : XYPointSet {
+ /**
+ * The buffer of Z values.
+ */
@UnstableKMathAPI
public interface XYZPointSet : XYPointSet {
public val z: Buffer
@@ -27,6 +57,10 @@ public interface XYZPointSet : XYPointSet {
}
}
+internal fun > insureSorted(points: XYPointSet) {
+ for (i in 0 until points.size - 1)
+ require(points.x[i + 1] > points.x[i]) { "Input data is not sorted at index $i" }
+}
public class NDStructureColumn(public val structure: Structure2D, public val column: Int) : Buffer {
public override val size: Int
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/cumulative.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/cumulative.kt
index b50e095cf..6466695a6 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/cumulative.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/cumulative.kt
@@ -37,8 +37,8 @@ public fun List.cumulative(initial: R, operation: (R, T) -> R): List Iterable.cumulativeSum(space: Group): Iterable =
- space { cumulative(zero) { element: T, sum: T -> sum + element } }
+public fun Iterable.cumulativeSum(group: Group): Iterable =
+ group { cumulative(zero) { element: T, sum: T -> sum + element } }
@JvmName("cumulativeSumOfDouble")
public fun Iterable.cumulativeSum(): Iterable = cumulative(0.0) { element, sum -> sum + element }
@@ -49,8 +49,8 @@ public fun Iterable.cumulativeSum(): Iterable = cumulative(0) { elemen
@JvmName("cumulativeSumOfLong")
public fun Iterable.cumulativeSum(): Iterable = cumulative(0L) { element, sum -> sum + element }
-public fun Sequence.cumulativeSum(space: Group): Sequence =
- space { cumulative(zero) { element: T, sum: T -> sum + element } }
+public fun Sequence.cumulativeSum(group: Group): Sequence =
+ group { cumulative(zero) { element: T, sum: T -> sum + element } }
@JvmName("cumulativeSumOfDouble")
public fun Sequence.cumulativeSum(): Sequence = cumulative(0.0) { element, sum -> sum + element }
@@ -61,8 +61,8 @@ public fun Sequence.cumulativeSum(): Sequence = cumulative(0) { elemen
@JvmName("cumulativeSumOfLong")
public fun Sequence.cumulativeSum(): Sequence = cumulative(0L) { element, sum -> sum + element }
-public fun List.cumulativeSum(space: Group): List =
- space { cumulative(zero) { element: T, sum: T -> sum + element } }
+public fun List.cumulativeSum(group: Group): List =
+ group { cumulative(zero) { element: T, sum: T -> sum + element } }
@JvmName("cumulativeSumOfDouble")
public fun List.cumulativeSum(): List = cumulative(0.0) { element, sum -> sum + element }
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt
index 04234205f..492ec8e88 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt
@@ -100,8 +100,8 @@ public fun Algebra.bindSymbol(symbol: Symbol): T = bindSymbol(symbo
public inline operator fun , R> A.invoke(block: A.() -> R): R = run(block)
/**
- * Represents linear space without neutral element, i.e. algebraic structure with associative, binary operation [add]
- * and scalar multiplication [multiply].
+ * Represents group without neutral element (also known as inverse semigroup), i.e. algebraic structure with
+ * associative, binary operation [add].
*
* @param T the type of element of this semispace.
*/
@@ -177,7 +177,7 @@ public interface GroupOperations : Algebra {
}
/**
- * Represents linear space with neutral element, i.e. algebraic structure with associative, binary operation [add].
+ * Represents group, i.e. algebraic structure with associative, binary operation [add].
*
* @param T the type of element of this semispace.
*/
@@ -189,8 +189,8 @@ public interface Group : GroupOperations {
}
/**
- * Represents rng, i.e. algebraic structure with associative, binary, commutative operation [add] and associative,
- * operation [multiply] distributive over [add].
+ * Represents ring without multiplicative and additive identities, i.e. algebraic structure with
+ * associative, binary, commutative operation [add] and associative, operation [multiply] distributive over [add].
*
* @param T the type of element of this semiring.
*/
@@ -238,7 +238,7 @@ public interface Ring : Group, RingOperations {
}
/**
- * Represents field without identity elements, i.e. algebraic structure with associative, binary, commutative operations
+ * Represents field without without multiplicative and additive identities, i.e. algebraic structure with associative, binary, commutative operations
* [add] and [multiply]; binary operation [divide] as multiplication of left operand by reciprocal of right one.
*
* @param T the type of element of this semifield.
@@ -276,10 +276,11 @@ public interface FieldOperations : RingOperations {
}
/**
- * Represents field, i.e. algebraic structure with three operations: associative "addition" and "multiplication",
- * and "division" and their neutral elements.
+ * Represents field, i.e. algebraic structure with three operations: associative, commutative addition and
+ * multiplication, and division. **This interface differs from the eponymous mathematical definition: fields in KMath
+ * also support associative multiplication by scalar.**
*
- * @param T the type of element of this semifield.
+ * @param T the type of element of this field.
*/
public interface Field : Ring, FieldOperations, ScaleOperations, NumericAlgebra {
override fun number(value: Number): T = scale(one, value.toDouble())
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BigInt.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BigInt.kt
index 55bb68850..b5e27575b 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BigInt.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BigInt.kt
@@ -12,8 +12,8 @@ import kotlin.math.max
import kotlin.math.min
import kotlin.math.sign
-public typealias Magnitude = UIntArray
-public typealias TBase = ULong
+private typealias Magnitude = UIntArray
+private typealias TBase = ULong
/**
* Kotlin Multiplatform implementation of Big Integer numbers (KBigInteger).
@@ -358,6 +358,9 @@ private fun stripLeadingZeros(mag: Magnitude): Magnitude {
return mag.sliceArray(IntRange(0, resSize))
}
+/**
+ * Returns the absolute value of the given value [x].
+ */
public fun abs(x: BigInt): BigInt = x.abs()
/**
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/algebraExtensions.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/algebraExtensions.kt
index 9a395b0f4..b927655e3 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/algebraExtensions.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/algebraExtensions.kt
@@ -49,19 +49,19 @@ public fun > Group.abs(value: T): T = if (value > zero) val
* Returns the sum of all elements in the iterable in provided space.
*
* @receiver the collection to sum up.
- * @param space the algebra that provides addition.
+ * @param group the algebra that provides addition.
* @return the sum.
*/
-public fun Iterable.sumWith(space: Group): T = space.sum(this)
+public fun Iterable.sumWith(group: Group): T = group.sum(this)
/**
* Returns the sum of all elements in the sequence in provided space.
*
* @receiver the collection to sum up.
- * @param space the algebra that provides addition.
+ * @param group the algebra that provides addition.
* @return the sum.
*/
-public fun Sequence.sumWith(space: Group): T = space.sum(this)
+public fun Sequence.sumWith(group: Group): T = group.sum(this)
/**
* Returns an average value of elements in the iterable in this [Group].
diff --git a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/flowExtra.kt b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/flowExtra.kt
index 81b4327fc..7d4914a01 100644
--- a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/flowExtra.kt
+++ b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/flowExtra.kt
@@ -14,7 +14,7 @@ public fun Flow.cumulativeSum(group: GroupOperations): Flow =
group { runningReduce { sum, element -> sum + element } }
@ExperimentalCoroutinesApi
-public fun Flow.mean(algebra: S): Flow where S : Group, S : ScaleOperations = algebra {
+public fun Flow.mean(space: S): Flow where S : Group, S : ScaleOperations = space {
data class Accumulator(var sum: T, var num: Int)
scan(Accumulator(zero, 0)) { sum, element ->
diff --git a/kmath-ejml/README.md b/kmath-ejml/README.md
new file mode 100644
index 000000000..2551703a4
--- /dev/null
+++ b/kmath-ejml/README.md
@@ -0,0 +1,37 @@
+# Module kmath-ejml
+
+EJML based linear algebra implementation.
+
+ - [ejml-vector](src/main/kotlin/space/kscience/kmath/ejml/EjmlVector.kt) : The Point implementation using SimpleMatrix.
+ - [ejml-matrix](src/main/kotlin/space/kscience/kmath/ejml/EjmlMatrix.kt) : The Matrix implementation using SimpleMatrix.
+ - [ejml-linear-space](src/main/kotlin/space/kscience/kmath/ejml/EjmlLinearSpace.kt) : The LinearSpace implementation using SimpleMatrix.
+
+
+## Artifact:
+
+The Maven coordinates of this project are `space.kscience:kmath-ejml:0.3.0-dev-3`.
+
+**Gradle:**
+```gradle
+repositories {
+ maven { url 'https://repo.kotlin.link' }
+ maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
+ maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
+}
+
+dependencies {
+ implementation 'space.kscience:kmath-ejml:0.3.0-dev-3'
+}
+```
+**Gradle Kotlin DSL:**
+```kotlin
+repositories {
+ maven("https://repo.kotlin.link")
+ maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
+ maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
+}
+
+dependencies {
+ implementation("space.kscience:kmath-ejml:0.3.0-dev-3")
+}
+```
diff --git a/kmath-ejml/build.gradle.kts b/kmath-ejml/build.gradle.kts
index 1ce2291c4..5091139ac 100644
--- a/kmath-ejml/build.gradle.kts
+++ b/kmath-ejml/build.gradle.kts
@@ -1,12 +1,33 @@
+import ru.mipt.npm.gradle.Maturity
+
plugins {
id("ru.mipt.npm.gradle.jvm")
}
dependencies {
- implementation("org.ejml:ejml-simple:0.39")
- implementation(project(":kmath-core"))
+ api("org.ejml:ejml-simple:0.40")
+ api(project(":kmath-core"))
}
readme {
- maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE
-}
\ No newline at end of file
+ maturity = Maturity.PROTOTYPE
+ propertyByTemplate("artifact", rootProject.file("docs/templates/ARTIFACT-TEMPLATE.md"))
+
+ feature(
+ id = "ejml-vector",
+ description = "The Point implementation using SimpleMatrix.",
+ ref = "src/main/kotlin/space/kscience/kmath/ejml/EjmlVector.kt"
+ )
+
+ feature(
+ id = "ejml-matrix",
+ description = "The Matrix implementation using SimpleMatrix.",
+ ref = "src/main/kotlin/space/kscience/kmath/ejml/EjmlMatrix.kt"
+ )
+
+ feature(
+ id = "ejml-linear-space",
+ description = "The LinearSpace implementation using SimpleMatrix.",
+ ref = "src/main/kotlin/space/kscience/kmath/ejml/EjmlLinearSpace.kt"
+ )
+}
diff --git a/kmath-ejml/docs/README-TEMPLATE.md b/kmath-ejml/docs/README-TEMPLATE.md
new file mode 100644
index 000000000..27fcedd65
--- /dev/null
+++ b/kmath-ejml/docs/README-TEMPLATE.md
@@ -0,0 +1,7 @@
+# Module kmath-ejml
+
+EJML based linear algebra implementation.
+
+${features}
+
+${artifact}
diff --git a/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlLinearSpace.kt b/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlLinearSpace.kt
index f84a57c9d..94429e7b3 100644
--- a/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlLinearSpace.kt
+++ b/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlLinearSpace.kt
@@ -15,10 +15,13 @@ import kotlin.reflect.cast
* Represents context of basic operations operating with [EjmlMatrix].
*
* @author Iaroslav Postovalov
+ * @author Alexander Nozik
*/
public object EjmlLinearSpace : LinearSpace {
-
- override val elementAlgebra: DoubleField get() = DoubleField
+ /**
+ * The [DoubleField] reference.
+ */
+ public override val elementAlgebra: DoubleField get() = DoubleField
/**
* Converts this matrix to EJML one.
@@ -39,14 +42,17 @@ public object EjmlLinearSpace : LinearSpace {
})
}
- override fun buildMatrix(rows: Int, columns: Int, initializer: DoubleField.(i: Int, j: Int) -> Double): EjmlMatrix =
- EjmlMatrix(SimpleMatrix(rows, columns).also {
- (0 until rows).forEach { row ->
- (0 until columns).forEach { col -> it[row, col] = DoubleField.initializer(row, col) }
- }
- })
+ public override fun buildMatrix(
+ rows: Int,
+ columns: Int,
+ initializer: DoubleField.(i: Int, j: Int) -> Double,
+ ): EjmlMatrix = EjmlMatrix(SimpleMatrix(rows, columns).also {
+ (0 until rows).forEach { row ->
+ (0 until columns).forEach { col -> it[row, col] = DoubleField.initializer(row, col) }
+ }
+ })
- override fun buildVector(size: Int, initializer: DoubleField.(Int) -> Double): Point =
+ public override fun buildVector(size: Int, initializer: DoubleField.(Int) -> Double): Point =
EjmlVector(SimpleMatrix(size, 1).also {
(0 until it.numRows()).forEach { row -> it[row, 0] = DoubleField.initializer(row) }
})
@@ -54,7 +60,7 @@ public object EjmlLinearSpace : LinearSpace {
private fun SimpleMatrix.wrapMatrix() = EjmlMatrix(this)
private fun SimpleMatrix.wrapVector() = EjmlVector(this)
- override fun Matrix.unaryMinus(): Matrix = this * (-1.0)
+ public override fun Matrix.unaryMinus(): Matrix = this * (-1.0)
public override fun Matrix.dot(other: Matrix): EjmlMatrix =
EjmlMatrix(toEjml().origin.mult(other.toEjml().origin))
@@ -68,29 +74,29 @@ public object EjmlLinearSpace : LinearSpace {
public override operator fun Matrix.times(value: Double): EjmlMatrix =
toEjml().origin.scale(value).wrapMatrix()
- override fun Point.unaryMinus(): EjmlVector =
+ public override fun Point.unaryMinus(): EjmlVector =
toEjml().origin.negative().wrapVector()
- override fun Matrix.plus(other: Matrix): EjmlMatrix =
+ public override fun Matrix.plus(other: Matrix): EjmlMatrix =
(toEjml().origin + other.toEjml().origin).wrapMatrix()
- override fun Point.plus(other: Point): EjmlVector =
+ public override fun Point.plus(other: Point): EjmlVector =
(toEjml().origin + other.toEjml().origin).wrapVector()
- override fun Point.minus(other: Point): EjmlVector =
+ public override fun Point.minus(other: Point): EjmlVector =
(toEjml().origin - other.toEjml().origin).wrapVector()
- override fun Double.times(m: Matrix): EjmlMatrix =
+ public override fun Double.times(m: Matrix): EjmlMatrix =
m.toEjml().origin.scale(this).wrapMatrix()
- override fun Point.times(value: Double): EjmlVector =
+ public override fun Point.times(value: Double): EjmlVector =
toEjml().origin.scale(value).wrapVector()
- override fun Double.times(v: Point): EjmlVector =
+ public override fun Double.times(v: Point): EjmlVector =
v.toEjml().origin.scale(this).wrapVector()
@UnstableKMathAPI
- override fun getFeature(structure: Matrix, type: KClass): F? {
+ public override fun getFeature(structure: Matrix, type: KClass): F? {
//Return the feature if it is intrinsic to the structure
structure.getFeature(type)?.let { return it }
@@ -161,7 +167,7 @@ public object EjmlLinearSpace : LinearSpace {
}
/**
- * Solves for X in the following equation: x = a^-1*b, where 'a' is base matrix and 'b' is an n by p matrix.
+ * Solves for *x* in the following equation: *x = [a] -1 · [b]*.
*
* @param a the base matrix.
* @param b n by p matrix.
@@ -172,7 +178,7 @@ public fun EjmlLinearSpace.solve(a: Matrix, b: Matrix): EjmlMatr
EjmlMatrix(a.toEjml().origin.solve(b.toEjml().origin))
/**
- * Solves for X in the following equation: x = a^(-1)*b, where 'a' is base matrix and 'b' is an n by p matrix.
+ * Solves for *x* in the following equation: *x = [a] -1 · [b]*.
*
* @param a the base matrix.
* @param b n by p vector.
@@ -182,7 +188,17 @@ public fun EjmlLinearSpace.solve(a: Matrix, b: Matrix): EjmlMatr
public fun EjmlLinearSpace.solve(a: Matrix, b: Point): EjmlVector =
EjmlVector(a.toEjml().origin.solve(b.toEjml().origin))
+/**
+ * Inverts this matrix.
+ *
+ * @author Alexander Nozik
+ */
@OptIn(UnstableKMathAPI::class)
public fun EjmlMatrix.inverted(): EjmlMatrix = getFeature>()!!.inverse as EjmlMatrix
+/**
+ * Inverts the given matrix.
+ *
+ * @author Alexander Nozik
+ */
public fun EjmlLinearSpace.inverse(matrix: Matrix): Matrix = matrix.toEjml().inverted()
\ No newline at end of file
diff --git a/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlMatrix.kt b/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlMatrix.kt
index 712c2a42c..10afd6ec2 100644
--- a/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlMatrix.kt
+++ b/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlMatrix.kt
@@ -4,7 +4,7 @@ import org.ejml.simple.SimpleMatrix
import space.kscience.kmath.linear.Matrix
/**
- * Represents featured matrix over EJML [SimpleMatrix].
+ * The matrix implementation over EJML [SimpleMatrix].
*
* @property origin the underlying [SimpleMatrix].
* @author Iaroslav Postovalov
diff --git a/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlVector.kt b/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlVector.kt
index c7f87675d..2c8d2edd4 100644
--- a/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlVector.kt
+++ b/kmath-ejml/src/main/kotlin/space/kscience/kmath/ejml/EjmlVector.kt
@@ -9,7 +9,7 @@ import space.kscience.kmath.linear.Point
* @property origin the underlying [SimpleMatrix].
* @author Iaroslav Postovalov
*/
-public class EjmlVector internal constructor(public val origin: SimpleMatrix) : Point {
+public inline class EjmlVector internal constructor(public val origin: SimpleMatrix) : Point {
public override val size: Int
get() = origin.numRows()
diff --git a/kmath-for-real/README.md b/kmath-for-real/README.md
index 139cd3cef..ad3d33062 100644
--- a/kmath-for-real/README.md
+++ b/kmath-for-real/README.md
@@ -1,41 +1,37 @@
-# Real number specialization module (`kmath-for-real`)
+# Module kmath-for-real
+
+Specialization of KMath APIs for Double numbers.
- [DoubleVector](src/commonMain/kotlin/space/kscience/kmath/real/DoubleVector.kt) : Numpy-like operations for Buffers/Points
- [DoubleMatrix](src/commonMain/kotlin/space/kscience/kmath/real/DoubleMatrix.kt) : Numpy-like operations for 2d real structures
- [grids](src/commonMain/kotlin/space/kscience/kmath/structures/grids.kt) : Uniform grid generators
-> #### Artifact:
->
-> This module artifact: `space.kscience:kmath-for-real:0.3.0-dev-3`.
->
-> Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-for-real/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-for-real/_latestVersion)
->
-> Bintray development version: [ ![Download](https://api.bintray.com/packages/mipt-npm/dev/kmath-for-real/images/download.svg) ](https://bintray.com/mipt-npm/dev/kmath-for-real/_latestVersion)
->
-> **Gradle:**
->
-> ```gradle
-> repositories {
-> maven { url 'https://repo.kotlin.link' }
-> maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
-> maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
-> }
->
-> dependencies {
-> implementation 'space.kscience:kmath-for-real:0.3.0-dev-3'
-> }
-> ```
-> **Gradle Kotlin DSL:**
->
-> ```kotlin
-> repositories {
-> maven("https://repo.kotlin.link")
-> maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
-> maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
-> }
->
-> dependencies {
-> implementation("space.kscience:kmath-for-real:0.3.0-dev-3")
-> }
-> ```
+## Artifact:
+
+The Maven coordinates of this project are `space.kscience:kmath-for-real:0.3.0-dev-3`.
+
+**Gradle:**
+```gradle
+repositories {
+ maven { url 'https://repo.kotlin.link' }
+ maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
+ maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
+}
+
+dependencies {
+ implementation 'space.kscience:kmath-for-real:0.3.0-dev-3'
+}
+```
+**Gradle Kotlin DSL:**
+```kotlin
+repositories {
+ maven("https://repo.kotlin.link")
+ maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
+ maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
+}
+
+dependencies {
+ implementation("space.kscience:kmath-for-real:0.3.0-dev-3")
+}
+```
diff --git a/kmath-for-real/docs/README-TEMPLATE.md b/kmath-for-real/docs/README-TEMPLATE.md
index 670844bd0..c2ef25aa7 100644
--- a/kmath-for-real/docs/README-TEMPLATE.md
+++ b/kmath-for-real/docs/README-TEMPLATE.md
@@ -1,4 +1,6 @@
-# Real number specialization module (`kmath-for-real`)
+# Module kmath-for-real
+
+Specialization of KMath APIs for Double numbers.
${features}
diff --git a/kmath-functions/README.md b/kmath-functions/README.md
index d13c4c107..531e97a44 100644
--- a/kmath-functions/README.md
+++ b/kmath-functions/README.md
@@ -1,6 +1,6 @@
-# Functions (`kmath-functions`)
+# Module kmath-functions
-Functions and interpolations:
+Functions and interpolations.
- [piecewise](Piecewise functions.) : src/commonMain/kotlin/space/kscience/kmath/functions/Piecewise.kt
- [polynomials](Polynomial functions.) : src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt
@@ -8,37 +8,31 @@ Functions and interpolations:
- [spline interpolation](Cubic spline XY interpolator.) : src/commonMain/kotlin/space/kscience/kmath/interpolation/SplineInterpolator.kt
-> #### Artifact:
->
-> This module artifact: `space.kscience:kmath-functions:0.3.0-dev-3`.
->
-> Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-functions/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-functions/_latestVersion)
->
-> Bintray development version: [ ![Download](https://api.bintray.com/packages/mipt-npm/dev/kmath-functions/images/download.svg) ](https://bintray.com/mipt-npm/dev/kmath-functions/_latestVersion)
->
-> **Gradle:**
->
-> ```gradle
-> repositories {
-> maven { url 'https://repo.kotlin.link' }
-> maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
-> maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
-> }
->
-> dependencies {
-> implementation 'space.kscience:kmath-functions:0.3.0-dev-3'
-> }
-> ```
-> **Gradle Kotlin DSL:**
->
-> ```kotlin
-> repositories {
-> maven("https://repo.kotlin.link")
-> maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
-> maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
-> }
->
-> dependencies {
-> implementation("space.kscience:kmath-functions:0.3.0-dev-3")
-> }
-> ```
+## Artifact:
+
+The Maven coordinates of this project are `space.kscience:kmath-functions:0.3.0-dev-3`.
+
+**Gradle:**
+```gradle
+repositories {
+ maven { url 'https://repo.kotlin.link' }
+ maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
+ maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
+}
+
+dependencies {
+ implementation 'space.kscience:kmath-functions:0.3.0-dev-3'
+}
+```
+**Gradle Kotlin DSL:**
+```kotlin
+repositories {
+ maven("https://repo.kotlin.link")
+ maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
+ maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
+}
+
+dependencies {
+ implementation("space.kscience:kmath-functions:0.3.0-dev-3")
+}
+```
diff --git a/kmath-functions/docs/README-TEMPLATE.md b/kmath-functions/docs/README-TEMPLATE.md
index 8a34a7cc4..2e163eee5 100644
--- a/kmath-functions/docs/README-TEMPLATE.md
+++ b/kmath-functions/docs/README-TEMPLATE.md
@@ -1,6 +1,6 @@
-# Functions (`kmath-functions`)
+# Module kmath-functions
-Functions and interpolations:
+Functions and interpolations.
${features}
diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Piecewise.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Piecewise.kt
index d2470a4b4..3510973be 100644
--- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Piecewise.kt
+++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Piecewise.kt
@@ -2,14 +2,28 @@ package space.kscience.kmath.functions
import space.kscience.kmath.operations.Ring
+/**
+ * Represents piecewise-defined function.
+ *
+ * @param T the piece key type.
+ * @param R the sub-function type.
+ */
public fun interface Piecewise {
+ /**
+ * Returns the appropriate sub-function for given piece key.
+ */
public fun findPiece(arg: T): R?
}
+/**
+ * Represents piecewise-defined function where all the sub-functions are polynomials.
+ */
public fun interface PiecewisePolynomial : Piecewise>
/**
- * Ordered list of pieces in piecewise function
+ * Basic [Piecewise] implementation where all the pieces are ordered by the [Comparable] type instances.
+ *
+ * @param T the comparable piece key type.
*/
public class OrderedPiecewisePolynomial>(delimiter: T) :
PiecewisePolynomial {
@@ -17,8 +31,10 @@ public class OrderedPiecewisePolynomial>(delimiter: T) :
private val pieces: MutableList> = arrayListOf()
/**
- * Dynamically add a piece to the "right" side (beyond maximum argument value of previous piece)
- * @param right new rightmost position. If is less then current rightmost position, a error is thrown.
+ * Dynamically adds a piece to the right side (beyond maximum argument value of previous piece)
+ *
+ * @param right new rightmost position. If is less then current rightmost position, an error is thrown.
+ * @param piece the sub-function.
*/
public fun putRight(right: T, piece: Polynomial) {
require(right > delimiters.last()) { "New delimiter should be to the right of old one" }
@@ -26,13 +42,19 @@ public class OrderedPiecewisePolynomial>(delimiter: T) :
pieces.add(piece)
}
+ /**
+ * Dynamically adds a piece to the left side (beyond maximum argument value of previous piece)
+ *
+ * @param left the new leftmost position. If is less then current rightmost position, an error is thrown.
+ * @param piece the sub-function.
+ */
public fun putLeft(left: T, piece: Polynomial) {
require(left < delimiters.first()) { "New delimiter should be to the left of old one" }
delimiters.add(0, left)
pieces.add(0, piece)
}
- override fun findPiece(arg: T): Polynomial? {
+ public override fun findPiece(arg: T): Polynomial? {
if (arg < delimiters.first() || arg >= delimiters.last())
return null
else {
@@ -46,9 +68,10 @@ public class OrderedPiecewisePolynomial>(delimiter: T) :
}
/**
- * Return a value of polynomial function with given [ring] an given [arg] or null if argument is outside of piecewise definition.
+ * Return a value of polynomial function with given [ring] an given [arg] or null if argument is outside of piecewise
+ * definition.
*/
public fun , C : Ring> PiecewisePolynomial.value(ring: C, arg: T): T? =
findPiece(arg)?.value(ring, arg)
-public fun , C : Ring> PiecewisePolynomial.asFunction(ring: C): (T) -> T? = { value(ring, it) }
\ No newline at end of file
+public fun , C : Ring> PiecewisePolynomial.asFunction(ring: C): (T) -> T? = { value(ring, it) }
diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt
index 049909fe1..550785812 100644
--- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt
+++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt
@@ -10,16 +10,26 @@ import kotlin.math.max
import kotlin.math.pow
/**
- * Polynomial coefficients without fixation on specific context they are applied to
- * @param coefficients constant is the leftmost coefficient
+ * Polynomial coefficients model without fixation on specific context they are applied to.
+ *
+ * @param coefficients constant is the leftmost coefficient.
*/
public inline class Polynomial(public val coefficients: List)
+/**
+ * Returns a [Polynomial] instance with given [coefficients].
+ */
@Suppress("FunctionName")
public fun Polynomial(vararg coefficients: T): Polynomial = Polynomial(coefficients.toList())
+/**
+ * Evaluates the value of the given double polynomial for given double argument.
+ */
public fun Polynomial.value(): Double = coefficients.reduceIndexed { index, acc, d -> acc + d.pow(index) }
+/**
+ * Evaluates the value of the given polynomial for given argument.
+ */
public fun > Polynomial.value(ring: C, arg: T): T = ring {
if (coefficients.isEmpty()) return@ring zero
var res = coefficients.first()
@@ -35,19 +45,23 @@ public fun > Polynomial.value(ring: C, arg: T): T = ring
}
/**
- * Represent the polynomial as a regular context-less function
+ * Represent the polynomial as a regular context-less function.
*/
public fun > Polynomial.asFunction(ring: C): (T) -> T = { value(ring, it) }
/**
- * An algebra for polynomials
+ * Space of polynomials.
+ *
+ * @param T the type of operated polynomials.
+ * @param C the intersection of [Ring] of [T] and [ScaleOperations] of [T].
+ * @param ring the [C] instance.
*/
public class PolynomialSpace(
private val ring: C,
) : Group>, ScaleOperations> where C : Ring, C : ScaleOperations {
public override val zero: Polynomial = Polynomial(emptyList())
- override fun Polynomial.unaryMinus(): Polynomial = with(ring) {
+ override fun Polynomial.unaryMinus(): Polynomial = ring {
Polynomial(coefficients.map { -it })
}
@@ -64,6 +78,9 @@ public class PolynomialSpace(
public override fun scale(a: Polynomial, value: Double): Polynomial =
ring { Polynomial(List(a.coefficients.size) { index -> a.coefficients[index] * value }) }
+ /**
+ * Evaluates the polynomial for the given value [arg].
+ */
public operator fun Polynomial.invoke(arg: T): T = value(ring, arg)
}
diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/Integrator.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/Integrator.kt
index ebc53ad2e..e421fb680 100644
--- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/Integrator.kt
+++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/Integrator.kt
@@ -1,11 +1,11 @@
package space.kscience.kmath.integration
/**
- * A general interface for all integrators
+ * A general interface for all integrators.
*/
public interface Integrator {
/**
- * Run one integration pass and return a new [Integrand] with a new set of features
+ * Runs one integration pass and return a new [Integrand] with a new set of features.
*/
public fun integrate(integrand: I): I
-}
\ No newline at end of file
+}
diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/UnivariateIntegrand.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/UnivariateIntegrand.kt
index 9389318e8..ca4bbf6b8 100644
--- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/UnivariateIntegrand.kt
+++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/UnivariateIntegrand.kt
@@ -61,4 +61,4 @@ public fun UnivariateIntegrator.integrate(
return integrate(
UnivariateIntegrand(function, *features.toTypedArray())
).value ?: error("Unexpected: no value after integration.")
-}
\ No newline at end of file
+}
diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/SplineInterpolator.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/SplineInterpolator.kt
index 8b6db8cf9..0756e2901 100644
--- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/SplineInterpolator.kt
+++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/SplineInterpolator.kt
@@ -10,8 +10,11 @@ import space.kscience.kmath.operations.invoke
import space.kscience.kmath.structures.MutableBufferFactory
/**
- * Generic spline interpolator. Not recommended for performance critical places, use platform-specific and type specific ones.
- * Based on https://github.com/apache/commons-math/blob/eb57d6d457002a0bb5336d789a3381a24599affe/src/main/java/org/apache/commons/math4/analysis/interpolation/SplineInterpolator.java
+ * Generic spline interpolator. Not recommended for performance critical places, use platform-specific and type
+ * specific ones.
+ *
+ * Based on
+ * https://github.com/apache/commons-math/blob/eb57d6d457002a0bb5336d789a3381a24599affe/src/main/java/org/apache/commons/math4/analysis/interpolation/SplineInterpolator.java
*/
public class SplineInterpolator>(
public override val algebra: Field,
diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt
index 616a72fde..764ff116c 100644
--- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt
+++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Counter.kt
@@ -37,11 +37,11 @@ public class LongCounter : Counter {
override val value: Long get() = innerValue.value
}
-public class ObjectCounter(public val space: Group) : Counter {
- private val innerValue = atomic(space.zero)
+public class ObjectCounter(public val group: Group) : Counter {
+ private val innerValue = atomic(group.zero)
override fun add(delta: T) {
- innerValue.getAndUpdate { space.run { it + delta } }
+ innerValue.getAndUpdate { group.run { it + delta } }
}
override val value: T get() = innerValue.value
diff --git a/kmath-nd4j/README.md b/kmath-nd4j/README.md
index 2771722eb..938d05c33 100644
--- a/kmath-nd4j/README.md
+++ b/kmath-nd4j/README.md
@@ -1,46 +1,40 @@
-# ND4J NDStructure implementation (`kmath-nd4j`)
+# Module kmath-nd4j
-This subproject implements the following features:
+ND4J based implementations of KMath abstractions.
- [nd4jarraystructure](#) : NDStructure wrapper for INDArray
- [nd4jarrayrings](#) : Rings over Nd4jArrayStructure of Int and Long
- [nd4jarrayfields](#) : Fields over Nd4jArrayStructure of Float and Double
-> #### Artifact:
->
-> This module artifact: `space.kscience:kmath-nd4j:0.3.0-dev-3`.
->
-> Bintray release version: [ ![Download](https://api.bintray.com/packages/mipt-npm/kscience/kmath-nd4j/images/download.svg) ](https://bintray.com/mipt-npm/kscience/kmath-nd4j/_latestVersion)
->
-> Bintray development version: [ ![Download](https://api.bintray.com/packages/mipt-npm/dev/kmath-nd4j/images/download.svg) ](https://bintray.com/mipt-npm/dev/kmath-nd4j/_latestVersion)
->
-> **Gradle:**
->
-> ```gradle
-> repositories {
-> maven { url 'https://repo.kotlin.link' }
-> maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
-> maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
-> }
->
-> dependencies {
-> implementation 'space.kscience:kmath-nd4j:0.3.0-dev-3'
-> }
-> ```
-> **Gradle Kotlin DSL:**
->
-> ```kotlin
-> repositories {
-> maven("https://repo.kotlin.link")
-> maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
-> maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
-> }
->
-> dependencies {
-> implementation("space.kscience:kmath-nd4j:0.3.0-dev-3")
-> }
-> ```
+## Artifact:
+
+The Maven coordinates of this project are `space.kscience:kmath-nd4j:0.3.0-dev-3`.
+
+**Gradle:**
+```gradle
+repositories {
+ maven { url 'https://repo.kotlin.link' }
+ maven { url 'https://dl.bintray.com/hotkeytlt/maven' }
+ maven { url "https://dl.bintray.com/kotlin/kotlin-eap" } // include for builds based on kotlin-eap
+}
+
+dependencies {
+ implementation 'space.kscience:kmath-nd4j:0.3.0-dev-3'
+}
+```
+**Gradle Kotlin DSL:**
+```kotlin
+repositories {
+ maven("https://repo.kotlin.link")
+ maven("https://dl.bintray.com/kotlin/kotlin-eap") // include for builds based on kotlin-eap
+ maven("https://dl.bintray.com/hotkeytlt/maven") // required for a
+}
+
+dependencies {
+ implementation("space.kscience:kmath-nd4j:0.3.0-dev-3")
+}
+```
## Examples
diff --git a/kmath-nd4j/docs/README-TEMPLATE.md b/kmath-nd4j/docs/README-TEMPLATE.md
index 9783e74be..5f325cab5 100644
--- a/kmath-nd4j/docs/README-TEMPLATE.md
+++ b/kmath-nd4j/docs/README-TEMPLATE.md
@@ -1,6 +1,6 @@
-# ND4J NDStructure implementation (`kmath-nd4j`)
+# Module kmath-nd4j
-This subproject implements the following features:
+ND4J based implementations of KMath abstractions.
${features}
diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Statistic.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Statistic.kt
index 8bf6b09ef..689182115 100644
--- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Statistic.kt
+++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/stat/Statistic.kt
@@ -66,16 +66,16 @@ public fun ComposableStatistic.flow(
* Arithmetic mean
*/
public class Mean(
- private val space: Group,
+ private val group: Group,
private val division: (sum: T, count: Int) -> T,
) : ComposableStatistic, T> {
public override suspend fun computeIntermediate(data: Buffer): Pair =
- space { sum(data.asIterable()) } to data.size
+ group { sum(data.asIterable()) } to data.size
public override suspend fun composeIntermediate(first: Pair, second: Pair): Pair =
- space { first.first + second.first } to (first.second + second.second)
+ group { first.first + second.first } to (first.second + second.second)
- public override suspend fun toResult(intermediate: Pair): T = space {
+ public override suspend fun toResult(intermediate: Pair): T = group {
division(intermediate.first, intermediate.second)
}