Minor refactor

This commit is contained in:
Iaroslav 2020-06-08 14:46:00 +07:00
parent b7d1fe2560
commit c576e46020
No known key found for this signature in database
GPG Key ID: 46E15E4A31B3BCD7
2 changed files with 4 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package scientifik.kmath.expressions
import scientifik.kmath.operations.Field import scientifik.kmath.operations.Field
import scientifik.kmath.operations.Space import scientifik.kmath.operations.Space
import scientifik.kmath.operations.invoke
open class AsmExpressionSpace<T>(private val space: Space<T>) : Space<AsmExpression<T>>, open class AsmExpressionSpace<T>(private val space: Space<T>) : Space<AsmExpression<T>>,
ExpressionSpace<T, AsmExpression<T>> { ExpressionSpace<T, AsmExpression<T>> {
@ -21,7 +22,7 @@ class AsmExpressionField<T>(private val field: Field<T>) : ExpressionField<T, As
override val one: AsmExpression<T> override val one: AsmExpression<T>
get() = const(this.field.one) get() = const(this.field.one)
override fun number(value: Number): AsmExpression<T> = const(field.run { one * value }) override fun number(value: Number): AsmExpression<T> = const(field { one * value })
override fun multiply(a: AsmExpression<T>, b: AsmExpression<T>): AsmExpression<T> = override fun multiply(a: AsmExpression<T>, b: AsmExpression<T>): AsmExpression<T> =
AsmProductExpression(field, a, b) AsmProductExpression(field, a, b)

View File

@ -3,6 +3,7 @@ package scientifik.kmath.expressions
import scientifik.kmath.operations.Field import scientifik.kmath.operations.Field
import scientifik.kmath.operations.Ring import scientifik.kmath.operations.Ring
import scientifik.kmath.operations.Space import scientifik.kmath.operations.Space
import scientifik.kmath.operations.invoke
internal class VariableExpression<T>(val name: String, val default: T? = null) : Expression<T> { internal class VariableExpression<T>(val name: String, val default: T? = null) : Expression<T> {
override fun invoke(arguments: Map<String, T>): T = override fun invoke(arguments: Map<String, T>): T =
@ -57,7 +58,7 @@ open class FunctionalExpressionField<T>(
override val one: Expression<T> override val one: Expression<T>
get() = const(this.field.one) get() = const(this.field.one)
override fun number(value: Number): Expression<T> = const(field.run { one * value }) override fun number(value: Number): Expression<T> = const(field { one * value })
override fun multiply(a: Expression<T>, b: Expression<T>): Expression<T> = ProductExpression(field, a, b) override fun multiply(a: Expression<T>, b: Expression<T>): Expression<T> = ProductExpression(field, a, b)
override fun divide(a: Expression<T>, b: Expression<T>): Expression<T> = DivExpression(field, a, b) override fun divide(a: Expression<T>, b: Expression<T>): Expression<T> = DivExpression(field, a, b)
operator fun Expression<T>.times(arg: T): Expression<T> = this * const(arg) operator fun Expression<T>.times(arg: T): Expression<T> = this * const(arg)