Add adapters of scalar functions to MST and vice versa #150
@ -8,8 +8,8 @@ import kscience.kmath.operations.*
|
||||
|
||||
/**
|
||||
* Maps [SFun] objects to [MST]. Some unsupported operations like [Derivative] are bound and converted then.
|
||||
*
|
||||
* @receiver a scalar function.
|
||||
change to toMst() change to toMst()
|
||||
* @return the [MST].
|
||||
change to toMst() change to toMst()
|
||||
* @receiver the scalar function.
|
||||
change to toMst() change to toMst()
|
||||
* @return a node.
|
||||
change to toMst() change to toMst()
|
||||
*/
|
||||
public fun <X : SFun<X>> SFun<X>.mst(): MST = MstExtendedField {
|
||||
when (this@mst) {
|
||||
@ -30,16 +30,33 @@ public fun <X : SFun<X>> SFun<X>.mst(): MST = MstExtendedField {
|
||||
change to toMst() change to toMst()
change to toMst() change to toMst()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
change to toMst() change to toMst()
|
||||
* Maps [MST.Numeric] to [SConst] directly.
|
||||
change to toMst() change to toMst()
|
||||
*
|
||||
change to toMst() change to toMst()
|
||||
* @receiver the node.
|
||||
change to toMst() change to toMst()
|
||||
* @return a new constant.
|
||||
change to toMst() change to toMst()
|
||||
*/
|
||||
change to toMst() change to toMst()
|
||||
public fun <X : SFun<X>> MST.Numeric.sconst(): SConst<X> = SConst(value)
|
||||
change to toMst() change to toMst()
|
||||
|
||||
change to toMst() change to toMst()
|
||||
/**
|
||||
change to toMst() change to toMst()
|
||||
* Maps [MST.Symbolic] to [SVar] directly.
|
||||
change to toMst() change to toMst()
|
||||
*
|
||||
change to toMst() change to toMst()
|
||||
* @receiver the node.
|
||||
change to toMst() change to toMst()
|
||||
* @param proto the prototype instance.
|
||||
change to toMst() change to toMst()
|
||||
* @return a new variable.
|
||||
change to toMst() change to toMst()
|
||||
*/
|
||||
change to toMst() change to toMst()
|
||||
public fun <X : SFun<X>> MST.Symbolic.svar(proto: X): SVar<X> = SVar(proto, value)
|
||||
change to toMst() change to toMst()
|
||||
|
||||
change to toMst() change to toMst()
|
||||
/**
|
||||
* Maps [MST] objects to [SFun]. Unsupported operations throw [IllegalStateException].
|
||||
*
|
||||
* @receiver an [MST].
|
||||
change to toMst() change to toMst()
|
||||
* @return the scalar function.
|
||||
change to toMst() change to toMst()
|
||||
* @receiver the node.
|
||||
change to toMst() change to toMst()
|
||||
* @param proto the prototype instance.
|
||||
change to toMst() change to toMst()
|
||||
* @return a scalar function.
|
||||
change to toMst() change to toMst()
|
||||
*/
|
||||
public fun <X : SFun<X>> MST.sfun(proto: X): SFun<X> {
|
||||
change to toMst() change to toMst()
|
||||
return when (this) {
|
||||
change to toMst() change to toMst()
|
||||
is MST.Numeric -> SConst(value)
|
||||
change to toMst() change to toMst()
|
||||
is MST.Symbolic -> SVar(proto, value)
|
||||
change to toMst() change to toMst()
|
||||
public fun <X : SFun<X>> MST.sfun(proto: X): SFun<X> = when (this) {
|
||||
change to toMst() change to toMst()
|
||||
is MST.Numeric -> sconst()
|
||||
change to toMst() change to toMst()
|
||||
is MST.Symbolic -> svar(proto)
|
||||
change to toMst() change to toMst()
|
||||
|
||||
is MST.Unary -> when (operation) {
|
||||
SpaceOperations.PLUS_OPERATION -> value.sfun(proto)
|
||||
@ -62,4 +79,3 @@ public fun <X : SFun<X>> MST.sfun(proto: X): SFun<X> {
|
||||
change to toMst() change to toMst()
change to toMst() change to toMst()
|
||||
else -> error("Binary operation $operation not defined in $this")
|
||||
}
|
||||
}
|
||||
}
|
||||
change to toMst() change to toMst()
|
||||
|
||||
change to toMst() change to toMst()
change to toMst() change to toMst()
|
Loading…
Reference in New Issue
Block a user
change to toMst()
change to toMst()