Package space.kscience.kmath.expressions

Types

Link copied to clipboard
fun interface AutoDiffProcessor<T, I, out A : Algebra<I>>

A factory that converts an expression in autodiff variables to a DifferentiableExpression

Link copied to clipboard
open class AutoDiffValue<out T>(value: T)
Link copied to clipboard
class DerivationResult<T : Any>(value: T, derivativeValues: Map<String, T>, context: Field<T>)

Represents result of simpleAutoDiff call.

Link copied to clipboard
interface DifferentiableExpression<T> : Expression<T>

Represents expression, which structure can be differentiated.

Link copied to clipboard
interface DoubleExpression : Expression<Double>

Specialization of Expression for Double allowing better performance because of using array.

Link copied to clipboard
fun interface Expression<T>

An elementary function that could be invoked on a map of arguments.

Link copied to clipboard
interface ExpressionAlgebra<in T, E> : Algebra<E>

A context for expression construction

Link copied to clipboard
abstract class FirstDerivativeExpression<T> : DifferentiableExpression<T>

A DifferentiableExpression that defines only first derivatives

Link copied to clipboard
abstract class FunctionalExpressionAlgebra<T, out A : Algebra<T>>(algebra: A) : ExpressionAlgebra<T, Expression<T>>

A context class for Expression construction.

Link copied to clipboard
open class FunctionalExpressionExtendedField<T, out A : ExtendedField<T>>(algebra: A) : FunctionalExpressionField<T, A> , ExtendedField<Expression<T>>
Link copied to clipboard
open class FunctionalExpressionField<T, out A : Field<T>>(algebra: A) : FunctionalExpressionRing<T, A> , Field<Expression<T>> , ScaleOperations<Expression<T>>
Link copied to clipboard
open class FunctionalExpressionGroup<T, out A : Group<T>>(algebra: A) : FunctionalExpressionAlgebra<T, A> , Group<Expression<T>>

A context class for Expression construction for Ring algebras.

Link copied to clipboard
open class FunctionalExpressionRing<T, out A : Ring<T>>(algebra: A) : FunctionalExpressionGroup<T, A> , Ring<Expression<T>>
Link copied to clipboard
interface IntExpression : Expression<Int>

Specialization of Expression for Int allowing better performance because of using array.

Link copied to clipboard
interface LongExpression : Expression<Long>

Specialization of Expression for Long allowing better performance because of using array.

Link copied to clipboard
interface MST

A Mathematical Syntax Tree (MST) node for mathematical expressions.

Link copied to clipboard
object MstExtendedField : ExtendedField<MST> , NumericAlgebra<MST>

ExtendedField over MST nodes.

Link copied to clipboard
object MstField : Field<MST> , NumbersAddOps<MST> , ScaleOperations<MST>

Field over MST nodes.

Link copied to clipboard
object MstGroup : Group<MST> , NumericAlgebra<MST> , ScaleOperations<MST>

Group over MST nodes.

Link copied to clipboard
object MstLogicAlgebra : LogicAlgebra<MST>

Logic algebra for MST

Link copied to clipboard
object MstNumericAlgebra : NumericAlgebra<MST>

Algebra over MST nodes.

Link copied to clipboard
object MstRing : Ring<MST> , NumbersAddOps<MST> , ScaleOperations<MST>

Ring over MST nodes.

Link copied to clipboard
class SimpleAutoDiffExpression<T : Any, F : Field<T>>(field: F, function: SimpleAutoDiffField<T, F>.() -> AutoDiffValue<T>) : FirstDerivativeExpression<T>

A constructs that creates a derivative structure with required order on-demand

Link copied to clipboard
class SimpleAutoDiffExtendedField<T : Any, F : ExtendedField<T>>(context: F, bindings: Map<Symbol, T>) : SimpleAutoDiffField<T, F> , ExtendedField<AutoDiffValue<T>> , ScaleOperations<AutoDiffValue<T>>
Link copied to clipboard
open class SimpleAutoDiffField<T : Any, F : Field<T>>(context: F, bindings: Map<Symbol, T>) : Field<AutoDiffValue<T>> , ExpressionAlgebra<T, AutoDiffValue<T>> , NumbersAddOps<AutoDiffValue<T>>

Represents field in context of which functions can be derived.

Link copied to clipboard
value class SimpleSymbolIndexer(symbols: List<Symbol>) : SymbolIndexer
Link copied to clipboard
interface SpecialDifferentiableExpression<T, out R : Expression<T>> : DifferentiableExpression<T>

A special type of DifferentiableExpression which returns typed expressions as derivatives.

Link copied to clipboard
interface Symbol : MST

A marker interface for a symbol. A symbol must have an identity with equality relation based on it. Other properties are to store additional, transient data only.

Link copied to clipboard
interface SymbolIndexer

An environment to easy transform indexed variables to symbols and back. TODO requires multi-receivers to be beautiful

