Apply new interfaces structure to ASM Expression Field/Space
This commit is contained in:
parent
4dcdc0f99c
commit
33a519c10b
@ -4,8 +4,9 @@ import scientifik.kmath.operations.Field
|
|||||||
import scientifik.kmath.operations.Space
|
import scientifik.kmath.operations.Space
|
||||||
import scientifik.kmath.operations.invoke
|
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>) :
|
||||||
ExpressionSpace<T, AsmExpression<T>> {
|
Space<AsmExpression<T>>,
|
||||||
|
ExpressionContext<T, AsmExpression<T>> {
|
||||||
override val zero: AsmExpression<T> = AsmConstantExpression(space.zero)
|
override val zero: AsmExpression<T> = AsmConstantExpression(space.zero)
|
||||||
override fun const(value: T): AsmExpression<T> = AsmConstantExpression(value)
|
override fun const(value: T): AsmExpression<T> = AsmConstantExpression(value)
|
||||||
override fun variable(name: String, default: T?): AsmExpression<T> = AsmVariableExpression(name, default)
|
override fun variable(name: String, default: T?): AsmExpression<T> = AsmVariableExpression(name, default)
|
||||||
@ -17,12 +18,14 @@ open class AsmExpressionSpace<T>(private val space: Space<T>) : Space<AsmExpress
|
|||||||
operator fun T.minus(arg: AsmExpression<T>): AsmExpression<T> = arg - this
|
operator fun T.minus(arg: AsmExpression<T>): AsmExpression<T> = arg - this
|
||||||
}
|
}
|
||||||
|
|
||||||
class AsmExpressionField<T>(private val field: Field<T>) : ExpressionField<T, AsmExpression<T>>,
|
class AsmExpressionField<T>(private val field: Field<T>) :
|
||||||
|
ExpressionContext<T, AsmExpression<T>>,
|
||||||
|
Field<AsmExpression<T>>,
|
||||||
AsmExpressionSpace<T>(field) {
|
AsmExpressionSpace<T>(field) {
|
||||||
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 { one * value })
|
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)
|
||||||
|
@ -39,7 +39,7 @@ internal class DivExpession<T>(val context: Field<T>, val expr: Expression<T>, v
|
|||||||
|
|
||||||
open class FunctionalExpressionSpace<T>(
|
open class FunctionalExpressionSpace<T>(
|
||||||
val space: Space<T>
|
val space: Space<T>
|
||||||
) : Space<Expression<T>>, ExpressionContext<T,Expression<T>> {
|
) : Space<Expression<T>>, ExpressionContext<T, Expression<T>> {
|
||||||
|
|
||||||
override val zero: Expression<T> = ConstantExpression(space.zero)
|
override val zero: Expression<T> = ConstantExpression(space.zero)
|
||||||
|
|
||||||
@ -61,12 +61,12 @@ open class FunctionalExpressionSpace<T>(
|
|||||||
|
|
||||||
open class FunctionalExpressionField<T>(
|
open class FunctionalExpressionField<T>(
|
||||||
val field: Field<T>
|
val field: Field<T>
|
||||||
) : Field<Expression<T>>, ExpressionContext<T,Expression<T>>, FunctionalExpressionSpace<T>(field) {
|
) : Field<Expression<T>>, ExpressionContext<T, Expression<T>>, FunctionalExpressionSpace<T>(field) {
|
||||||
|
|
||||||
override val one: Expression<T>
|
override val one: Expression<T>
|
||||||
get() = const(this.field.one)
|
get() = const(this.field.one)
|
||||||
|
|
||||||
fun const(value: Double): Expression<T> = const(field.run { one*value})
|
fun number(value: Number): Expression<T> = const(field.run { 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)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user