Dev #280
23
README.md
23
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.
|
||||
|
||||
<hr/>
|
||||
|
||||
* ### [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
|
||||
|
||||
<hr/>
|
||||
|
||||
|
@ -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<KSciencePublishingPlugin>()
|
||||
|
||||
afterEvaluate {
|
||||
tasks.withType<DokkaTask> {
|
||||
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 {
|
||||
|
62
docs/templates/ARTIFACT-TEMPLATE.md
vendored
62
docs/templates/ARTIFACT-TEMPLATE.md
vendored
@ -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}")
|
||||
> }
|
||||
> ```
|
||||
## 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}")
|
||||
}
|
||||
```
|
5
docs/templates/README-TEMPLATE.md
vendored
5
docs/templates/README-TEMPLATE.md
vendored
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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}
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
```
|
||||
|
@ -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}
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
```
|
||||
|
@ -1,6 +1,6 @@
|
||||
# The Core Module (`kmath-core`)
|
||||
# Module kmath-core
|
||||
|
||||
The core features of KMath:
|
||||
The core interfaces of KMath.
|
||||
|
||||
${features}
|
||||
|
||||
|
@ -24,7 +24,6 @@ import space.kscience.kmath.misc.UnstableKMathAPI
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public interface DoubleDomain : Domain<Double> {
|
||||
|
||||
/**
|
||||
* Global lower edge
|
||||
* @param num axis number
|
||||
|
@ -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 <sup>-1</sup> · B*, where *A* and *B* are matrices or
|
||||
* vectors.
|
||||
*
|
||||
* @param T the type of items.
|
||||
*/
|
||||
public interface LinearSolver<T : Any> {
|
||||
/**
|
||||
@ -23,7 +26,7 @@ public interface LinearSolver<T : Any> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert matrix to vector if it is possible
|
||||
* Convert matrix to vector if it is possible.
|
||||
*/
|
||||
public fun <T : Any> Matrix<T>.asVector(): Point<T> =
|
||||
if (this.colNum == 1)
|
||||
@ -31,4 +34,11 @@ public fun <T : Any> Matrix<T>.asVector(): Point<T> =
|
||||
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 <T : Any> Point<T>.asMatrix(): VirtualMatrix<T> = VirtualMatrix(size, 1) { i, _ -> get(i) }
|
||||
|
@ -17,6 +17,8 @@ public typealias Matrix<T> = Structure2D<T>
|
||||
|
||||
/**
|
||||
* 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<T> = Buffer<T>
|
||||
|
||||
|
@ -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<X, Y> {
|
||||
/**
|
||||
* The size of all the involved buffers.
|
||||
*/
|
||||
public val size: Int
|
||||
|
||||
/**
|
||||
* The buffer of X values.
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public interface XYPointSet<T, X : T, Y : T> : ColumnarData<T> {
|
||||
public val x: Buffer<X>
|
||||
|
||||
/**
|
||||
* The buffer of Y values.
|
||||
*/
|
||||
public val y: Buffer<Y>
|
||||
|
||||
override fun get(symbol: Symbol): Buffer<T> = when (symbol) {
|
||||
@ -15,6 +34,17 @@ public interface XYPointSet<T, X : T, Y : T> : ColumnarData<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<X, Y, Z> : XYPointSet<X, Y> {
|
||||
/**
|
||||
* The buffer of Z values.
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public interface XYZPointSet<T, X : T, Y : T, Z : T> : XYPointSet<T, X, Y> {
|
||||
public val z: Buffer<Z>
|
||||
@ -27,6 +57,10 @@ public interface XYZPointSet<T, X : T, Y : T, Z : T> : XYPointSet<T, X, Y> {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun <T : Comparable<T>> insureSorted(points: XYPointSet<T, *>) {
|
||||
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<T>(public val structure: Structure2D<T>, public val column: Int) : Buffer<T> {
|
||||
public override val size: Int
|
||||
|
@ -37,8 +37,8 @@ public fun <T, R> List<T>.cumulative(initial: R, operation: (R, T) -> R): List<R
|
||||
/**
|
||||
* Cumulative sum with custom space
|
||||
*/
|
||||
public fun <T> Iterable<T>.cumulativeSum(space: Group<T>): Iterable<T> =
|
||||
space { cumulative(zero) { element: T, sum: T -> sum + element } }
|
||||
public fun <T> Iterable<T>.cumulativeSum(group: Group<T>): Iterable<T> =
|
||||
group { cumulative(zero) { element: T, sum: T -> sum + element } }
|
||||
|
||||
@JvmName("cumulativeSumOfDouble")
|
||||
public fun Iterable<Double>.cumulativeSum(): Iterable<Double> = cumulative(0.0) { element, sum -> sum + element }
|
||||
@ -49,8 +49,8 @@ public fun Iterable<Int>.cumulativeSum(): Iterable<Int> = cumulative(0) { elemen
|
||||
@JvmName("cumulativeSumOfLong")
|
||||
public fun Iterable<Long>.cumulativeSum(): Iterable<Long> = cumulative(0L) { element, sum -> sum + element }
|
||||
|
||||
public fun <T> Sequence<T>.cumulativeSum(space: Group<T>): Sequence<T> =
|
||||
space { cumulative(zero) { element: T, sum: T -> sum + element } }
|
||||
public fun <T> Sequence<T>.cumulativeSum(group: Group<T>): Sequence<T> =
|
||||
group { cumulative(zero) { element: T, sum: T -> sum + element } }
|
||||
|
||||
@JvmName("cumulativeSumOfDouble")
|
||||
public fun Sequence<Double>.cumulativeSum(): Sequence<Double> = cumulative(0.0) { element, sum -> sum + element }
|
||||
@ -61,8 +61,8 @@ public fun Sequence<Int>.cumulativeSum(): Sequence<Int> = cumulative(0) { elemen
|
||||
@JvmName("cumulativeSumOfLong")
|
||||
public fun Sequence<Long>.cumulativeSum(): Sequence<Long> = cumulative(0L) { element, sum -> sum + element }
|
||||
|
||||
public fun <T> List<T>.cumulativeSum(space: Group<T>): List<T> =
|
||||
space { cumulative(zero) { element: T, sum: T -> sum + element } }
|
||||
public fun <T> List<T>.cumulativeSum(group: Group<T>): List<T> =
|
||||
group { cumulative(zero) { element: T, sum: T -> sum + element } }
|
||||
|
||||
@JvmName("cumulativeSumOfDouble")
|
||||
public fun List<Double>.cumulativeSum(): List<Double> = cumulative(0.0) { element, sum -> sum + element }
|
||||
|
@ -100,8 +100,8 @@ public fun <T : Any> Algebra<T>.bindSymbol(symbol: Symbol): T = bindSymbol(symbo
|
||||
public inline operator fun <A : Algebra<*>, 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<T> : Algebra<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<T> : GroupOperations<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<T> : Group<T>, RingOperations<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<T> : RingOperations<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<T> : Ring<T>, FieldOperations<T>, ScaleOperations<T>, NumericAlgebra<T> {
|
||||
override fun number(value: Number): T = scale(one, value.toDouble())
|
||||
|
@ -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()
|
||||
|
||||
/**
|
||||
|
@ -49,19 +49,19 @@ public fun <T : Comparable<T>> Group<T>.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 <T> Iterable<T>.sumWith(space: Group<T>): T = space.sum(this)
|
||||
public fun <T> Iterable<T>.sumWith(group: Group<T>): 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 <T> Sequence<T>.sumWith(space: Group<T>): T = space.sum(this)
|
||||
public fun <T> Sequence<T>.sumWith(group: Group<T>): T = group.sum(this)
|
||||
|
||||
/**
|
||||
* Returns an average value of elements in the iterable in this [Group].
|
||||
|
@ -14,7 +14,7 @@ public fun <T> Flow<T>.cumulativeSum(group: GroupOperations<T>): Flow<T> =
|
||||
group { runningReduce { sum, element -> sum + element } }
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
public fun <T, S> Flow<T>.mean(algebra: S): Flow<T> where S : Group<T>, S : ScaleOperations<T> = algebra {
|
||||
public fun <T, S> Flow<T>.mean(space: S): Flow<T> where S : Group<T>, S : ScaleOperations<T> = space {
|
||||
data class Accumulator(var sum: T, var num: Int)
|
||||
|
||||
scan(Accumulator(zero, 0)) { sum, element ->
|
||||
|
37
kmath-ejml/README.md
Normal file
37
kmath-ejml/README.md
Normal file
@ -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")
|
||||
}
|
||||
```
|
@ -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
|
||||
}
|
||||
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"
|
||||
)
|
||||
}
|
||||
|
7
kmath-ejml/docs/README-TEMPLATE.md
Normal file
7
kmath-ejml/docs/README-TEMPLATE.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Module kmath-ejml
|
||||
|
||||
EJML based linear algebra implementation.
|
||||
|
||||
${features}
|
||||
|
||||
${artifact}
|
@ -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<Double, DoubleField> {
|
||||
|
||||
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<Double, DoubleField> {
|
||||
})
|
||||
}
|
||||
|
||||
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<Double> =
|
||||
public override fun buildVector(size: Int, initializer: DoubleField.(Int) -> Double): Point<Double> =
|
||||
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<Double, DoubleField> {
|
||||
private fun SimpleMatrix.wrapMatrix() = EjmlMatrix(this)
|
||||
private fun SimpleMatrix.wrapVector() = EjmlVector(this)
|
||||
|
||||
override fun Matrix<Double>.unaryMinus(): Matrix<Double> = this * (-1.0)
|
||||
public override fun Matrix<Double>.unaryMinus(): Matrix<Double> = this * (-1.0)
|
||||
|
||||
public override fun Matrix<Double>.dot(other: Matrix<Double>): EjmlMatrix =
|
||||
EjmlMatrix(toEjml().origin.mult(other.toEjml().origin))
|
||||
@ -68,29 +74,29 @@ public object EjmlLinearSpace : LinearSpace<Double, DoubleField> {
|
||||
public override operator fun Matrix<Double>.times(value: Double): EjmlMatrix =
|
||||
toEjml().origin.scale(value).wrapMatrix()
|
||||
|
||||
override fun Point<Double>.unaryMinus(): EjmlVector =
|
||||
public override fun Point<Double>.unaryMinus(): EjmlVector =
|
||||
toEjml().origin.negative().wrapVector()
|
||||
|
||||
override fun Matrix<Double>.plus(other: Matrix<Double>): EjmlMatrix =
|
||||
public override fun Matrix<Double>.plus(other: Matrix<Double>): EjmlMatrix =
|
||||
(toEjml().origin + other.toEjml().origin).wrapMatrix()
|
||||
|
||||
override fun Point<Double>.plus(other: Point<Double>): EjmlVector =
|
||||
public override fun Point<Double>.plus(other: Point<Double>): EjmlVector =
|
||||
(toEjml().origin + other.toEjml().origin).wrapVector()
|
||||
|
||||
override fun Point<Double>.minus(other: Point<Double>): EjmlVector =
|
||||
public override fun Point<Double>.minus(other: Point<Double>): EjmlVector =
|
||||
(toEjml().origin - other.toEjml().origin).wrapVector()
|
||||
|
||||
override fun Double.times(m: Matrix<Double>): EjmlMatrix =
|
||||
public override fun Double.times(m: Matrix<Double>): EjmlMatrix =
|
||||
m.toEjml().origin.scale(this).wrapMatrix()
|
||||
|
||||
override fun Point<Double>.times(value: Double): EjmlVector =
|
||||
public override fun Point<Double>.times(value: Double): EjmlVector =
|
||||
toEjml().origin.scale(value).wrapVector()
|
||||
|
||||
override fun Double.times(v: Point<Double>): EjmlVector =
|
||||
public override fun Double.times(v: Point<Double>): EjmlVector =
|
||||
v.toEjml().origin.scale(this).wrapVector()
|
||||
|
||||
@UnstableKMathAPI
|
||||
override fun <F : StructureFeature> getFeature(structure: Matrix<Double>, type: KClass<out F>): F? {
|
||||
public override fun <F : StructureFeature> getFeature(structure: Matrix<Double>, type: KClass<out F>): 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<Double, DoubleField> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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] <sup>-1</sup> · [b]*.
|
||||
*
|
||||
* @param a the base matrix.
|
||||
* @param b n by p matrix.
|
||||
@ -172,7 +178,7 @@ public fun EjmlLinearSpace.solve(a: Matrix<Double>, b: Matrix<Double>): 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] <sup>-1</sup> · [b]*.
|
||||
*
|
||||
* @param a the base matrix.
|
||||
* @param b n by p vector.
|
||||
@ -182,7 +188,17 @@ public fun EjmlLinearSpace.solve(a: Matrix<Double>, b: Matrix<Double>): EjmlMatr
|
||||
public fun EjmlLinearSpace.solve(a: Matrix<Double>, b: Point<Double>): EjmlVector =
|
||||
EjmlVector(a.toEjml().origin.solve(b.toEjml().origin))
|
||||
|
||||
/**
|
||||
* Inverts this matrix.
|
||||
*
|
||||
* @author Alexander Nozik
|
||||
*/
|
||||
@OptIn(UnstableKMathAPI::class)
|
||||
public fun EjmlMatrix.inverted(): EjmlMatrix = getFeature<InverseMatrixFeature<Double>>()!!.inverse as EjmlMatrix
|
||||
|
||||
/**
|
||||
* Inverts the given matrix.
|
||||
*
|
||||
* @author Alexander Nozik
|
||||
*/
|
||||
public fun EjmlLinearSpace.inverse(matrix: Matrix<Double>): Matrix<Double> = matrix.toEjml().inverted()
|
@ -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
|
||||
|
@ -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<Double> {
|
||||
public inline class EjmlVector internal constructor(public val origin: SimpleMatrix) : Point<Double> {
|
||||
public override val size: Int
|
||||
get() = origin.numRows()
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
```
|
||||
|
@ -1,4 +1,6 @@
|
||||
# Real number specialization module (`kmath-for-real`)
|
||||
# Module kmath-for-real
|
||||
|
||||
Specialization of KMath APIs for Double numbers.
|
||||
|
||||
${features}
|
||||
|
||||
|
@ -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")
|
||||
}
|
||||
```
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Functions (`kmath-functions`)
|
||||
# Module kmath-functions
|
||||
|
||||
Functions and interpolations:
|
||||
Functions and interpolations.
|
||||
|
||||
${features}
|
||||
|
||||
|
@ -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<T, R> {
|
||||
/**
|
||||
* 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<T : Any> : Piecewise<T, Polynomial<T>>
|
||||
|
||||
/**
|
||||
* 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<T : Comparable<T>>(delimiter: T) :
|
||||
PiecewisePolynomial<T> {
|
||||
@ -17,8 +31,10 @@ public class OrderedPiecewisePolynomial<T : Comparable<T>>(delimiter: T) :
|
||||
private val pieces: MutableList<Polynomial<T>> = 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<T>) {
|
||||
require(right > delimiters.last()) { "New delimiter should be to the right of old one" }
|
||||
@ -26,13 +42,19 @@ public class OrderedPiecewisePolynomial<T : Comparable<T>>(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<T>) {
|
||||
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<T>? {
|
||||
public override fun findPiece(arg: T): Polynomial<T>? {
|
||||
if (arg < delimiters.first() || arg >= delimiters.last())
|
||||
return null
|
||||
else {
|
||||
@ -46,9 +68,10 @@ public class OrderedPiecewisePolynomial<T : Comparable<T>>(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 <T : Comparable<T>, C : Ring<T>> PiecewisePolynomial<T>.value(ring: C, arg: T): T? =
|
||||
findPiece(arg)?.value(ring, arg)
|
||||
|
||||
public fun <T : Comparable<T>, C : Ring<T>> PiecewisePolynomial<T>.asFunction(ring: C): (T) -> T? = { value(ring, it) }
|
||||
public fun <T : Comparable<T>, C : Ring<T>> PiecewisePolynomial<T>.asFunction(ring: C): (T) -> T? = { value(ring, it) }
|
||||
|
@ -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<T : Any>(public val coefficients: List<T>)
|
||||
|
||||
/**
|
||||
* Returns a [Polynomial] instance with given [coefficients].
|
||||
*/
|
||||
@Suppress("FunctionName")
|
||||
public fun <T : Any> Polynomial(vararg coefficients: T): Polynomial<T> = Polynomial(coefficients.toList())
|
||||
|
||||
/**
|
||||
* Evaluates the value of the given double polynomial for given double argument.
|
||||
*/
|
||||
public fun Polynomial<Double>.value(): Double = coefficients.reduceIndexed { index, acc, d -> acc + d.pow(index) }
|
||||
|
||||
/**
|
||||
* Evaluates the value of the given polynomial for given argument.
|
||||
*/
|
||||
public fun <T : Any, C : Ring<T>> Polynomial<T>.value(ring: C, arg: T): T = ring {
|
||||
if (coefficients.isEmpty()) return@ring zero
|
||||
var res = coefficients.first()
|
||||
@ -35,19 +45,23 @@ public fun <T : Any, C : Ring<T>> Polynomial<T>.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 <T : Any, C : Ring<T>> Polynomial<T>.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<T : Any, C>(
|
||||
private val ring: C,
|
||||
) : Group<Polynomial<T>>, ScaleOperations<Polynomial<T>> where C : Ring<T>, C : ScaleOperations<T> {
|
||||
public override val zero: Polynomial<T> = Polynomial(emptyList())
|
||||
|
||||
override fun Polynomial<T>.unaryMinus(): Polynomial<T> = with(ring) {
|
||||
override fun Polynomial<T>.unaryMinus(): Polynomial<T> = ring {
|
||||
Polynomial(coefficients.map { -it })
|
||||
}
|
||||
|
||||
@ -64,6 +78,9 @@ public class PolynomialSpace<T : Any, C>(
|
||||
public override fun scale(a: Polynomial<T>, value: Double): Polynomial<T> =
|
||||
ring { Polynomial(List(a.coefficients.size) { index -> a.coefficients[index] * value }) }
|
||||
|
||||
/**
|
||||
* Evaluates the polynomial for the given value [arg].
|
||||
*/
|
||||
public operator fun Polynomial<T>.invoke(arg: T): T = value(ring, arg)
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
package space.kscience.kmath.integration
|
||||
|
||||
/**
|
||||
* A general interface for all integrators
|
||||
* A general interface for all integrators.
|
||||
*/
|
||||
public interface Integrator<I : Integrand> {
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
}
|
||||
|
@ -61,4 +61,4 @@ public fun UnivariateIntegrator<Double>.integrate(
|
||||
return integrate(
|
||||
UnivariateIntegrand(function, *features.toTypedArray())
|
||||
).value ?: error("Unexpected: no value after integration.")
|
||||
}
|
||||
}
|
||||
|
@ -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<T : Comparable<T>>(
|
||||
public override val algebra: Field<T>,
|
||||
|
@ -37,11 +37,11 @@ public class LongCounter : Counter<Long> {
|
||||
override val value: Long get() = innerValue.value
|
||||
}
|
||||
|
||||
public class ObjectCounter<T : Any>(public val space: Group<T>) : Counter<T> {
|
||||
private val innerValue = atomic(space.zero)
|
||||
public class ObjectCounter<T : Any>(public val group: Group<T>) : Counter<T> {
|
||||
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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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}
|
||||
|
||||
|
@ -66,16 +66,16 @@ public fun <T, I, R> ComposableStatistic<T, I, R>.flow(
|
||||
* Arithmetic mean
|
||||
*/
|
||||
public class Mean<T>(
|
||||
private val space: Group<T>,
|
||||
private val group: Group<T>,
|
||||
private val division: (sum: T, count: Int) -> T,
|
||||
) : ComposableStatistic<T, Pair<T, Int>, T> {
|
||||
public override suspend fun computeIntermediate(data: Buffer<T>): Pair<T, Int> =
|
||||
space { sum(data.asIterable()) } to data.size
|
||||
group { sum(data.asIterable()) } to data.size
|
||||
|
||||
public override suspend fun composeIntermediate(first: Pair<T, Int>, second: Pair<T, Int>): Pair<T, Int> =
|
||||
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, Int>): T = space {
|
||||
public override suspend fun toResult(intermediate: Pair<T, Int>): T = group {
|
||||
division(intermediate.first, intermediate.second)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user