Feature/diff api #154
No reviewers
Labels
No Label
bug
dependencies
discussion
documentation
duplicate
feature
good first issue
misc
performance
question
test
use case
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: kscience/kmath#154
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "feature/diff-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Experimental API for symbols and automatic differentiation
@ -0,0 +10,4 @@
public fun <T> DifferentiableExpression<T>.derivative(orders: Map<Symbol, Int>): Expression<T> =
derivativeOrNull(orders) ?: error("Derivative with orders $orders not provided")
public fun <T> DifferentiableExpression<T>.derivative(vararg orders: Pair<Symbol, Int>): Expression<T> =
Overload with
vararg symbols: Symbol
for order 1 can be added, too.@ -12,30 +31,69 @@ public fun interface Expression<T> {
* @param arguments the map of arguments.
Why is it commented?
By the way, it is SAM-interface
Operator form can be used:
left(arguments)
@ -0,0 +12,4 @@
*/
public open class AutoDiffValue<out T>(public val value: T)
I am sure that it may be replaced with sealed class to prevent one to extend AutoDiffValue with irrelevant object.
Removed
@ -0,0 +10,4 @@
public fun <T> DifferentiableExpression<T>.derivative(orders: Map<Symbol, Int>): Expression<T> =
derivativeOrNull(orders) ?: error("Derivative with orders $orders not provided")
public fun <T> DifferentiableExpression<T>.derivative(vararg orders: Pair<Symbol, Int>): Expression<T> =
No sense in that. People will use first, maximum second derivatives. There is an extension for the first. The second one could be added any moment.
@ -0,0 +12,4 @@
*/
public open class AutoDiffValue<out T>(public val value: T)
The idea is that it could be extended anytime. Here
AutoDiffValue
is just a marker interface. It is possible to even replace it with an inline class, but we need performance measurements to make that change.Implementation detail and it looks more readable that way.
@ -0,0 +35,4 @@
* A factory that converts an expression in autodiff variables to a [DifferentiableExpression]
*/
public interface AutoDiffProcessor<T : Any, I : Any, A : ExpressionAlgebra<T, I>> {
public fun process(function: A.() -> I): DifferentiableExpression<T>
SAM
@ -0,0 +35,4 @@
* A factory that converts an expression in autodiff variables to a [DifferentiableExpression]
*/
public interface AutoDiffProcessor<T : Any, I : Any, A : ExpressionAlgebra<T, I>> {
public fun process(function: A.() -> I): DifferentiableExpression<T>
I see no reason for that. This interface is mostly implemented by companion objects. Also I plan to add additional methods later.