Functions

Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.acos(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.acosh(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.asin(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.asinh(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.atan(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.atanh(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
@JvmName(name = "genericChiSquaredExpression")
fun <T : Comparable<T>, I : Any, A : ExtendedField<I>, ExpressionAlgebra<T, I>> AutoDiffProcessor<T, I, A>.chiSquaredExpression(x: Buffer<T>, y: Buffer<T>, yErr: Buffer<T>, model: A.(I) -> I): DifferentiableExpression<T>

Generate a chi squared expression from given x-y-sigma data and inline model. Provides automatic differentiation.

Link copied to clipboard
inline fun <T : Any, F : Field<T>> SimpleAutoDiffField<T, F>.const(block: F.() -> T): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.cos(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.cosh(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T> DifferentiableExpression<T>.derivative(vararg symbols: Symbol): Expression<T>
fun <T> DifferentiableExpression<T>.derivative(name: String): Expression<T>
fun <T> DifferentiableExpression<T>.derivative(symbols: List<Symbol>): Expression<T>
fun <T, R : Expression<T>> SpecialDifferentiableExpression<T, R>.derivative(vararg symbols: Symbol): R
fun <T, R : Expression<T>> SpecialDifferentiableExpression<T, R>.derivative(name: String): R
fun <T, R : Expression<T>> SpecialDifferentiableExpression<T, R>.derivative(symbols: List<Symbol>): R
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.exp(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
Link copied to clipboard
inline fun <T, A : ExtendedField<T>> A.expressionInExtendedField(block: FunctionalExpressionExtendedField<T, A>.() -> Expression<T>): Expression<T>
Link copied to clipboard
inline fun <T, A : Field<T>> A.expressionInField(block: FunctionalExpressionField<T, A>.() -> Expression<T>): Expression<T>
Link copied to clipboard
inline fun <T, A : Group<T>> A.expressionInGroup(block: FunctionalExpressionGroup<T, A>.() -> Expression<T>): Expression<T>
Link copied to clipboard
inline fun <T, A : Ring<T>> A.expressionInRing(block: FunctionalExpressionRing<T, A>.() -> Expression<T>): Expression<T>
Link copied to clipboard
operator fun <T> Map<String, T>.get(symbol: Symbol): T?

Ger a value from a String-keyed map by a Symbol

operator fun <T> Map<Symbol, T>.get(string: String): T?

Get a value from a Symbol-keyed map by a String

Link copied to clipboard
fun <T : Any> DerivationResult<T>.grad(vararg variables: Symbol): Point<T>

Computes the gradient for variables in given order.

Link copied to clipboard
fun <T> MST.interpret(algebra: Algebra<T>, vararg arguments: Pair<Symbol, T>): T
fun <T> MST.interpret(algebra: Algebra<T>, arguments: Map<Symbol, T>): T

Interprets the MST node with this Algebra and optional arguments

Link copied to clipboard
operator fun DoubleExpression.invoke(): Double
operator fun <T> Expression<T>.invoke(): T
operator fun IntExpression.invoke(): Int
operator fun LongExpression.invoke(): Long

Calls this expression without providing any arguments.

operator fun DoubleExpression.invoke(vararg arguments: Double): Double
@JvmName(name = "callByString")
operator fun <T> Expression<T>.invoke(vararg pairs: Pair<String, T>): T
@JvmName(name = "callBySymbol")
operator fun <T> Expression<T>.invoke(vararg pairs: Pair<Symbol, T>): T
operator fun IntExpression.invoke(vararg arguments: Int): Int
operator fun LongExpression.invoke(vararg arguments: Long): Long

Calls this expression from arguments.

Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.ln(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.pow(x: AutoDiffValue<T>, y: Double): AutoDiffValue<T>
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.pow(x: AutoDiffValue<T>, y: Int): AutoDiffValue<T>
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.pow(x: AutoDiffValue<T>, y: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
operator fun <T> MutableMap<String, T>.set(symbol: Symbol, value: T)
operator fun <T> MutableMap<Symbol, T>.set(string: String, value: T)

Set a value of String-keyed map by a Symbol

Link copied to clipboard
fun <T : Any, F : Field<T>> simpleAutoDiff(field: F): AutoDiffProcessor<T, AutoDiffValue<T>, SimpleAutoDiffField<T, F>>
fun <T : Any, F : Field<T>> F.simpleAutoDiff(vararg bindings: Pair<Symbol, T>, body: SimpleAutoDiffField<T, F>.() -> AutoDiffValue<T>): DerivationResult<T>

fun <T : Any, F : Field<T>> F.simpleAutoDiff(bindings: Map<Symbol, T>, body: SimpleAutoDiffField<T, F>.() -> AutoDiffValue<T>): DerivationResult<T>

Runs differentiation and establishes SimpleAutoDiffField context inside the block of code.

Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.sin(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.sinh(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.sqr(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.sqrt(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun Symbol(identity: String): Symbol

Create s Symbols with a string identity

Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.tan(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any, F : ExtendedField<T>> SimpleAutoDiffField<T, F>.tanh(x: AutoDiffValue<T>): AutoDiffValue<T>
Link copied to clipboard
fun <T : Any> MST.toExpression(algebra: Algebra<T>): Expression<T>

Interpret this MST as expression.

Link copied to clipboard
inline fun <R> withSymbols(vararg symbols: Symbol, block: SymbolIndexer.() -> R): R

Execute the block with symbol indexer based on given symbol order

inline fun <R> withSymbols(symbols: Collection<Symbol>, block: SymbolIndexer.() -> R): R

Properties

Link copied to clipboard
val <T, E> ExpressionAlgebra<T, E>.binding: ReadOnlyProperty<Any?, E>

Bind a symbol by name inside the ExpressionAlgebra

Link copied to clipboard
val symbol: ReadOnlyProperty<Any?, Symbol>

A delegate to create a symbol with a string identity in this scope