Tests for large BigIntegers multiplication and power are provided. #281
@ -1,6 +0,0 @@
|
||||
<component name="CopyrightManager">
|
||||
<copyright>
|
||||
<option name="notice" value="Copyright 2018-2021 KMath contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file." />
|
||||
<option name="myName" value="kmath" />
|
||||
</copyright>
|
||||
</component>
|
@ -1,7 +0,0 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings default="kmath">
|
||||
<module2copyright>
|
||||
<element module="Project Files" copyright="kmath" />
|
||||
</module2copyright>
|
||||
</settings>
|
||||
</component>
|
@ -22,6 +22,7 @@
|
||||
- Redesign advanced Chain API
|
||||
- Redesign MST. Remove MSTExpression.
|
||||
- Move MST to core
|
||||
- Separated benchmarks and examples
|
||||
|
||||
### Deprecated
|
||||
|
||||
|
27
README.md
27
README.md
@ -89,9 +89,9 @@ KMath is a modular library. Different modules provide different features with di
|
||||
>
|
||||
> **Features:**
|
||||
> - [expression-language](kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/ast/parser.kt) : Expression language and its parser
|
||||
> - [mst](kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/MST.kt) : MST (Mathematical Syntax Tree) as expression language's syntax intermediate representation
|
||||
> - [mst-building](kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/MstAlgebra.kt) : MST building algebraic structure
|
||||
> - [mst-interpreter](kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/MST.kt) : MST interpreter
|
||||
> - [mst](kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MST.kt) : MST (Mathematical Syntax Tree) as expression language's syntax intermediate representation
|
||||
> - [mst-building](kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MstAlgebra.kt) : MST building algebraic structure
|
||||
> - [mst-interpreter](kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/MST.kt) : MST interpreter
|
||||
> - [mst-jvm-codegen](kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/asm/asm.kt) : Dynamic MST to JVM bytecode compiler
|
||||
> - [mst-js-codegen](kmath-ast/src/jsMain/kotlin/space/kscience/kmath/estree/estree.kt) : Dynamic MST to JS compiler
|
||||
|
||||
@ -171,15 +171,16 @@ One can still use generic algebras though.
|
||||
<hr/>
|
||||
|
||||
* ### [kmath-functions](kmath-functions)
|
||||
> Functions and interpolation
|
||||
> Functions, integration and interpolation
|
||||
>
|
||||
> **Maturity**: PROTOTYPE
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
>
|
||||
> **Features:**
|
||||
> - [piecewise](kmath-functions/Piecewise functions.) : src/commonMain/kotlin/space/kscience/kmath/functions/Piecewise.kt
|
||||
> - [polynomials](kmath-functions/Polynomial functions.) : src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt
|
||||
> - [linear interpolation](kmath-functions/Linear XY interpolator.) : src/commonMain/kotlin/space/kscience/kmath/interpolation/LinearInterpolator.kt
|
||||
> - [spline interpolation](kmath-functions/Cubic spline XY interpolator.) : src/commonMain/kotlin/space/kscience/kmath/interpolation/SplineInterpolator.kt
|
||||
> - [piecewise](kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Piecewise.kt) : Piecewise functions.
|
||||
> - [polynomials](kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt) : Polynomial functions.
|
||||
> - [linear interpolation](kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/LinearInterpolator.kt) : Linear XY interpolator.
|
||||
> - [spline interpolation](kmath-functions/src/commonMain/kotlin/space/kscience/kmath/interpolation/SplineInterpolator.kt) : Cubic spline XY interpolator.
|
||||
> - [integration](kmath-functions/#) : Univariate and multivariate quadratures
|
||||
|
||||
<hr/>
|
||||
|
||||
@ -250,6 +251,10 @@ cases. We expect the worst KMath benchmarks will perform better than native Pyth
|
||||
native/SciPy (mostly due to boxing operations on primitive numbers). The best performance of optimized parts could be
|
||||
better than SciPy.
|
||||
|
||||
## Requirements
|
||||
|
||||
KMath currently relies on JDK 11 for compilation and execution of Kotlin-JVM part. We recommend to use GraalVM-CE 11 for execution in order to get better performance.
|
||||
|
||||
### Repositories
|
||||
|
||||
Release and development artifacts are accessible from mipt-npm [Space](https://www.jetbrains.com/space/) repository `https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven` (see documentation of
|
||||
@ -261,8 +266,8 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api("space.kscience:kmath-core:0.3.0-dev-4")
|
||||
// api("space.kscience.kmath:kmath-core-jvm:0.3.0-dev-4") for jvm-specific version
|
||||
api("space.kscience:kmath-core:0.3.0-dev-6")
|
||||
// api("space.kscience:kmath-core-jvm:0.3.0-dev-6") for jvm-specific version
|
||||
}
|
||||
```
|
||||
|
||||
|
147
benchmarks/build.gradle.kts
Normal file
147
benchmarks/build.gradle.kts
Normal file
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright 2018-2021 KMath contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
import ru.mipt.npm.gradle.Maturity
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
kotlin("plugin.allopen")
|
||||
id("org.jetbrains.kotlinx.benchmark")
|
||||
}
|
||||
|
||||
allOpen.annotation("org.openjdk.jmh.annotations.State")
|
||||
sourceSets.register("benchmarks")
|
||||
|
||||
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven("https://repo.kotlin.link")
|
||||
maven("https://clojars.org/repo")
|
||||
maven("https://dl.bintray.com/egor-bogomolov/astminer/")
|
||||
maven("https://dl.bintray.com/hotkeytlt/maven")
|
||||
maven("https://jitpack.io")
|
||||
maven {
|
||||
setUrl("http://logicrunch.research.it.uu.se/maven/")
|
||||
isAllowInsecureProtocol = true
|
||||
}
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation(project(":kmath-ast"))
|
||||
implementation(project(":kmath-core"))
|
||||
implementation(project(":kmath-coroutines"))
|
||||
implementation(project(":kmath-complex"))
|
||||
implementation(project(":kmath-stat"))
|
||||
implementation(project(":kmath-dimensions"))
|
||||
implementation(project(":kmath-for-real"))
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.3.0")
|
||||
}
|
||||
}
|
||||
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
implementation(project(":kmath-commons"))
|
||||
implementation(project(":kmath-ejml"))
|
||||
implementation(project(":kmath-nd4j"))
|
||||
implementation(project(":kmath-kotlingrad"))
|
||||
implementation(project(":kmath-viktor"))
|
||||
implementation("org.nd4j:nd4j-native:1.0.0-beta7")
|
||||
|
||||
// uncomment if your system supports AVX2
|
||||
// val os = System.getProperty("os.name")
|
||||
//
|
||||
// if (System.getProperty("os.arch") in arrayOf("x86_64", "amd64")) when {
|
||||
// os.startsWith("Windows") -> implementation("org.nd4j:nd4j-native:1.0.0-beta7:windows-x86_64-avx2")
|
||||
// os == "Linux" -> implementation("org.nd4j:nd4j-native:1.0.0-beta7:linux-x86_64-avx2")
|
||||
// os == "Mac OS X" -> implementation("org.nd4j:nd4j-native:1.0.0-beta7:macosx-x86_64-avx2")
|
||||
// } else
|
||||
// implementation("org.nd4j:nd4j-native-platform:1.0.0-beta7")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Configure benchmark
|
||||
benchmark {
|
||||
// Setup configurations
|
||||
targets {
|
||||
register("jvm")
|
||||
}
|
||||
|
||||
configurations.register("buffer") {
|
||||
warmups = 1 // number of warmup iterations
|
||||
iterations = 3 // number of iterations
|
||||
iterationTime = 500 // time in seconds per iteration
|
||||
iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
|
||||
include("BufferBenchmark")
|
||||
}
|
||||
|
||||
configurations.register("dot") {
|
||||
warmups = 1 // number of warmup iterations
|
||||
iterations = 3 // number of iterations
|
||||
iterationTime = 500 // time in seconds per iteration
|
||||
iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
|
||||
include("DotBenchmark")
|
||||
}
|
||||
|
||||
configurations.register("expressions") {
|
||||
warmups = 1 // number of warmup iterations
|
||||
iterations = 3 // number of iterations
|
||||
iterationTime = 500 // time in seconds per iteration
|
||||
iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
|
||||
include("ExpressionsInterpretersBenchmark")
|
||||
}
|
||||
|
||||
configurations.register("matrixInverse") {
|
||||
warmups = 1 // number of warmup iterations
|
||||
iterations = 3 // number of iterations
|
||||
iterationTime = 500 // time in seconds per iteration
|
||||
iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
|
||||
include("MatrixInverseBenchmark")
|
||||
}
|
||||
|
||||
configurations.register("bigInt") {
|
||||
warmups = 1 // number of warmup iterations
|
||||
iterations = 3 // number of iterations
|
||||
iterationTime = 500 // time in seconds per iteration
|
||||
iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
|
||||
include("BigIntBenchmark")
|
||||
}
|
||||
}
|
||||
|
||||
// Fix kotlinx-benchmarks bug
|
||||
afterEvaluate {
|
||||
val jvmBenchmarkJar by tasks.getting(org.gradle.jvm.tasks.Jar::class) {
|
||||
duplicatesStrategy = org.gradle.api.file.DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
kotlin.sourceSets.all {
|
||||
with(languageSettings) {
|
||||
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
||||
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
|
||||
useExperimentalAnnotation("space.kscience.kmath.misc.UnstableKMathAPI")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
readme {
|
||||
maturity = Maturity.EXPERIMENTAL
|
||||
}
|
@ -25,7 +25,7 @@ allprojects {
|
||||
}
|
||||
|
||||
group = "space.kscience"
|
||||
version = "0.3.0-dev-6"
|
||||
version = "0.3.0-dev-7"
|
||||
}
|
||||
|
||||
subprojects {
|
||||
|
4
docs/templates/README-TEMPLATE.md
vendored
4
docs/templates/README-TEMPLATE.md
vendored
@ -94,6 +94,10 @@ cases. We expect the worst KMath benchmarks will perform better than native Pyth
|
||||
native/SciPy (mostly due to boxing operations on primitive numbers). The best performance of optimized parts could be
|
||||
better than SciPy.
|
||||
|
||||
## Requirements
|
||||
|
||||
KMath currently relies on JDK 11 for compilation and execution of Kotlin-JVM part. We recommend to use GraalVM-CE 11 for execution in order to get better performance.
|
||||
|
||||
### Repositories
|
||||
|
||||
Release and development artifacts are accessible from mipt-npm [Space](https://www.jetbrains.com/space/) repository `https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven` (see documentation of
|
||||
|
@ -8,29 +8,20 @@ import ru.mipt.npm.gradle.Maturity
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
kotlin("plugin.allopen")
|
||||
id("org.jetbrains.kotlinx.benchmark")
|
||||
}
|
||||
|
||||
allOpen.annotation("org.openjdk.jmh.annotations.State")
|
||||
sourceSets.register("benchmarks")
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven("https://repo.kotlin.link")
|
||||
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")
|
||||
maven("https://dl.bintray.com/mipt-npm/kscience")
|
||||
maven("https://jitpack.io")
|
||||
maven{
|
||||
setUrl("http://logicrunch.research.it.uu.se/maven/")
|
||||
isAllowInsecureProtocol = true
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -48,7 +39,6 @@ dependencies {
|
||||
|
||||
implementation(project(":kmath-for-real"))
|
||||
|
||||
implementation("org.deeplearning4j:deeplearning4j-core:1.0.0-beta7")
|
||||
implementation("org.nd4j:nd4j-native:1.0.0-beta7")
|
||||
|
||||
// uncomment if your system supports AVX2
|
||||
@ -61,62 +51,9 @@ dependencies {
|
||||
// } else
|
||||
implementation("org.nd4j:nd4j-native-platform:1.0.0-beta7")
|
||||
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-io:0.2.0-npm-dev-11")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-benchmark-runtime:0.3.0")
|
||||
implementation("org.slf4j:slf4j-simple:1.7.30")
|
||||
|
||||
// plotting
|
||||
implementation("kscience.plotlykt:plotlykt-server:0.3.1-dev")
|
||||
|
||||
"benchmarksImplementation"("org.jetbrains.kotlinx:kotlinx.benchmark.runtime-jvm:0.2.0-dev-20")
|
||||
"benchmarksImplementation"(sourceSets.main.get().output + sourceSets.main.get().runtimeClasspath)
|
||||
}
|
||||
|
||||
// Configure benchmark
|
||||
benchmark {
|
||||
// Setup configurations
|
||||
targets.register("benchmarks")
|
||||
// This one matches sourceSet name above
|
||||
|
||||
configurations.register("buffer") {
|
||||
warmups = 1 // number of warmup iterations
|
||||
iterations = 3 // number of iterations
|
||||
iterationTime = 500 // time in seconds per iteration
|
||||
iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
|
||||
include("BufferBenchmark")
|
||||
}
|
||||
|
||||
configurations.register("dot") {
|
||||
warmups = 1 // number of warmup iterations
|
||||
iterations = 3 // number of iterations
|
||||
iterationTime = 500 // time in seconds per iteration
|
||||
iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
|
||||
include("DotBenchmark")
|
||||
}
|
||||
|
||||
configurations.register("expressions") {
|
||||
warmups = 1 // number of warmup iterations
|
||||
iterations = 3 // number of iterations
|
||||
iterationTime = 500 // time in seconds per iteration
|
||||
iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
|
||||
include("ExpressionsInterpretersBenchmark")
|
||||
}
|
||||
|
||||
configurations.register("matrixInverse") {
|
||||
warmups = 1 // number of warmup iterations
|
||||
iterations = 3 // number of iterations
|
||||
iterationTime = 500 // time in seconds per iteration
|
||||
iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
|
||||
include("MatrixInverseBenchmark")
|
||||
}
|
||||
|
||||
configurations.register("bigInt") {
|
||||
warmups = 1 // number of warmup iterations
|
||||
iterations = 3 // number of iterations
|
||||
iterationTime = 500 // time in seconds per iteration
|
||||
iterationTimeUnit = "ms" // time unity for iterationTime, default is seconds
|
||||
include("BigIntBenchmark")
|
||||
}
|
||||
implementation("space.kscience:plotlykt-server:0.4.0-dev-2")
|
||||
}
|
||||
|
||||
kotlin.sourceSets.all {
|
||||
|
@ -7,9 +7,6 @@ package space.kscience.kmath.commons.fit
|
||||
|
||||
import kotlinx.html.br
|
||||
import kotlinx.html.h3
|
||||
import kscience.plotly.*
|
||||
import kscience.plotly.models.ScatterMode
|
||||
import kscience.plotly.models.TraceValues
|
||||
import space.kscience.kmath.commons.optimization.chiSquared
|
||||
import space.kscience.kmath.commons.optimization.minimize
|
||||
import space.kscience.kmath.distributions.NormalDistribution
|
||||
@ -22,6 +19,9 @@ import space.kscience.kmath.real.step
|
||||
import space.kscience.kmath.stat.RandomGenerator
|
||||
import space.kscience.kmath.structures.asIterable
|
||||
import space.kscience.kmath.structures.toList
|
||||
import space.kscience.plotly.*
|
||||
import space.kscience.plotly.models.ScatterMode
|
||||
import space.kscience.plotly.models.TraceValues
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.sqrt
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
package space.kscience.kmath.functions
|
||||
|
||||
import space.kscience.kmath.integration.GaussIntegrator
|
||||
import space.kscience.kmath.integration.integrate
|
||||
import space.kscience.kmath.integration.value
|
||||
import space.kscience.kmath.operations.DoubleField
|
||||
import kotlin.math.pow
|
||||
|
||||
fun main() {
|
||||
@ -9,7 +10,7 @@ fun main() {
|
||||
val function: UnivariateFunction<Double> = { x -> 3 * x.pow(2) + 2 * x + 1 }
|
||||
|
||||
//get the result of the integration
|
||||
val result = GaussIntegrator.legendre(0.0..10.0, function = function)
|
||||
val result = DoubleField.integrate(0.0..10.0, function = function)
|
||||
|
||||
//the value is nullable because in some cases the integration could not succeed
|
||||
println(result.value)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package space.kscience.kmath.functions
|
||||
|
||||
import space.kscience.kmath.integration.GaussIntegrator
|
||||
import space.kscience.kmath.integration.UnivariateIntegrand
|
||||
import space.kscience.kmath.integration.integrate
|
||||
import space.kscience.kmath.integration.value
|
||||
import space.kscience.kmath.nd.StructureND
|
||||
import space.kscience.kmath.nd.nd
|
||||
@ -10,11 +9,17 @@ import space.kscience.kmath.operations.invoke
|
||||
|
||||
fun main(): Unit = DoubleField {
|
||||
nd(2, 2) {
|
||||
|
||||
//Produce a diagonal StructureND
|
||||
fun diagonal(v: Double) = produce { (i, j) ->
|
||||
if (i == j) v else 0.0
|
||||
}
|
||||
|
||||
//Define a function in a nd space
|
||||
val function: UnivariateFunction<StructureND<Double>> = { x -> 3 * x.pow(2) + 2 * x + 1 }
|
||||
val function: (Double) -> StructureND<Double> = { x: Double -> 3 * number(x).pow(2) + 2 * diagonal(x) + 1 }
|
||||
|
||||
//get the result of the integration
|
||||
val result: UnivariateIntegrand<StructureND<Double>> = GaussIntegrator.legendre(this, 0.0..10.0, function = function)
|
||||
val result = integrate(0.0..10.0, function = function)
|
||||
|
||||
//the value is nullable because in some cases the integration could not succeed
|
||||
println(result.value)
|
||||
|
7
gradle/wrapper/gradle-wrapper.properties
vendored
7
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,10 +1,5 @@
|
||||
#
|
||||
# Copyright 2018-2021 KMath contributors.
|
||||
# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
#
|
||||
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -3,16 +3,16 @@
|
||||
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](../kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/MST.kt) : MST (Mathematical Syntax Tree) as expression language's syntax intermediate representation
|
||||
- [mst-building](../kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/MstAlgebra.kt) : MST building algebraic structure
|
||||
- [mst-interpreter](../kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/MST.kt) : MST interpreter
|
||||
- [mst](src/commonMain/kotlin/space/kscience/kmath/ast/MST.kt) : MST (Mathematical Syntax Tree) as expression language's syntax intermediate representation
|
||||
- [mst-building](src/commonMain/kotlin/space/kscience/kmath/ast/MstAlgebra.kt) : MST building algebraic structure
|
||||
- [mst-interpreter](src/commonMain/kotlin/space/kscience/kmath/ast/MST.kt) : MST interpreter
|
||||
- [mst-jvm-codegen](src/jvmMain/kotlin/space/kscience/kmath/asm/asm.kt) : Dynamic MST to JVM bytecode compiler
|
||||
- [mst-js-codegen](src/jsMain/kotlin/space/kscience/kmath/estree/estree.kt) : Dynamic MST to JS compiler
|
||||
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-ast:0.3.0-dev-4`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-ast:0.3.0-dev-6`.
|
||||
|
||||
**Gradle:**
|
||||
```gradle
|
||||
@ -23,7 +23,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'space.kscience:kmath-ast:0.3.0-dev-4'
|
||||
implementation 'space.kscience:kmath-ast:0.3.0-dev-6'
|
||||
}
|
||||
```
|
||||
**Gradle Kotlin DSL:**
|
||||
@ -35,7 +35,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-ast:0.3.0-dev-4")
|
||||
implementation("space.kscience:kmath-ast:0.3.0-dev-6")
|
||||
}
|
||||
```
|
||||
|
||||
@ -52,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;
|
||||
|
@ -8,7 +8,7 @@ Complex and hypercomplex number systems in KMath.
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-complex:0.3.0-dev-4`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-complex:0.3.0-dev-6`.
|
||||
|
||||
**Gradle:**
|
||||
```gradle
|
||||
@ -19,7 +19,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'space.kscience:kmath-complex:0.3.0-dev-4'
|
||||
implementation 'space.kscience:kmath-complex:0.3.0-dev-6'
|
||||
}
|
||||
```
|
||||
**Gradle Kotlin DSL:**
|
||||
@ -31,6 +31,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-complex:0.3.0-dev-4")
|
||||
implementation("space.kscience:kmath-complex:0.3.0-dev-6")
|
||||
}
|
||||
```
|
||||
|
@ -12,10 +12,6 @@ plugins {
|
||||
}
|
||||
|
||||
kotlin.sourceSets {
|
||||
all {
|
||||
languageSettings.useExperimentalAnnotation("kscience.kmath.misc.UnstableKMathAPI")
|
||||
}
|
||||
|
||||
commonMain {
|
||||
dependencies {
|
||||
api(project(":kmath-core"))
|
||||
|
@ -15,7 +15,7 @@ performance calculations to code generation.
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-core:0.3.0-dev-4`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-core:0.3.0-dev-6`.
|
||||
|
||||
**Gradle:**
|
||||
```gradle
|
||||
@ -26,7 +26,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'space.kscience:kmath-core:0.3.0-dev-4'
|
||||
implementation 'space.kscience:kmath-core:0.3.0-dev-6'
|
||||
}
|
||||
```
|
||||
**Gradle Kotlin DSL:**
|
||||
@ -38,6 +38,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-core:0.3.0-dev-4")
|
||||
implementation("space.kscience:kmath-core:0.3.0-dev-6")
|
||||
}
|
||||
```
|
||||
|
@ -1,8 +1,3 @@
|
||||
/*
|
||||
* Copyright 2018-2021 KMath contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
id("ru.mipt.npm.gradle.common")
|
||||
|
@ -9,7 +9,7 @@ EJML based linear algebra implementation.
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-ejml:0.3.0-dev-4`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-ejml:0.3.0-dev-6`.
|
||||
|
||||
**Gradle:**
|
||||
```gradle
|
||||
@ -20,7 +20,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'space.kscience:kmath-ejml:0.3.0-dev-4'
|
||||
implementation 'space.kscience:kmath-ejml:0.3.0-dev-6'
|
||||
}
|
||||
```
|
||||
**Gradle Kotlin DSL:**
|
||||
@ -32,6 +32,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-ejml:0.3.0-dev-4")
|
||||
implementation("space.kscience:kmath-ejml:0.3.0-dev-6")
|
||||
}
|
||||
```
|
||||
|
@ -1,10 +1,3 @@
|
||||
/*
|
||||
* Copyright 2018-2021 KMath contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
import ru.mipt.npm.gradle.Maturity
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("ru.mipt.npm.gradle.common")
|
||||
@ -16,7 +9,7 @@ dependencies {
|
||||
}
|
||||
|
||||
readme {
|
||||
maturity = Maturity.PROTOTYPE
|
||||
maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE
|
||||
propertyByTemplate("artifact", rootProject.file("docs/templates/ARTIFACT-TEMPLATE.md"))
|
||||
|
||||
feature(
|
||||
|
@ -14,7 +14,7 @@ import space.kscience.kmath.linear.Point
|
||||
* @property origin the underlying [SimpleMatrix].
|
||||
* @author Iaroslav Postovalov
|
||||
*/
|
||||
public inline class EjmlVector internal constructor(public val origin: SimpleMatrix) : Point<Double> {
|
||||
public class EjmlVector internal constructor(public val origin: SimpleMatrix) : Point<Double> {
|
||||
public override val size: Int
|
||||
get() = origin.numRows()
|
||||
|
||||
|
@ -9,7 +9,7 @@ Specialization of KMath APIs for Double numbers.
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-for-real:0.3.0-dev-4`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-for-real:0.3.0-dev-6`.
|
||||
|
||||
**Gradle:**
|
||||
```gradle
|
||||
@ -20,7 +20,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'space.kscience:kmath-for-real:0.3.0-dev-4'
|
||||
implementation 'space.kscience:kmath-for-real:0.3.0-dev-6'
|
||||
}
|
||||
```
|
||||
**Gradle Kotlin DSL:**
|
||||
@ -32,6 +32,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-for-real:0.3.0-dev-4")
|
||||
implementation("space.kscience:kmath-for-real:0.3.0-dev-6")
|
||||
}
|
||||
```
|
||||
|
@ -1,10 +1,3 @@
|
||||
/*
|
||||
* Copyright 2018-2021 KMath contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
import ru.mipt.npm.gradle.Maturity
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
id("ru.mipt.npm.gradle.common")
|
||||
@ -22,7 +15,7 @@ readme {
|
||||
All operations are specialized to work with `Double` numbers without declaring algebraic contexts.
|
||||
One can still use generic algebras though.
|
||||
""".trimIndent()
|
||||
maturity = Maturity.EXPERIMENTAL
|
||||
maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL
|
||||
propertyByTemplate("artifact", rootProject.file("docs/templates/ARTIFACT-TEMPLATE.md"))
|
||||
|
||||
feature(
|
||||
|
@ -2,15 +2,16 @@
|
||||
|
||||
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
|
||||
- [linear interpolation](Linear XY interpolator.) : src/commonMain/kotlin/space/kscience/kmath/interpolation/LinearInterpolator.kt
|
||||
- [spline interpolation](Cubic spline XY interpolator.) : src/commonMain/kotlin/space/kscience/kmath/interpolation/SplineInterpolator.kt
|
||||
- [piecewise](src/commonMain/kotlin/space/kscience/kmath/functions/Piecewise.kt) : Piecewise functions.
|
||||
- [polynomials](src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt) : Polynomial functions.
|
||||
- [linear interpolation](src/commonMain/kotlin/space/kscience/kmath/interpolation/LinearInterpolator.kt) : Linear XY interpolator.
|
||||
- [spline interpolation](src/commonMain/kotlin/space/kscience/kmath/interpolation/SplineInterpolator.kt) : Cubic spline XY interpolator.
|
||||
- [integration](#) : Univariate and multivariate quadratures
|
||||
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-functions:0.3.0-dev-4`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-functions:0.3.0-dev-6`.
|
||||
|
||||
**Gradle:**
|
||||
```gradle
|
||||
@ -21,7 +22,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'space.kscience:kmath-functions:0.3.0-dev-4'
|
||||
implementation 'space.kscience:kmath-functions:0.3.0-dev-6'
|
||||
}
|
||||
```
|
||||
**Gradle Kotlin DSL:**
|
||||
@ -33,6 +34,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-functions:0.3.0-dev-4")
|
||||
implementation("space.kscience:kmath-functions:0.3.0-dev-6")
|
||||
}
|
||||
```
|
||||
|
@ -5,7 +5,6 @@
|
||||
package space.kscience.kmath.integration
|
||||
|
||||
import space.kscience.kmath.misc.UnstableKMathAPI
|
||||
import space.kscience.kmath.operations.DoubleField
|
||||
import space.kscience.kmath.operations.Field
|
||||
import space.kscience.kmath.structures.*
|
||||
|
||||
@ -15,12 +14,10 @@ import space.kscience.kmath.structures.*
|
||||
*/
|
||||
public class GaussIntegrator<T : Any>(
|
||||
public val algebra: Field<T>,
|
||||
public val bufferFactory: BufferFactory<T>,
|
||||
) : UnivariateIntegrator<T> {
|
||||
|
||||
private fun buildRule(integrand: UnivariateIntegrand<T>): Pair<Buffer<T>, Buffer<T>> {
|
||||
val factory = integrand.getFeature<GaussIntegratorRuleFactory<T>>()
|
||||
?: GenericGaussLegendreRuleFactory(algebra, bufferFactory)
|
||||
private fun buildRule(integrand: UnivariateIntegrand<T>): Pair<Buffer<Double>, Buffer<Double>> {
|
||||
val factory = integrand.getFeature<GaussIntegratorRuleFactory>() ?: GaussLegendreRuleFactory
|
||||
val numPoints = integrand.getFeature<IntegrandMaxCalls>()?.maxCalls ?: 100
|
||||
val range = integrand.getFeature<IntegrationRange<Double>>()?.range ?: 0.0..1.0
|
||||
return factory.build(numPoints, range)
|
||||
@ -32,9 +29,9 @@ public class GaussIntegrator<T : Any>(
|
||||
var res = zero
|
||||
var c = zero
|
||||
for (i in points.indices) {
|
||||
val x: T = points[i]
|
||||
val w: T = weights[i]
|
||||
val y: T = w * f(x) - c
|
||||
val x = points[i]
|
||||
val weight = weights[i]
|
||||
val y: T = weight * f(x) - c
|
||||
val t = res + y
|
||||
c = t - res - y
|
||||
res = t
|
||||
@ -44,68 +41,38 @@ public class GaussIntegrator<T : Any>(
|
||||
|
||||
public companion object {
|
||||
|
||||
/**
|
||||
* Integrate [T]-valued univariate function using provided set of [IntegrandFeature]
|
||||
* Following features are evaluated:
|
||||
* * [GaussIntegratorRuleFactory] - A factory for computing the Gauss integration rule. By default uses [GenericGaussLegendreRuleFactory]
|
||||
* * [IntegrationRange] - the univariate range of integration. By default uses 0..1 interval.
|
||||
* * [IntegrandMaxCalls] - the maximum number of function calls during integration. For non-iterative rules, always uses the maximum number of points. By default uses 100 points.
|
||||
*/
|
||||
public fun <T : Any> integrate(
|
||||
algebra: Field<T>,
|
||||
bufferFactory: BufferFactory<T> = ::ListBuffer,
|
||||
vararg features: IntegrandFeature,
|
||||
function: (T) -> T,
|
||||
): UnivariateIntegrand<T> =
|
||||
GaussIntegrator(algebra, bufferFactory).integrate(UnivariateIntegrand(function, *features))
|
||||
|
||||
/**
|
||||
* Integrate in real numbers
|
||||
*/
|
||||
public fun integrate(
|
||||
vararg features: IntegrandFeature,
|
||||
function: (Double) -> Double,
|
||||
): UnivariateIntegrand<Double> = integrate(DoubleField, ::DoubleBuffer, features = features, function)
|
||||
|
||||
/**
|
||||
* Integrate given [function] in a [range] with Gauss-Legendre quadrature with [numPoints] points.
|
||||
* The [range] is automatically transformed into [T] using [Field.number]
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public fun <T : Any> legendre(
|
||||
algebra: Field<T>,
|
||||
range: ClosedRange<Double>,
|
||||
numPoints: Int = 100,
|
||||
bufferFactory: BufferFactory<T> = ::ListBuffer,
|
||||
vararg features: IntegrandFeature,
|
||||
function: (T) -> T,
|
||||
): UnivariateIntegrand<T> = GaussIntegrator(algebra, bufferFactory).integrate(
|
||||
UnivariateIntegrand(
|
||||
function,
|
||||
IntegrationRange(range),
|
||||
DoubleGaussLegendreRuleFactory,
|
||||
IntegrandMaxCalls(numPoints),
|
||||
*features
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* Integrate given [function] in a [range] with Gauss-Legendre quadrature with [numPoints] points.
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public fun legendre(
|
||||
range: ClosedRange<Double>,
|
||||
numPoints: Int = 100,
|
||||
vararg features: IntegrandFeature,
|
||||
function: (Double) -> Double,
|
||||
): UnivariateIntegrand<Double> = GaussIntegrator(DoubleField, ::DoubleBuffer).integrate(
|
||||
UnivariateIntegrand(
|
||||
function,
|
||||
IntegrationRange(range),
|
||||
DoubleGaussLegendreRuleFactory,
|
||||
IntegrandMaxCalls(numPoints),
|
||||
*features
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Integrate [T]-valued univariate function using provided set of [IntegrandFeature]
|
||||
* Following features are evaluated:
|
||||
* * [GaussIntegratorRuleFactory] - A factory for computing the Gauss integration rule. By default uses [GaussLegendreRuleFactory]
|
||||
* * [IntegrationRange] - the univariate range of integration. By default uses 0..1 interval.
|
||||
* * [IntegrandMaxCalls] - the maximum number of function calls during integration. For non-iterative rules, always uses the maximum number of points. By default uses 100 points.
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public fun <T : Any> Field<T>.integrate(
|
||||
vararg features: IntegrandFeature,
|
||||
function: (Double) -> T,
|
||||
): UnivariateIntegrand<T> = GaussIntegrator(this).integrate(UnivariateIntegrand(function, *features))
|
||||
|
||||
|
||||
/**
|
||||
* Use [GaussIntegrator.Companion.integrate] to integrate the function in the current algebra with given [range] and [numPoints]
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public fun <T : Any> Field<T>.integrate(
|
||||
range: ClosedRange<Double>,
|
||||
numPoints: Int = 100,
|
||||
vararg features: IntegrandFeature,
|
||||
function: (Double) -> T,
|
||||
): UnivariateIntegrand<T> = GaussIntegrator(this).integrate(
|
||||
UnivariateIntegrand(
|
||||
function,
|
||||
IntegrationRange(range),
|
||||
GaussLegendreRuleFactory,
|
||||
IntegrandMaxCalls(numPoints),
|
||||
*features
|
||||
)
|
||||
)
|
@ -5,22 +5,20 @@
|
||||
|
||||
package space.kscience.kmath.integration
|
||||
|
||||
import space.kscience.kmath.operations.DoubleField
|
||||
import space.kscience.kmath.operations.Field
|
||||
import space.kscience.kmath.structures.*
|
||||
import space.kscience.kmath.structures.Buffer
|
||||
import space.kscience.kmath.structures.DoubleBuffer
|
||||
import space.kscience.kmath.structures.asBuffer
|
||||
import space.kscience.kmath.structures.map
|
||||
import kotlin.jvm.Synchronized
|
||||
import kotlin.math.ulp
|
||||
import kotlin.native.concurrent.ThreadLocal
|
||||
|
||||
public interface GaussIntegratorRuleFactory<T : Any> : IntegrandFeature {
|
||||
public val algebra: Field<T>
|
||||
public val bufferFactory: BufferFactory<T>
|
||||
|
||||
public fun build(numPoints: Int): Pair<Buffer<T>, Buffer<T>>
|
||||
public interface GaussIntegratorRuleFactory : IntegrandFeature {
|
||||
public fun build(numPoints: Int): Pair<Buffer<Double>, Buffer<Double>>
|
||||
|
||||
public companion object {
|
||||
public fun double(numPoints: Int, range: ClosedRange<Double>): Pair<Buffer<Double>, Buffer<Double>> =
|
||||
DoubleGaussLegendreRuleFactory.build(numPoints, range)
|
||||
GaussLegendreRuleFactory.build(numPoints, range)
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,24 +26,23 @@ public interface GaussIntegratorRuleFactory<T : Any> : IntegrandFeature {
|
||||
* Create an integration rule by scaling existing normalized rule
|
||||
*
|
||||
*/
|
||||
public fun <T : Any> GaussIntegratorRuleFactory<T>.build(
|
||||
public fun GaussIntegratorRuleFactory.build(
|
||||
numPoints: Int,
|
||||
range: ClosedRange<Double>,
|
||||
): Pair<Buffer<T>, Buffer<T>> {
|
||||
): Pair<Buffer<Double>, Buffer<Double>> {
|
||||
val normalized = build(numPoints)
|
||||
with(algebra) {
|
||||
val length = range.endInclusive - range.start
|
||||
val length = range.endInclusive - range.start
|
||||
|
||||
val points = normalized.first.map(bufferFactory) {
|
||||
number(range.start + length / 2) + number(length / 2) * it
|
||||
}
|
||||
|
||||
val weights = normalized.second.map(bufferFactory) {
|
||||
it * length / 2
|
||||
}
|
||||
|
||||
return points to weights
|
||||
val points = normalized.first.map(::DoubleBuffer) {
|
||||
range.start + length / 2 + length / 2 * it
|
||||
}
|
||||
|
||||
val weights = normalized.second.map(::DoubleBuffer) {
|
||||
it * length / 2
|
||||
}
|
||||
|
||||
return points to weights
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -56,11 +53,7 @@ public fun <T : Any> GaussIntegratorRuleFactory<T>.build(
|
||||
*
|
||||
*/
|
||||
@ThreadLocal
|
||||
public object DoubleGaussLegendreRuleFactory : GaussIntegratorRuleFactory<Double> {
|
||||
|
||||
override val algebra: Field<Double> get() = DoubleField
|
||||
|
||||
override val bufferFactory: BufferFactory<Double> get() = ::DoubleBuffer
|
||||
public object GaussLegendreRuleFactory : GaussIntegratorRuleFactory {
|
||||
|
||||
private val cache = HashMap<Int, Pair<Buffer<Double>, Buffer<Double>>>()
|
||||
|
||||
@ -172,21 +165,3 @@ public object DoubleGaussLegendreRuleFactory : GaussIntegratorRuleFactory<Double
|
||||
|
||||
override fun build(numPoints: Int): Pair<Buffer<Double>, Buffer<Double>> = getOrBuildRule(numPoints)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A generic Gauss-Legendre rule factory that wraps [DoubleGaussLegendreRuleFactory] in a generic way.
|
||||
*/
|
||||
public class GenericGaussLegendreRuleFactory<T : Any>(
|
||||
override val algebra: Field<T>,
|
||||
override val bufferFactory: BufferFactory<T>,
|
||||
) : GaussIntegratorRuleFactory<T> {
|
||||
|
||||
override fun build(numPoints: Int): Pair<Buffer<T>, Buffer<T>> {
|
||||
val (doublePoints, doubleWeights) = DoubleGaussLegendreRuleFactory.build(numPoints)
|
||||
|
||||
val points = doublePoints.map(bufferFactory) { algebra.number(it) }
|
||||
val weights = doubleWeights.map(bufferFactory) { algebra.number(it) }
|
||||
return points to weights
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,13 @@
|
||||
|
||||
package space.kscience.kmath.integration
|
||||
|
||||
import space.kscience.kmath.functions.UnivariateFunction
|
||||
import space.kscience.kmath.misc.UnstableKMathAPI
|
||||
import kotlin.jvm.JvmInline
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
public class UnivariateIntegrand<T : Any> internal constructor(
|
||||
private val features: Map<KClass<*>, IntegrandFeature>,
|
||||
public val function: UnivariateFunction<T>,
|
||||
public val function: (Double) -> T,
|
||||
) : Integrand {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@ -27,7 +26,7 @@ public class UnivariateIntegrand<T : Any> internal constructor(
|
||||
|
||||
@Suppress("FunctionName")
|
||||
public fun <T : Any> UnivariateIntegrand(
|
||||
function: (T) -> T,
|
||||
function: (Double) -> T,
|
||||
vararg features: IntegrandFeature,
|
||||
): UnivariateIntegrand<T> = UnivariateIntegrand(features.associateBy { it::class }, function)
|
||||
|
||||
|
@ -5,15 +5,18 @@
|
||||
|
||||
package space.kscience.kmath.integration
|
||||
|
||||
import space.kscience.kmath.misc.UnstableKMathAPI
|
||||
import space.kscience.kmath.operations.DoubleField
|
||||
import kotlin.math.PI
|
||||
import kotlin.math.sin
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@OptIn(UnstableKMathAPI::class)
|
||||
class GaussIntegralTest {
|
||||
@Test
|
||||
fun gaussSin() {
|
||||
val res = GaussIntegrator.legendre(0.0..2 * PI) { x ->
|
||||
val res = DoubleField.integrate(0.0..2 * PI) { x ->
|
||||
sin(x)
|
||||
}
|
||||
assertEquals(0.0, res.value!!, 1e-4)
|
||||
@ -21,7 +24,7 @@ class GaussIntegralTest {
|
||||
|
||||
@Test
|
||||
fun gaussUniform() {
|
||||
val res = GaussIntegrator.legendre(0.0..100.0,300) { x ->
|
||||
val res = DoubleField.integrate(0.0..100.0,300) { x ->
|
||||
if(x in 30.0..50.0){
|
||||
1.0
|
||||
} else {
|
||||
|
@ -9,7 +9,7 @@ ND4J based implementations of KMath abstractions.
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-nd4j:0.3.0-dev-4`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-nd4j:0.3.0-dev-6`.
|
||||
|
||||
**Gradle:**
|
||||
```gradle
|
||||
@ -20,7 +20,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'space.kscience:kmath-nd4j:0.3.0-dev-4'
|
||||
implementation 'space.kscience:kmath-nd4j:0.3.0-dev-6'
|
||||
}
|
||||
```
|
||||
**Gradle Kotlin DSL:**
|
||||
@ -32,7 +32,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-nd4j:0.3.0-dev-4")
|
||||
implementation("space.kscience:kmath-nd4j:0.3.0-dev-6")
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -13,84 +13,71 @@ public final class space/kscience/kmath/viktor/ViktorBuffer : space/kscience/kma
|
||||
public final class space/kscience/kmath/viktor/ViktorFieldND : space/kscience/kmath/nd/FieldND, space/kscience/kmath/operations/ExtendedField, space/kscience/kmath/operations/NumbersAddOperations, space/kscience/kmath/operations/ScaleOperations {
|
||||
public fun <init> ([I)V
|
||||
public synthetic fun acos (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
public fun acos-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun acos (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun add (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
|
||||
public synthetic fun add (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
|
||||
public fun add-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun add (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun asin (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
public fun asin-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun asin (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun atan (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
public fun atan-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun atan (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND;
|
||||
public fun combine-WKhNzhk (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun combine (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun cos (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
public fun cos-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun cos (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun exp (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
public fun exp-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun exp (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun getElementContext ()Lspace/kscience/kmath/operations/Algebra;
|
||||
public fun getElementContext ()Lspace/kscience/kmath/operations/DoubleField;
|
||||
public final fun getF64Buffer (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public synthetic fun getOne ()Ljava/lang/Object;
|
||||
public fun getOne-6kW2wQc ()Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun getOne ()Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public fun getShape ()[I
|
||||
public synthetic fun getZero ()Ljava/lang/Object;
|
||||
public fun getZero-6kW2wQc ()Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun getZero ()Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun ln (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
public fun ln-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun ln (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND;
|
||||
public fun map-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun map (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/nd/StructureND;
|
||||
public fun mapIndexed-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun mapIndexed (Lspace/kscience/kmath/nd/StructureND;Lkotlin/jvm/functions/Function3;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun minus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
|
||||
public fun minus-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun minus (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun number (Ljava/lang/Number;)Ljava/lang/Object;
|
||||
public fun number-8UOKELU (Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun number (Ljava/lang/Number;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun plus (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
|
||||
public fun plus (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun plus (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Object;)Lspace/kscience/kmath/nd/StructureND;
|
||||
public fun plus-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;D)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun plus-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun plus (Lspace/kscience/kmath/nd/StructureND;Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun power (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object;
|
||||
public fun power-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun power (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/nd/StructureND;
|
||||
public fun produce-8UOKELU (Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun produce (Lkotlin/jvm/functions/Function2;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun scale (Ljava/lang/Object;D)Ljava/lang/Object;
|
||||
public fun scale-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;D)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun scale (Lspace/kscience/kmath/nd/StructureND;D)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun sin (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
public fun sin-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun sin (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun tan (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
public fun tan-8UOKELU (Lspace/kscience/kmath/nd/StructureND;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun tan (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun times (Ljava/lang/Object;Ljava/lang/Number;)Ljava/lang/Object;
|
||||
public fun times-zrEAbyI (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun times (Lspace/kscience/kmath/nd/StructureND;Ljava/lang/Number;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public synthetic fun unaryMinus (Ljava/lang/Object;)Ljava/lang/Object;
|
||||
public fun unaryMinus (Lspace/kscience/kmath/nd/StructureND;)Lspace/kscience/kmath/nd/StructureND;
|
||||
}
|
||||
|
||||
public final class space/kscience/kmath/viktor/ViktorStructureND : space/kscience/kmath/nd/MutableStructureND {
|
||||
public static final synthetic fun box-impl (Lorg/jetbrains/bio/viktor/F64Array;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
public static fun constructor-impl (Lorg/jetbrains/bio/viktor/F64Array;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun <init> (Lorg/jetbrains/bio/viktor/F64Array;)V
|
||||
public fun elements ()Lkotlin/sequences/Sequence;
|
||||
public static fun elements-impl (Lorg/jetbrains/bio/viktor/F64Array;)Lkotlin/sequences/Sequence;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public static fun equals-impl (Lorg/jetbrains/bio/viktor/F64Array;Ljava/lang/Object;)Z
|
||||
public static final fun equals-impl0 (Lorg/jetbrains/bio/viktor/F64Array;Lorg/jetbrains/bio/viktor/F64Array;)Z
|
||||
public fun get ([I)Ljava/lang/Double;
|
||||
public synthetic fun get ([I)Ljava/lang/Object;
|
||||
public static fun get-impl (Lorg/jetbrains/bio/viktor/F64Array;[I)Ljava/lang/Double;
|
||||
public final fun getF64Buffer ()Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public fun getShape ()[I
|
||||
public static fun getShape-impl (Lorg/jetbrains/bio/viktor/F64Array;)[I
|
||||
public fun hashCode ()I
|
||||
public static fun hashCode-impl (Lorg/jetbrains/bio/viktor/F64Array;)I
|
||||
public fun set ([ID)V
|
||||
public synthetic fun set ([ILjava/lang/Object;)V
|
||||
public static fun set-impl (Lorg/jetbrains/bio/viktor/F64Array;[ID)V
|
||||
public fun toString ()Ljava/lang/String;
|
||||
public static fun toString-impl (Lorg/jetbrains/bio/viktor/F64Array;)Ljava/lang/String;
|
||||
public final synthetic fun unbox-impl ()Lorg/jetbrains/bio/viktor/F64Array;
|
||||
}
|
||||
|
||||
public final class space/kscience/kmath/viktor/ViktorStructureNDKt {
|
||||
public static final fun ViktorNDField ([I)Lspace/kscience/kmath/viktor/ViktorFieldND;
|
||||
public static final fun asStructure (Lorg/jetbrains/bio/viktor/F64Array;)Lorg/jetbrains/bio/viktor/F64Array;
|
||||
public static final fun asStructure (Lorg/jetbrains/bio/viktor/F64Array;)Lspace/kscience/kmath/viktor/ViktorStructureND;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import space.kscience.kmath.operations.NumbersAddOperations
|
||||
import space.kscience.kmath.operations.ScaleOperations
|
||||
|
||||
@Suppress("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE")
|
||||
public inline class ViktorStructureND(public val f64Buffer: F64Array) : MutableStructureND<Double> {
|
||||
public class ViktorStructureND(public val f64Buffer: F64Array) : MutableStructureND<Double> {
|
||||
public override val shape: IntArray get() = f64Buffer.shape
|
||||
|
||||
public override inline fun get(index: IntArray): Double = f64Buffer.get(*index)
|
||||
|
@ -44,5 +44,6 @@ include(
|
||||
":kmath-ast",
|
||||
":kmath-ejml",
|
||||
":kmath-kotlingrad",
|
||||
":examples"
|
||||
":examples",
|
||||
":benchmarks"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user