From 65e05605533a033fff621b83a447c7a78a07cd58 Mon Sep 17 00:00:00 2001 From: Iaroslav Postovalov Date: Sat, 29 May 2021 15:50:16 +0700 Subject: [PATCH] Fix Symja build issues --- build.gradle.kts | 5 ++++- kmath-symja/build.gradle.kts | 9 ++++++++- .../space/kscience/kmath/symja/SymjaExpression.kt | 15 +++++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4de6d8bad..1826a2e7e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,9 @@ allprojects { maven("http://logicrunch.research.it.uu.se/maven") { isAllowInsecureProtocol = true } - maven("https://oss.sonatype.org/content/repositories/snapshots") + maven("https://oss.sonatype.org/content/repositories/snapshots") { + + } mavenCentral() } @@ -31,6 +33,7 @@ subprojects { externalDocumentationLink("http://ejml.org/javadoc/") externalDocumentationLink("https://commons.apache.org/proper/commons-math/javadocs/api-3.6.1/") externalDocumentationLink("https://deeplearning4j.org/api/latest/") + externalDocumentationLink("https://axelclk.bitbucket.io/symja/javadoc/") externalDocumentationLink("https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/") } } diff --git a/kmath-symja/build.gradle.kts b/kmath-symja/build.gradle.kts index c06020bb6..c67b42e3f 100644 --- a/kmath-symja/build.gradle.kts +++ b/kmath-symja/build.gradle.kts @@ -11,7 +11,14 @@ plugins { description = "Symja integration module" dependencies { - api("org.matheclipse:matheclipse-core:2.0.0-SNAPSHOT") + api("org.matheclipse:matheclipse-core:2.0.0-SNAPSHOT") { + // Incorrect transitive dependency org.apfloat:apfloat:1.10.0-SNAPSHOT + exclude("org.apfloat", "apfloat") + } + + // Replace for org.apfloat:apfloat:1.10.0-SNAPSHOT + api("org.apfloat:apfloat:1.10.0") + api(project(":kmath-core")) testImplementation("org.slf4j:slf4j-simple:1.7.30") } diff --git a/kmath-symja/src/main/kotlin/space/kscience/kmath/symja/SymjaExpression.kt b/kmath-symja/src/main/kotlin/space/kscience/kmath/symja/SymjaExpression.kt index 301678916..a6773c709 100644 --- a/kmath-symja/src/main/kotlin/space/kscience/kmath/symja/SymjaExpression.kt +++ b/kmath-symja/src/main/kotlin/space/kscience/kmath/symja/SymjaExpression.kt @@ -7,17 +7,28 @@ package space.kscience.kmath.symja import org.matheclipse.core.eval.ExprEvaluator import org.matheclipse.core.expression.F -import space.kscience.kmath.expressions.DifferentiableExpression +import space.kscience.kmath.expressions.SpecialDifferentiableExpression import space.kscience.kmath.expressions.MST import space.kscience.kmath.expressions.Symbol import space.kscience.kmath.expressions.interpret import space.kscience.kmath.operations.NumericAlgebra +/** + * Represents [MST] based [DifferentiableExpression] relying on [Symja](https://github.com/axkr/symja_android_library). + * + * The principle of this API is converting the [mst] to an [org.matheclipse.core.interfaces.IExpr], differentiating it + * with Symja's [F.D], then converting [org.matheclipse.core.interfaces.IExpr] back to [MST]. + * + * @param T The type of number. + * @param A The [NumericAlgebra] of [T]. + * @property algebra The [A] instance. + * @property mst The [MST] node. + */ public class SymjaExpression>( public val algebra: A, public val mst: MST, public val evaluator: ExprEvaluator = DEFAULT_EVALUATOR, -) : DifferentiableExpression> { +) : SpecialDifferentiableExpression> { public override fun invoke(arguments: Map): T = mst.interpret(algebra, arguments) public override fun derivativeOrNull(symbols: List): SymjaExpression = SymjaExpression(