Compare commits
1 Commits
beta/kotli
...
dev
Author | SHA1 | Date | |
---|---|---|---|
c475c43744 |
@ -19,14 +19,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
jvmToolchain(17)
|
|
||||||
|
|
||||||
compilerOptions {
|
|
||||||
optIn.addAll(
|
|
||||||
"space.kscience.kmath.UnstableKMathAPI"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
jvm()
|
jvm()
|
||||||
|
|
||||||
js(IR) {
|
js(IR) {
|
||||||
@ -66,7 +58,7 @@ kotlin {
|
|||||||
implementation(project(":kmath-nd4j"))
|
implementation(project(":kmath-nd4j"))
|
||||||
implementation(project(":kmath-kotlingrad"))
|
implementation(project(":kmath-kotlingrad"))
|
||||||
implementation(project(":kmath-viktor"))
|
implementation(project(":kmath-viktor"))
|
||||||
// implementation(project(":kmath-jafama"))
|
implementation(project(":kmath-jafama"))
|
||||||
implementation(projects.kmath.kmathTensorflow)
|
implementation(projects.kmath.kmathTensorflow)
|
||||||
implementation("org.tensorflow:tensorflow-core-platform:0.4.0")
|
implementation("org.tensorflow:tensorflow-core-platform:0.4.0")
|
||||||
implementation("org.nd4j:nd4j-native:1.0.0-M1")
|
implementation("org.nd4j:nd4j-native:1.0.0-M1")
|
||||||
@ -160,6 +152,15 @@ benchmark {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain(11)
|
||||||
|
compilerOptions {
|
||||||
|
optIn.addAll(
|
||||||
|
"space.kscience.kmath.UnstableKMathAPI"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private data class JmhReport(
|
private data class JmhReport(
|
||||||
val jmhVersion: String,
|
val jmhVersion: String,
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018-2024 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package space.kscience.kmath.benchmarks
|
||||||
|
|
||||||
|
import kotlinx.benchmark.Blackhole
|
||||||
|
import org.openjdk.jmh.annotations.Benchmark
|
||||||
|
import org.openjdk.jmh.annotations.Scope
|
||||||
|
import org.openjdk.jmh.annotations.State
|
||||||
|
import space.kscience.kmath.jafama.JafamaDoubleField
|
||||||
|
import space.kscience.kmath.jafama.StrictJafamaDoubleField
|
||||||
|
import space.kscience.kmath.operations.Float64Field
|
||||||
|
import space.kscience.kmath.operations.invoke
|
||||||
|
import kotlin.random.Random
|
||||||
|
|
||||||
|
@State(Scope.Benchmark)
|
||||||
|
internal class JafamaBenchmark {
|
||||||
|
@Benchmark
|
||||||
|
fun jafama(blackhole: Blackhole) = invokeBenchmarks(blackhole) { x ->
|
||||||
|
JafamaDoubleField { x * power(x, 4) * exp(x) / cos(x) + sin(x) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
fun core(blackhole: Blackhole) = invokeBenchmarks(blackhole) { x ->
|
||||||
|
Float64Field { x * power(x, 4) * exp(x) / cos(x) + sin(x) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Benchmark
|
||||||
|
fun strictJafama(blackhole: Blackhole) = invokeBenchmarks(blackhole) { x ->
|
||||||
|
StrictJafamaDoubleField { x * power(x, 4) * exp(x) / cos(x) + sin(x) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private inline fun invokeBenchmarks(blackhole: Blackhole, expr: (Double) -> Double) {
|
||||||
|
val rng = Random(0)
|
||||||
|
repeat(1000000) { blackhole.consume(expr(rng.nextDouble())) }
|
||||||
|
}
|
@ -19,12 +19,6 @@ allprojects {
|
|||||||
version = "0.4.1-dev"
|
version = "0.4.1-dev"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies{
|
|
||||||
subprojects.forEach {
|
|
||||||
dokka(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
if (name.startsWith("kmath")) apply<MavenPublishPlugin>()
|
if (name.startsWith("kmath")) apply<MavenPublishPlugin>()
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ dependencies {
|
|||||||
implementation(project(":kmath-tensors"))
|
implementation(project(":kmath-tensors"))
|
||||||
implementation(project(":kmath-symja"))
|
implementation(project(":kmath-symja"))
|
||||||
implementation(project(":kmath-for-real"))
|
implementation(project(":kmath-for-real"))
|
||||||
|
//jafama
|
||||||
|
implementation(project(":kmath-jafama"))
|
||||||
//multik
|
//multik
|
||||||
implementation(project(":kmath-multik"))
|
implementation(project(":kmath-multik"))
|
||||||
implementation(libs.multik.default)
|
implementation(libs.multik.default)
|
||||||
@ -52,7 +54,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
jvmToolchain(17)
|
jvmToolchain(11)
|
||||||
sourceSets.all {
|
sourceSets.all {
|
||||||
languageSettings {
|
languageSettings {
|
||||||
optIn("kotlin.contracts.ExperimentalContracts")
|
optIn("kotlin.contracts.ExperimentalContracts")
|
||||||
|
@ -9,6 +9,7 @@ import kotlinx.html.br
|
|||||||
import kotlinx.html.h3
|
import kotlinx.html.h3
|
||||||
import space.kscience.kmath.commons.optimization.CMOptimizer
|
import space.kscience.kmath.commons.optimization.CMOptimizer
|
||||||
import space.kscience.kmath.distributions.NormalDistribution
|
import space.kscience.kmath.distributions.NormalDistribution
|
||||||
|
import space.kscience.kmath.expressions.DifferentiableExpression
|
||||||
import space.kscience.kmath.expressions.autodiff
|
import space.kscience.kmath.expressions.autodiff
|
||||||
import space.kscience.kmath.expressions.symbol
|
import space.kscience.kmath.expressions.symbol
|
||||||
import space.kscience.kmath.operations.asIterable
|
import space.kscience.kmath.operations.asIterable
|
||||||
@ -19,6 +20,7 @@ import space.kscience.kmath.real.DoubleVector
|
|||||||
import space.kscience.kmath.real.map
|
import space.kscience.kmath.real.map
|
||||||
import space.kscience.kmath.real.step
|
import space.kscience.kmath.real.step
|
||||||
import space.kscience.kmath.stat.chiSquaredExpression
|
import space.kscience.kmath.stat.chiSquaredExpression
|
||||||
|
import space.kscience.kmath.structures.Float64
|
||||||
import space.kscience.plotly.*
|
import space.kscience.plotly.*
|
||||||
import space.kscience.plotly.models.ScatterMode
|
import space.kscience.plotly.models.ScatterMode
|
||||||
import space.kscience.plotly.models.TraceValues
|
import space.kscience.plotly.models.TraceValues
|
||||||
@ -64,7 +66,7 @@ suspend fun main() {
|
|||||||
val yErr = y.map { sqrt(it) }//RealVector.same(x.size, sigma)
|
val yErr = y.map { sqrt(it) }//RealVector.same(x.size, sigma)
|
||||||
|
|
||||||
// compute differentiable chi^2 sum for given model ax^2 + bx + c
|
// compute differentiable chi^2 sum for given model ax^2 + bx + c
|
||||||
val chi2 = Double.autodiff.chiSquaredExpression(x, y, yErr) { arg ->
|
val chi2: DifferentiableExpression<Float64> = Double.autodiff.chiSquaredExpression(x, y, yErr) { arg ->
|
||||||
//bind variables to autodiff context
|
//bind variables to autodiff context
|
||||||
val a = bindSymbol(a)
|
val a = bindSymbol(a)
|
||||||
val b = bindSymbol(b)
|
val b = bindSymbol(b)
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018-2024 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package space.kscience.kmath.jafama
|
||||||
|
|
||||||
|
import space.kscience.kmath.operations.invoke
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val a = 2.0
|
||||||
|
val b = StrictJafamaDoubleField { exp(a) }
|
||||||
|
println(JafamaDoubleField { b + a })
|
||||||
|
println(StrictJafamaDoubleField { ln(b) })
|
||||||
|
}
|
@ -2,15 +2,12 @@
|
|||||||
# Copyright 2018-2021 KMath contributors.
|
# 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.
|
# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
#
|
#
|
||||||
|
kotlin.code.style=official
|
||||||
|
kotlin.mpp.stability.nowarn=true
|
||||||
|
kotlin.native.ignoreDisabledTargets=true
|
||||||
org.gradle.configureondemand=true
|
org.gradle.configureondemand=true
|
||||||
org.gradle.jvmargs=-Xmx4096m
|
org.gradle.jvmargs=-Xmx4096m
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
org.gradle.workers.max=4
|
org.gradle.workers.max=4
|
||||||
|
|
||||||
kotlin.code.style=official
|
toolsVersion=0.15.4-kotlin-2.0.0
|
||||||
kotlin.mpp.stability.nowarn=true
|
|
||||||
kotlin.native.ignoreDisabledTargets=true
|
|
||||||
org.jetbrains.dokka.experimental.gradle.pluginMode=V2EnabledWithHelpers
|
|
||||||
kotlin.native.enableKlibsCrossCompilation=true
|
|
||||||
|
|
||||||
toolsVersion=0.16.0-kotlin-2.1.20-Beta1
|
|
@ -7,18 +7,14 @@ kscience {
|
|||||||
js{
|
js{
|
||||||
nodejs {
|
nodejs {
|
||||||
testTask {
|
testTask {
|
||||||
useMocha {
|
useMocha().timeout = "0"
|
||||||
timeout = "0"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
browser {
|
browser {
|
||||||
useCommonJs()
|
useCommonJs()
|
||||||
testTask {
|
testTask {
|
||||||
useMocha {
|
useMocha().timeout = "0"
|
||||||
timeout = "0"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,13 @@ package space.kscience.kmath.wasm.internal
|
|||||||
|
|
||||||
import space.kscience.kmath.UnstableKMathAPI
|
import space.kscience.kmath.UnstableKMathAPI
|
||||||
import space.kscience.kmath.ast.TypedMst
|
import space.kscience.kmath.ast.TypedMst
|
||||||
import space.kscience.kmath.expressions.*
|
import space.kscience.kmath.expressions.DoubleExpression
|
||||||
|
import space.kscience.kmath.expressions.Expression
|
||||||
|
import space.kscience.kmath.expressions.IntExpression
|
||||||
|
import space.kscience.kmath.expressions.Symbol
|
||||||
import space.kscience.kmath.internal.binaryen.*
|
import space.kscience.kmath.internal.binaryen.*
|
||||||
import space.kscience.kmath.internal.webassembly.Instance
|
import space.kscience.kmath.internal.webassembly.Instance
|
||||||
|
import space.kscience.kmath.named.SimpleSymbolIndexer
|
||||||
import space.kscience.kmath.operations.*
|
import space.kscience.kmath.operations.*
|
||||||
import space.kscience.kmath.structures.Float64
|
import space.kscience.kmath.structures.Float64
|
||||||
import space.kscience.kmath.internal.binaryen.Module as BinaryenModule
|
import space.kscience.kmath.internal.binaryen.Module as BinaryenModule
|
||||||
|
@ -11,6 +11,7 @@ import space.kscience.kmath.UnstableKMathAPI
|
|||||||
import space.kscience.kmath.ast.TypedMst
|
import space.kscience.kmath.ast.TypedMst
|
||||||
import space.kscience.kmath.ast.evaluateConstants
|
import space.kscience.kmath.ast.evaluateConstants
|
||||||
import space.kscience.kmath.expressions.*
|
import space.kscience.kmath.expressions.*
|
||||||
|
import space.kscience.kmath.named.SimpleSymbolIndexer
|
||||||
import space.kscience.kmath.operations.Float64Field
|
import space.kscience.kmath.operations.Float64Field
|
||||||
import space.kscience.kmath.operations.Int32Ring
|
import space.kscience.kmath.operations.Int32Ring
|
||||||
import space.kscience.kmath.structures.Float64
|
import space.kscience.kmath.structures.Float64
|
||||||
|
@ -12,6 +12,7 @@ import space.kscience.kmath.asm.internal.*
|
|||||||
import space.kscience.kmath.ast.TypedMst
|
import space.kscience.kmath.ast.TypedMst
|
||||||
import space.kscience.kmath.ast.evaluateConstants
|
import space.kscience.kmath.ast.evaluateConstants
|
||||||
import space.kscience.kmath.expressions.*
|
import space.kscience.kmath.expressions.*
|
||||||
|
import space.kscience.kmath.named.SimpleSymbolIndexer
|
||||||
import space.kscience.kmath.operations.Algebra
|
import space.kscience.kmath.operations.Algebra
|
||||||
import space.kscience.kmath.operations.Float64Field
|
import space.kscience.kmath.operations.Float64Field
|
||||||
import space.kscience.kmath.operations.Int32Ring
|
import space.kscience.kmath.operations.Int32Ring
|
||||||
|
@ -14,6 +14,8 @@ import org.objectweb.asm.commons.InstructionAdapter
|
|||||||
import space.kscience.kmath.UnstableKMathAPI
|
import space.kscience.kmath.UnstableKMathAPI
|
||||||
import space.kscience.kmath.ast.TypedMst
|
import space.kscience.kmath.ast.TypedMst
|
||||||
import space.kscience.kmath.expressions.*
|
import space.kscience.kmath.expressions.*
|
||||||
|
import space.kscience.kmath.named.SimpleSymbolIndexer
|
||||||
|
import space.kscience.kmath.named.SymbolIndexer
|
||||||
import space.kscience.kmath.operations.*
|
import space.kscience.kmath.operations.*
|
||||||
import space.kscience.kmath.structures.Float64
|
import space.kscience.kmath.structures.Float64
|
||||||
import java.lang.invoke.MethodHandles
|
import java.lang.invoke.MethodHandles
|
||||||
|
@ -18,9 +18,9 @@ import space.kscience.attributes.AttributesBuilder
|
|||||||
import space.kscience.attributes.SetAttribute
|
import space.kscience.attributes.SetAttribute
|
||||||
import space.kscience.kmath.UnstableKMathAPI
|
import space.kscience.kmath.UnstableKMathAPI
|
||||||
import space.kscience.kmath.expressions.Symbol
|
import space.kscience.kmath.expressions.Symbol
|
||||||
import space.kscience.kmath.expressions.SymbolIndexer
|
|
||||||
import space.kscience.kmath.expressions.derivative
|
import space.kscience.kmath.expressions.derivative
|
||||||
import space.kscience.kmath.expressions.withSymbols
|
import space.kscience.kmath.named.SymbolIndexer
|
||||||
|
import space.kscience.kmath.named.withSymbols
|
||||||
import space.kscience.kmath.optimization.*
|
import space.kscience.kmath.optimization.*
|
||||||
import space.kscience.kmath.structures.Float64
|
import space.kscience.kmath.structures.Float64
|
||||||
import kotlin.collections.set
|
import kotlin.collections.set
|
||||||
|
@ -23,7 +23,7 @@ public abstract class Domain1D<T : Comparable<T>>(public val range: ClosedRange<
|
|||||||
|
|
||||||
@UnstableKMathAPI
|
@UnstableKMathAPI
|
||||||
public class DoubleDomain1D(
|
public class DoubleDomain1D(
|
||||||
@Suppress("CanBeParameter") public val doubleRange: ClosedFloatingPointRange<Float64>,
|
public val doubleRange: ClosedFloatingPointRange<Float64>,
|
||||||
) : Domain1D<Float64>(doubleRange), Float64Domain {
|
) : Domain1D<Float64>(doubleRange), Float64Domain {
|
||||||
override fun getLowerBound(num: Int): Double {
|
override fun getLowerBound(num: Int): Double {
|
||||||
require(num == 0)
|
require(num == 0)
|
||||||
|
@ -7,6 +7,7 @@ package space.kscience.kmath.expressions
|
|||||||
|
|
||||||
import space.kscience.attributes.SafeType
|
import space.kscience.attributes.SafeType
|
||||||
import space.kscience.kmath.UnstableKMathAPI
|
import space.kscience.kmath.UnstableKMathAPI
|
||||||
|
import space.kscience.kmath.named.SymbolIndexer
|
||||||
import space.kscience.kmath.operations.*
|
import space.kscience.kmath.operations.*
|
||||||
import space.kscience.kmath.structures.Buffer
|
import space.kscience.kmath.structures.Buffer
|
||||||
import space.kscience.kmath.structures.MutableBuffer
|
import space.kscience.kmath.structures.MutableBuffer
|
||||||
|
@ -126,7 +126,7 @@ public class DSCompiler<T, out A : Algebra<T>> internal constructor(
|
|||||||
* If all orders are set to 0, then the 0<sup>th</sup> order derivative is returned, which is the value of the
|
* If all orders are set to 0, then the 0<sup>th</sup> order derivative is returned, which is the value of the
|
||||||
* function.
|
* function.
|
||||||
*
|
*
|
||||||
* The indices of derivatives are between 0 and [size] − 1. Their specific order is fixed for a given compiler, but
|
* The indices of derivatives are between 0 and [getSize] − 1. Their specific order is fixed for a given compiler, but
|
||||||
* otherwise not publicly specified. There are however some simple cases which have guaranteed indices:
|
* otherwise not publicly specified. There are however some simple cases which have guaranteed indices:
|
||||||
*
|
*
|
||||||
* * the index of 0<sup>th</sup> order derivative is always 0
|
* * the index of 0<sup>th</sup> order derivative is always 0
|
||||||
|
@ -9,6 +9,7 @@ import space.kscience.attributes.SafeType
|
|||||||
import space.kscience.attributes.WithType
|
import space.kscience.attributes.WithType
|
||||||
import space.kscience.attributes.safeTypeOf
|
import space.kscience.attributes.safeTypeOf
|
||||||
import space.kscience.kmath.UnstableKMathAPI
|
import space.kscience.kmath.UnstableKMathAPI
|
||||||
|
import space.kscience.kmath.named.SymbolIndexer
|
||||||
import space.kscience.kmath.operations.Algebra
|
import space.kscience.kmath.operations.Algebra
|
||||||
import space.kscience.kmath.operations.DoubleField
|
import space.kscience.kmath.operations.DoubleField
|
||||||
import space.kscience.kmath.operations.IntRing
|
import space.kscience.kmath.operations.IntRing
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018-2024 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@file:OptIn(UnstableKMathAPI::class)
|
||||||
|
|
||||||
|
package space.kscience.kmath.named
|
||||||
|
|
||||||
|
import space.kscience.kmath.UnstableKMathAPI
|
||||||
|
import space.kscience.kmath.expressions.Symbol
|
||||||
|
import space.kscience.kmath.structures.Buffer
|
||||||
|
import space.kscience.kmath.structures.MutableBuffer
|
||||||
|
|
||||||
|
public class NamedBuffer<T>(public val values: Buffer<T>, public val indexer: SymbolIndexer): Buffer<T> by values{
|
||||||
|
public operator fun get(symbol: Symbol): T = values[indexer.indexOf(symbol)]
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NamedMutableBuffer<T>(public val values: MutableBuffer<T>, public val indexer: SymbolIndexer): MutableBuffer<T> by values{
|
||||||
|
public operator fun get(symbol: Symbol): T = values[indexer.indexOf(symbol)]
|
||||||
|
public operator fun set(symbol: Symbol, value: T) { values[indexer.indexOf(symbol)] = value }
|
||||||
|
}
|
@ -5,14 +5,24 @@
|
|||||||
|
|
||||||
@file:OptIn(UnstableKMathAPI::class)
|
@file:OptIn(UnstableKMathAPI::class)
|
||||||
|
|
||||||
package space.kscience.kmath.expressions
|
package space.kscience.kmath.named
|
||||||
|
|
||||||
import space.kscience.kmath.PerformancePitfall
|
import space.kscience.kmath.PerformancePitfall
|
||||||
import space.kscience.kmath.UnstableKMathAPI
|
import space.kscience.kmath.UnstableKMathAPI
|
||||||
|
import space.kscience.kmath.expressions.Symbol
|
||||||
import space.kscience.kmath.linear.Matrix
|
import space.kscience.kmath.linear.Matrix
|
||||||
import space.kscience.kmath.structures.getOrNull
|
import space.kscience.kmath.structures.getOrNull
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A square matrix that could be accessed via column and row names.
|
||||||
|
*
|
||||||
|
* Multiple symbols could in theory reference the same columns or rows. Some columns could be not references at all.
|
||||||
|
*/
|
||||||
public class NamedMatrix<T>(public val values: Matrix<T>, public val indexer: SymbolIndexer) : Matrix<T> by values {
|
public class NamedMatrix<T>(public val values: Matrix<T>, public val indexer: SymbolIndexer) : Matrix<T> by values {
|
||||||
|
init {
|
||||||
|
require(values.rows.size == values.columns.size) { "Only square matrices could be named" }
|
||||||
|
}
|
||||||
|
|
||||||
public operator fun get(i: Symbol, j: Symbol): T = get(indexer.indexOf(i), indexer.indexOf(j))
|
public operator fun get(i: Symbol, j: Symbol): T = get(indexer.indexOf(i), indexer.indexOf(j))
|
||||||
|
|
||||||
public companion object {
|
public companion object {
|
@ -3,9 +3,10 @@
|
|||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package space.kscience.kmath.expressions
|
package space.kscience.kmath.named
|
||||||
|
|
||||||
import space.kscience.kmath.UnstableKMathAPI
|
import space.kscience.kmath.UnstableKMathAPI
|
||||||
|
import space.kscience.kmath.expressions.Symbol
|
||||||
import space.kscience.kmath.linear.Point
|
import space.kscience.kmath.linear.Point
|
||||||
import space.kscience.kmath.nd.Structure2D
|
import space.kscience.kmath.nd.Structure2D
|
||||||
import space.kscience.kmath.structures.BufferFactory
|
import space.kscience.kmath.structures.BufferFactory
|
||||||
@ -69,6 +70,9 @@ public interface SymbolIndexer {
|
|||||||
public fun Map<Symbol, Double>.toDoubleArray(): DoubleArray = DoubleArray(symbols.size) { getValue(symbols[it]) }
|
public fun Map<Symbol, Double>.toDoubleArray(): DoubleArray = DoubleArray(symbols.size) { getValue(symbols[it]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UnstableKMathAPI
|
||||||
|
public val SymbolIndexer.size: Int get() = symbols.size
|
||||||
|
|
||||||
@UnstableKMathAPI
|
@UnstableKMathAPI
|
||||||
@JvmInline
|
@JvmInline
|
||||||
public value class SimpleSymbolIndexer(override val symbols: List<Symbol>) : SymbolIndexer
|
public value class SimpleSymbolIndexer(override val symbols: List<Symbol>) : SymbolIndexer
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("space.kscience.gradle.mpp")
|
id("space.kscience.gradle.jvm")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin.sourceSets
|
kotlin.sourceSets
|
||||||
@ -9,18 +9,11 @@ kotlin.sourceSets
|
|||||||
|
|
||||||
description = "Kotlin∇ integration module"
|
description = "Kotlin∇ integration module"
|
||||||
|
|
||||||
kscience{
|
dependencies {
|
||||||
jvm()
|
|
||||||
|
|
||||||
jvmMain{
|
|
||||||
api("ai.hypergraph:kaliningraph:0.1.9")
|
api("ai.hypergraph:kaliningraph:0.1.9")
|
||||||
api("ai.hypergraph:kotlingrad:0.4.7")
|
api("ai.hypergraph:kotlingrad:0.4.7")
|
||||||
api(project(":kmath-core"))
|
api(project(":kmath-core"))
|
||||||
}
|
testImplementation(project(":kmath-ast"))
|
||||||
|
|
||||||
jvmTest{
|
|
||||||
implementation(project(":kmath-ast"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readme {
|
readme {
|
||||||
|
@ -11,10 +11,6 @@ kscience {
|
|||||||
dependencies {
|
dependencies {
|
||||||
api(projects.kmathCore)
|
api(projects.kmathCore)
|
||||||
}
|
}
|
||||||
|
|
||||||
wasmJsMain{
|
|
||||||
api(spclibs.kotlinx.browser)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readme {
|
readme {
|
||||||
|
@ -1,21 +1,14 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("space.kscience.gradle.mpp")
|
id("space.kscience.gradle.jvm")
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "ND4J NDStructure implementation and according NDAlgebra classes"
|
description = "ND4J NDStructure implementation and according NDAlgebra classes"
|
||||||
|
|
||||||
|
dependencies {
|
||||||
kscience {
|
|
||||||
jvm()
|
|
||||||
|
|
||||||
jvmMain {
|
|
||||||
api(project(":kmath-tensors"))
|
api(project(":kmath-tensors"))
|
||||||
api("org.nd4j:nd4j-api:1.0.0-M2.1")
|
api("org.nd4j:nd4j-api:1.0.0-M1")
|
||||||
}
|
testImplementation("org.nd4j:nd4j-native-platform:1.0.0-M1")
|
||||||
|
testImplementation("org.slf4j:slf4j-simple:1.7.32")
|
||||||
jvmTest{
|
|
||||||
implementation("org.nd4j:nd4j-native-platform:1.0.0-M1")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readme {
|
readme {
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
package space.kscience.kmath.optimization
|
package space.kscience.kmath.optimization
|
||||||
|
|
||||||
import space.kscience.attributes.*
|
import space.kscience.attributes.*
|
||||||
import space.kscience.kmath.expressions.NamedMatrix
|
|
||||||
import space.kscience.kmath.expressions.Symbol
|
import space.kscience.kmath.expressions.Symbol
|
||||||
import space.kscience.kmath.misc.Loggable
|
import space.kscience.kmath.misc.Loggable
|
||||||
|
import space.kscience.kmath.named.NamedMatrix
|
||||||
|
|
||||||
public interface OptimizationAttribute<T> : Attribute<T>
|
public interface OptimizationAttribute<T> : Attribute<T>
|
||||||
|
|
||||||
|
@ -6,9 +6,15 @@
|
|||||||
package space.kscience.kmath.optimization
|
package space.kscience.kmath.optimization
|
||||||
|
|
||||||
import space.kscience.kmath.UnstableKMathAPI
|
import space.kscience.kmath.UnstableKMathAPI
|
||||||
import space.kscience.kmath.expressions.*
|
import space.kscience.kmath.expressions.DifferentiableExpression
|
||||||
|
import space.kscience.kmath.expressions.Symbol
|
||||||
|
import space.kscience.kmath.expressions.derivative
|
||||||
|
import space.kscience.kmath.expressions.withDefaultArgs
|
||||||
import space.kscience.kmath.linear.*
|
import space.kscience.kmath.linear.*
|
||||||
import space.kscience.kmath.misc.log
|
import space.kscience.kmath.misc.log
|
||||||
|
import space.kscience.kmath.named.NamedMatrix
|
||||||
|
import space.kscience.kmath.named.SymbolIndexer
|
||||||
|
import space.kscience.kmath.named.named
|
||||||
import space.kscience.kmath.operations.Float64Field
|
import space.kscience.kmath.operations.Float64Field
|
||||||
import space.kscience.kmath.operations.Float64L2Norm
|
import space.kscience.kmath.operations.Float64L2Norm
|
||||||
import space.kscience.kmath.operations.algebra
|
import space.kscience.kmath.operations.algebra
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018-2024 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package space.kscience.kmath.distributions
|
||||||
|
|
||||||
|
public interface MultivariateNormalDistribution: NamedDistribution<Double> {
|
||||||
|
public companion object{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -6,9 +6,7 @@
|
|||||||
package space.kscience.kmath.stat
|
package space.kscience.kmath.stat
|
||||||
|
|
||||||
import space.kscience.kmath.operations.*
|
import space.kscience.kmath.operations.*
|
||||||
import space.kscience.kmath.structures.Buffer
|
import space.kscience.kmath.structures.*
|
||||||
import space.kscience.kmath.structures.Float64
|
|
||||||
import space.kscience.kmath.structures.indices
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arithmetic mean
|
* Arithmetic mean
|
||||||
@ -44,8 +42,8 @@ public class Mean<T>(
|
|||||||
|
|
||||||
public companion object {
|
public companion object {
|
||||||
public fun evaluate(buffer: Buffer<Float64>): Double = Float64Field.mean.evaluateBlocking(buffer)
|
public fun evaluate(buffer: Buffer<Float64>): Double = Float64Field.mean.evaluateBlocking(buffer)
|
||||||
public fun evaluate(buffer: Buffer<Int>): Int = Int32Ring.mean.evaluateBlocking(buffer)
|
public fun evaluate(buffer: Buffer<Int32>): Int = Int32Ring.mean.evaluateBlocking(buffer)
|
||||||
public fun evaluate(buffer: Buffer<Long>): Long = Int64Ring.mean.evaluateBlocking(buffer)
|
public fun evaluate(buffer: Buffer<Int64>): Long = Int64Ring.mean.evaluateBlocking(buffer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,8 @@ public class RandomSourceGenerator internal constructor(
|
|||||||
public val source: RandomSource,
|
public val source: RandomSource,
|
||||||
seed: Long?,
|
seed: Long?,
|
||||||
) : RandomGenerator {
|
) : RandomGenerator {
|
||||||
internal val random: UniformRandomProvider = seed?.let { source.create(seed) } ?: source.create()
|
internal val random: UniformRandomProvider = seed?.let { source.create(seed) }
|
||||||
|
?: RandomSource.create(source)
|
||||||
|
|
||||||
override fun nextBoolean(): Boolean = random.nextBoolean()
|
override fun nextBoolean(): Boolean = random.nextBoolean()
|
||||||
override fun nextDouble(): Double = random.nextDouble()
|
override fun nextDouble(): Double = random.nextDouble()
|
||||||
|
@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.first
|
|||||||
import kotlinx.coroutines.flow.last
|
import kotlinx.coroutines.flow.last
|
||||||
import kotlinx.coroutines.flow.take
|
import kotlinx.coroutines.flow.take
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
import space.kscience.kmath.operations.Float64Field
|
import space.kscience.kmath.operations.Float64Field
|
||||||
import space.kscience.kmath.random.RandomGenerator
|
import space.kscience.kmath.random.RandomGenerator
|
||||||
import space.kscience.kmath.random.chain
|
import space.kscience.kmath.random.chain
|
||||||
@ -27,21 +28,21 @@ internal class StatisticTest {
|
|||||||
val chunked = data.chunked(1000)
|
val chunked = data.chunked(1000)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun singleBlockingMean() {
|
fun singleBlockingMean() = runTest {
|
||||||
|
val first = chunked.first()
|
||||||
|
val res = Float64Field.mean(first)
|
||||||
|
assertEquals(0.5, res, 1e-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun singleSuspendMean() = runTest {
|
||||||
val first = runBlocking { chunked.first() }
|
val first = runBlocking { chunked.first() }
|
||||||
val res = Float64Field.mean(first)
|
val res = Float64Field.mean(first)
|
||||||
assertEquals(0.5, res, 1e-1)
|
assertEquals(0.5, res, 1e-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun singleSuspendMean() = runBlocking {
|
fun parallelMean() = runTest {
|
||||||
val first = runBlocking { chunked.first() }
|
|
||||||
val res = Float64Field.mean(first)
|
|
||||||
assertEquals(0.5, res, 1e-1)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun parallelMean() = runBlocking {
|
|
||||||
val average = Float64Field.mean
|
val average = Float64Field.mean
|
||||||
.flow(chunked) //create a flow from evaluated results
|
.flow(chunked) //create a flow from evaluated results
|
||||||
.take(100) // Take 100 data chunks from the source and accumulate them
|
.take(100) // Take 100 data chunks from the source and accumulate them
|
||||||
|
@ -4,24 +4,38 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("space.kscience.gradle.mpp")
|
id("space.kscience.gradle.jvm")
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "Symja integration module"
|
description = "Symja integration module"
|
||||||
|
|
||||||
kscience{
|
dependencies {
|
||||||
jvm()
|
api("org.matheclipse:matheclipse-core:2.0.0") {
|
||||||
|
// Incorrect transitive dependencies
|
||||||
jvmMain {
|
exclude("org.apfloat", "apfloat")
|
||||||
api("org.matheclipse:matheclipse-core:3.0.0")
|
exclude("org.hipparchus", "hipparchus-clustering")
|
||||||
|
exclude("org.hipparchus", "hipparchus-core")
|
||||||
api(project(":kmath-core"))
|
exclude("org.hipparchus", "hipparchus-fft")
|
||||||
|
exclude("org.hipparchus", "hipparchus-fitting")
|
||||||
|
exclude("org.hipparchus", "hipparchus-ode")
|
||||||
|
exclude("org.hipparchus", "hipparchus-optim")
|
||||||
|
exclude("org.hipparchus", "hipparchus-stat")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replaces for incorrect transitive dependencies
|
||||||
|
api("org.apfloat:apfloat:1.10.0")
|
||||||
|
api("org.hipparchus:hipparchus-clustering:1.8")
|
||||||
|
api("org.hipparchus:hipparchus-core:1.8")
|
||||||
|
api("org.hipparchus:hipparchus-fft:1.8")
|
||||||
|
api("org.hipparchus:hipparchus-fitting:1.8")
|
||||||
|
api("org.hipparchus:hipparchus-ode:1.8")
|
||||||
|
api("org.hipparchus:hipparchus-optim:1.8")
|
||||||
|
api("org.hipparchus:hipparchus-stat:1.8")
|
||||||
|
|
||||||
|
api(project(":kmath-core"))
|
||||||
|
testImplementation("org.slf4j:slf4j-simple:1.7.31")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
readme {
|
readme {
|
||||||
maturity = space.kscience.gradle.Maturity.PROTOTYPE
|
maturity = space.kscience.gradle.Maturity.PROTOTYPE
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,7 @@ kscience {
|
|||||||
js {
|
js {
|
||||||
browser {
|
browser {
|
||||||
testTask {
|
testTask {
|
||||||
useMocha {
|
useMocha().timeout = "0"
|
||||||
timeout = "0"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("space.kscience.gradle.mpp")
|
id("space.kscience.gradle.jvm")
|
||||||
}
|
}
|
||||||
|
|
||||||
description = "Binding for https://github.com/JetBrains-Research/viktor"
|
description = "Binding for https://github.com/JetBrains-Research/viktor"
|
||||||
|
|
||||||
kscience{
|
dependencies {
|
||||||
jvm()
|
|
||||||
jvmMain{
|
|
||||||
api(project(":kmath-core"))
|
api(project(":kmath-core"))
|
||||||
api("org.jetbrains.bio:viktor:1.2.0")
|
api("org.jetbrains.bio:viktor:1.2.0")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
readme {
|
readme {
|
||||||
|
@ -61,6 +61,7 @@ include(
|
|||||||
":kmath-tensors",
|
":kmath-tensors",
|
||||||
":kmath-jupyter",
|
":kmath-jupyter",
|
||||||
":kmath-symja",
|
":kmath-symja",
|
||||||
|
":kmath-jafama",
|
||||||
":examples",
|
":examples",
|
||||||
":benchmarks",
|
":benchmarks",
|
||||||
)
|
)
|
||||||
|
@ -14,7 +14,6 @@ kotlin.sourceSets {
|
|||||||
dependencies {
|
dependencies {
|
||||||
api(projects.kmath.kmathCore)
|
api(projects.kmath.kmathCore)
|
||||||
api(kotlin("test"))
|
api(kotlin("test"))
|
||||||
api(spclibs.logback.classic)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user