Feature: Polynomials and rational functions #469

Merged
lounres merged 132 commits from feature/polynomials into dev 2022-07-28 18:04:06 +03:00
11 changed files with 65 additions and 40 deletions
Showing only changes of commit ffea8cc223 - Show all commits

View File

@ -308,8 +308,8 @@ repositories {
} }
dependencies { dependencies {
api("space.kscience:kmath-core:0.3.0-dev-17") api("space.kscience:kmath-core:0.3.0-dev-19")
// api("space.kscience:kmath-core-jvm:0.3.0-dev-17") for jvm-specific version // api("space.kscience:kmath-core-jvm:0.3.0-dev-19") for jvm-specific version
} }
``` ```

View File

@ -10,7 +10,7 @@ Extensions to MST API: transformations, dynamic compilation and visualization.
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:kmath-ast:0.3.0-dev-17`. The Maven coordinates of this project are `space.kscience:kmath-ast:0.3.0-dev-19`.
**Gradle:** **Gradle:**
```gradle ```gradle
@ -20,7 +20,7 @@ repositories {
} }
dependencies { dependencies {
implementation 'space.kscience:kmath-ast:0.3.0-dev-17' implementation 'space.kscience:kmath-ast:0.3.0-dev-19'
} }
``` ```
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
@ -31,7 +31,7 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:kmath-ast:0.3.0-dev-17") implementation("space.kscience:kmath-ast:0.3.0-dev-19")
} }
``` ```
@ -66,20 +66,19 @@ For example, the following code:
```kotlin ```kotlin
import space.kscience.kmath.asm.compileToExpression import space.kscience.kmath.asm.compileToExpression
import space.kscience.kmath.complex.ComplexField import space.kscience.kmath.operations.DoubleField
"x+2".parseMath().compileToExpression(ComplexField) "x^3-x+3".parseMath().compileToExpression(DoubleField)
``` ```
… 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 ```java
import java.util.Map; import java.util.*;
import kotlin.jvm.functions.Function2; import kotlin.jvm.functions.*;
import space.kscience.kmath.asm.internal.MapIntrinsics; import space.kscience.kmath.asm.internal.*;
import space.kscience.kmath.complex.Complex; import space.kscience.kmath.complex.*;
import space.kscience.kmath.expressions.Expression; import space.kscience.kmath.expressions.*;
import space.kscience.kmath.expressions.Symbol;
public final class CompiledExpression_45045_0 implements Expression<Complex> { public final class CompiledExpression_45045_0 implements Expression<Complex> {
private final Object[] constants; private final Object[] constants;
@ -91,6 +90,32 @@ public final class CompiledExpression_45045_0 implements Expression<Complex> {
} }
``` ```
For `LongRing`, `IntRing`, and `DoubleField` specialization is supported for better performance:
```java
import java.util.*;
import space.kscience.kmath.asm.internal.*;
import space.kscience.kmath.expressions.*;
public final class CompiledExpression_-386104628_0 implements DoubleExpression {
private final SymbolIndexer indexer;
public SymbolIndexer getIndexer() {
return this.indexer;
}
public double invoke(double[] arguments) {
double var2 = arguments[0];
return Math.pow(var2, 3.0D) - var2 + 3.0D;
}
public final Double invoke(Map<Symbol, ? extends Double> arguments) {
double var2 = ((Double)MapIntrinsics.getOrFail(arguments, "x")).doubleValue();
return Math.pow(var2, 3.0D) - var2 + 3.0D;
}
}
```
Setting JVM system property `space.kscience.kmath.ast.dump.generated.classes` to `1` makes the translator dump class files to program's working directory, so they can be reviewed manually. Setting JVM system property `space.kscience.kmath.ast.dump.generated.classes` to `1` makes the translator dump class files to program's working directory, so they can be reviewed manually.
#### Limitations #### Limitations

View File

@ -8,7 +8,7 @@ Complex and hypercomplex number systems in KMath.
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:kmath-complex:0.3.0-dev-17`. The Maven coordinates of this project are `space.kscience:kmath-complex:0.3.0-dev-19`.
**Gradle:** **Gradle:**
```gradle ```gradle
@ -18,7 +18,7 @@ repositories {
} }
dependencies { dependencies {
implementation 'space.kscience:kmath-complex:0.3.0-dev-17' implementation 'space.kscience:kmath-complex:0.3.0-dev-19'
} }
``` ```
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
@ -29,6 +29,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:kmath-complex:0.3.0-dev-17") implementation("space.kscience:kmath-complex:0.3.0-dev-19")
} }
``` ```

View File

@ -15,7 +15,7 @@ performance calculations to code generation.
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:kmath-core:0.3.0-dev-17`. The Maven coordinates of this project are `space.kscience:kmath-core:0.3.0-dev-19`.
**Gradle:** **Gradle:**
```gradle ```gradle
@ -25,7 +25,7 @@ repositories {
} }
dependencies { dependencies {
implementation 'space.kscience:kmath-core:0.3.0-dev-17' implementation 'space.kscience:kmath-core:0.3.0-dev-19'
} }
``` ```
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
@ -36,6 +36,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:kmath-core:0.3.0-dev-17") implementation("space.kscience:kmath-core:0.3.0-dev-19")
} }
``` ```

View File

