Package space.kscience.kmath.ast

Types

Link copied to clipboard
object ArithmeticsEvaluator : Grammar<MST>

better-parse implementation of grammar defined in the ArithmeticsEvaluator.g4.

Link copied to clipboard
interface TypedMst<T>

MST form where all values belong to the type T. It is optimal for constant folding, dynamic compilation, etc.

Functions

Link copied to clipboard
fun <T> MST.evaluateConstants(algebra: Algebra<T>): TypedMst<T>

Evaluates constants in given MST for given algebra at the same time with converting to TypedMst.

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

Interprets the TypedMst node with this Algebra and optional arguments.

fun <T> TypedMst<T>.interpret(algebra: Algebra<T>, arguments: Map<Symbol, T>): T

Interprets the TypedMst node with this Algebra and arguments.

Link copied to clipboard
fun String.parseMath(): MST

Parses the string into MST using ArithmeticsEvaluator.

Link copied to clipboard
fun <T : Any> TypedMst<T>.toExpression(algebra: Algebra<T>): Expression<T>

Interpret this TypedMst node as expression.

Link copied to clipboard
fun String.tryParseMath(): ParseResult<MST>

Tries to parse the string into MST using ArithmeticsEvaluator. Returns ParseResult representing expression or error.