Fix up Symja build issues #356

Merged
CommanderTvis merged 8 commits from commandertvis/symja into dev 2021-05-29 12:07:57 +03:00
4 changed files with 28 additions and 6 deletions

View File

@ -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()
}
@ -27,11 +29,13 @@ subprojects {
dokkaSourceSets.all {
val readmeFile = File(this@subprojects.projectDir, "README.md")
if (readmeFile.exists()) includes.setFrom(includes + readmeFile.absolutePath)
if (readmeFile.exists()) includes.from(readmeFile.absolutePath)
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/")
externalDocumentationLink("https://breandan.net/kotlingrad/kotlingrad/", "https://breandan.net/kotlingrad/kotlingrad/kotlingrad/package-list")
}
}
}

View File

@ -9,5 +9,5 @@ kotlin.mpp.stability.nowarn=true
kotlin.native.enableDependencyPropagation=false
kotlin.parallel.tasks.in.project=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-XX:MaxMetaspaceSize=1G
org.gradle.jvmargs=-XX:MaxMetaspaceSize=2G
org.gradle.parallel=true

View File

@ -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")
}

View File

@ -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<T : Number, A : NumericAlgebra<T>>(
public val algebra: A,
public val mst: MST,
public val evaluator: ExprEvaluator = DEFAULT_EVALUATOR,
) : DifferentiableExpression<T, SymjaExpression<T, A>> {
) : SpecialDifferentiableExpression<T, SymjaExpression<T, A>> {
public override fun invoke(arguments: Map<Symbol, T>): T = mst.interpret(algebra, arguments)
public override fun derivativeOrNull(symbols: List<Symbol>): SymjaExpression<T, A> = SymjaExpression(