@ -9,7 +9,7 @@ EJML based linear algebra implementation.
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:kmath-ejml:0.3.0-dev-17`. The Maven coordinates of this project are `space.kscience:kmath-ejml:0.3.0-dev-19`.
**Gradle:** **Gradle:**
```gradle ```gradle
@ -19,7 +19,7 @@ repositories {
} }
dependencies { dependencies {
implementation 'space.kscience:kmath-ejml:0.3.0-dev-17' implementation 'space.kscience:kmath-ejml:0.3.0-dev-19'
} }
``` ```
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
@ -30,6 +30,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:kmath-ejml:0.3.0-dev-17") implementation("space.kscience:kmath-ejml:0.3.0-dev-19")
} }
``` ```

View File

@ -9,7 +9,7 @@ Specialization of KMath APIs for Double numbers.
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:kmath-for-real:0.3.0-dev-17`. The Maven coordinates of this project are `space.kscience:kmath-for-real:0.3.0-dev-19`.
**Gradle:** **Gradle:**
```gradle ```gradle
@ -19,7 +19,7 @@ repositories {
} }
dependencies { dependencies {
implementation 'space.kscience:kmath-for-real:0.3.0-dev-17' implementation 'space.kscience:kmath-for-real:0.3.0-dev-19'
} }
``` ```
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
@ -30,6 +30,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:kmath-for-real:0.3.0-dev-17") implementation("space.kscience:kmath-for-real:0.3.0-dev-19")
} }
``` ```

View File

@ -11,7 +11,7 @@ Functions and interpolations.
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:kmath-functions:0.3.0-dev-17`. The Maven coordinates of this project are `space.kscience:kmath-functions:0.3.0-dev-19`.
**Gradle:** **Gradle:**
```gradle ```gradle
@ -21,7 +21,7 @@ repositories {
} }
dependencies { dependencies {
implementation 'space.kscience:kmath-functions:0.3.0-dev-17' implementation 'space.kscience:kmath-functions:0.3.0-dev-19'
} }
``` ```
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
@ -32,6 +32,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:kmath-functions:0.3.0-dev-17") implementation("space.kscience:kmath-functions:0.3.0-dev-19")
} }
``` ```

View File

@ -7,7 +7,7 @@ Integration with [Jafama](https://github.com/jeffhain/jafama).
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:kmath-jafama:0.3.0-dev-17`. The Maven coordinates of this project are `space.kscience:kmath-jafama:0.3.0-dev-19`.
**Gradle:** **Gradle:**
```gradle ```gradle
@ -17,7 +17,7 @@ repositories {
} }
dependencies { dependencies {
implementation 'space.kscience:kmath-jafama:0.3.0-dev-17' implementation 'space.kscience:kmath-jafama:0.3.0-dev-19'
} }
``` ```
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
@ -28,7 +28,7 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:kmath-jafama:0.3.0-dev-17") implementation("space.kscience:kmath-jafama:0.3.0-dev-19")
} }
``` ```

View File

@ -8,7 +8,7 @@
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:kmath-kotlingrad:0.3.0-dev-17`. The Maven coordinates of this project are `space.kscience:kmath-kotlingrad:0.3.0-dev-19`.
**Gradle:** **Gradle:**
```gradle ```gradle
@ -18,7 +18,7 @@ repositories {
} }
dependencies { dependencies {
implementation 'space.kscience:kmath-kotlingrad:0.3.0-dev-17' implementation 'space.kscience:kmath-kotlingrad:0.3.0-dev-19'
} }
``` ```
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
@ -29,6 +29,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:kmath-kotlingrad:0.3.0-dev-17") implementation("space.kscience:kmath-kotlingrad:0.3.0-dev-19")
} }
``` ```

View File

@ -9,7 +9,7 @@ ND4J based implementations of KMath abstractions.
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:kmath-nd4j:0.3.0-dev-17`. The Maven coordinates of this project are `space.kscience:kmath-nd4j:0.3.0-dev-19`.
**Gradle:** **Gradle:**
```gradle ```gradle
@ -19,7 +19,7 @@ repositories {
} }
dependencies { dependencies {
implementation 'space.kscience:kmath-nd4j:0.3.0-dev-17' implementation 'space.kscience:kmath-nd4j:0.3.0-dev-19'
} }
``` ```
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
@ -30,7 +30,7 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:kmath-nd4j:0.3.0-dev-17") implementation("space.kscience:kmath-nd4j:0.3.0-dev-19")
} }
``` ```

View File

@ -9,7 +9,7 @@ Common linear algebra operations on tensors.
## Artifact: ## Artifact:
The Maven coordinates of this project are `space.kscience:kmath-tensors:0.3.0-dev-17`. The Maven coordinates of this project are `space.kscience:kmath-tensors:0.3.0-dev-19`.
**Gradle:** **Gradle:**
```gradle ```gradle
@ -19,7 +19,7 @@ repositories {
} }
dependencies { dependencies {
implementation 'space.kscience:kmath-tensors:0.3.0-dev-17' implementation 'space.kscience:kmath-tensors:0.3.0-dev-19'
} }
``` ```
**Gradle Kotlin DSL:** **Gradle Kotlin DSL:**
@ -30,6 +30,6 @@ repositories {
} }
dependencies { dependencies {
implementation("space.kscience:kmath-tensors:0.3.0-dev-17") implementation("space.kscience:kmath-tensors:0.3.0-dev-19")
} }
``` ```