Feature/diff api #154
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -25,7 +25,7 @@ internal class AsmBuilder<T> internal constructor(
|
|||||||
private val classOfT: Class<*>,
|
private val classOfT: Class<*>,
|
||||||
private val algebra: Algebra<T>,
|
private val algebra: Algebra<T>,
|
||||||
private val className: String,
|
private val className: String,
|
||||||
private val invokeLabel0Visitor: AsmBuilder<T>.() -> Unit
|
private val invokeLabel0Visitor: AsmBuilder<T>.() -> Unit,
|
||||||
) {
|
) {
|
||||||
/**
|
/**
|
||||||
* Internal classloader of [AsmBuilder] with alias to define class from byte array.
|
* Internal classloader of [AsmBuilder] with alias to define class from byte array.
|
||||||
@ -379,22 +379,14 @@ internal class AsmBuilder<T> internal constructor(
|
|||||||
* Loads a variable [name] from arguments [Map] parameter of [Expression.invoke]. The [defaultValue] may be
|
* Loads a variable [name] from arguments [Map] parameter of [Expression.invoke]. The [defaultValue] may be
|
||||||
* provided.
|
* provided.
|
||||||
*/
|
*/
|
||||||
internal fun loadVariable(name: String, defaultValue: T? = null): Unit = invokeMethodVisitor.run {
|
internal fun loadVariable(name: String): Unit = invokeMethodVisitor.run {
|
||||||
load(invokeArgumentsVar, MAP_TYPE)
|
load(invokeArgumentsVar, MAP_TYPE)
|
||||||
aconst(name)
|
aconst(name)
|
||||||
|
|
||||||
if (defaultValue != null)
|
|
||||||
loadTConstant(defaultValue)
|
|
||||||
|
|
||||||
invokestatic(
|
invokestatic(
|
||||||
MAP_INTRINSICS_TYPE.internalName,
|
MAP_INTRINSICS_TYPE.internalName,
|
||||||
"getOrFail",
|
"getOrFail",
|
||||||
|
Type.getMethodDescriptor(OBJECT_TYPE, MAP_TYPE, STRING_TYPE),
|
||||||
Type.getMethodDescriptor(
|
|
||||||
OBJECT_TYPE,
|
|
||||||
MAP_TYPE,
|
|
||||||
OBJECT_TYPE,
|
|
||||||
*OBJECT_TYPE.wrapToArrayIf { defaultValue != null }),
|
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -429,7 +421,7 @@ internal class AsmBuilder<T> internal constructor(
|
|||||||
method: String,
|
method: String,
|
||||||
descriptor: String,
|
descriptor: String,
|
||||||
expectedArity: Int,
|
expectedArity: Int,
|
||||||
opcode: Int = INVOKEINTERFACE
|
opcode: Int = INVOKEINTERFACE,
|
||||||
) {
|
) {
|
||||||
run loop@{
|
run loop@{
|
||||||
repeat(expectedArity) {
|
repeat(expectedArity) {
|
||||||
|
@ -3,12 +3,11 @@
|
|||||||
package kscience.kmath.asm.internal
|
package kscience.kmath.asm.internal
|
||||||
|
|
||||||
import kscience.kmath.expressions.StringSymbol
|
import kscience.kmath.expressions.StringSymbol
|
||||||
|
import kscience.kmath.expressions.Symbol
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets value with given [key] or throws [IllegalStateException] whenever it is not present.
|
* Gets value with given [key] or throws [NoSuchElementException] whenever it is not present.
|
||||||
*
|
*
|
||||||
* @author Iaroslav Postovalov
|
* @author Iaroslav Postovalov
|
||||||
*/
|
*/
|
||||||
@JvmOverloads
|
internal fun <V> Map<Symbol, V>.getOrFail(key: String): V = getValue(StringSymbol(key))
|
||||||
internal fun <K, V> Map<K, V>.getOrFail(key: K, default: V? = null): V =
|
|
||||||
this[StringSymbol(key.toString())] ?: default ?: error("Parameter not found: $key")
|
|
||||||
|
@ -146,7 +146,9 @@ private class AutoDiffContext<T : Any, F : Field<T>>(
|
|||||||
override val identity: String,
|
override val identity: String,
|
||||||
value: T,
|
value: T,
|
||||||
var d: T,
|
var d: T,
|
||||||
) : AutoDiffValue<T>(value), Symbol
|
) : AutoDiffValue<T>(value), Symbol{
|
||||||
|
override fun toString(): String = identity
|
||||||
|
}
|
||||||
|
|
||||||
private val bindings: Map<String, AutoDiffVariableWithDeriv<T>> = bindings.entries.associate {
|
private val bindings: Map<String, AutoDiffVariableWithDeriv<T>> = bindings.entries.associate {
|
||||||
it.key.identity to AutoDiffVariableWithDeriv(it.key.identity, it.value, context.zero)
|
it.key.identity to AutoDiffVariableWithDeriv(it.key.identity, it.value, context.zero)
|
||||||
|
Loading…
Reference in New Issue
Block a user