forked from kscience/kmath
Added space and scope fabrics for RFs
This commit is contained in:
parent
ffd3ae7684
commit
d63c4acf10
@ -5,6 +5,24 @@
|
|||||||
|
|
||||||
package space.kscience.kmath.functions
|
package space.kscience.kmath.functions
|
||||||
|
|
||||||
|
import space.kscience.kmath.operations.Ring
|
||||||
|
import kotlin.contracts.InvocationKind
|
||||||
|
import kotlin.contracts.contract
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a [LabeledRationalFunctionSpace] over a received ring.
|
||||||
|
*/
|
||||||
|
public fun <C, A : Ring<C>> A.labeledRationalFunction(): LabeledRationalFunctionSpace<C, A> =
|
||||||
|
LabeledRationalFunctionSpace(this)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a [RationalFunctionSpace]'s scope over a received ring.
|
||||||
|
*/
|
||||||
|
public inline fun <C, A : Ring<C>, R> A.labeledRationalFunction(block: LabeledRationalFunctionSpace<C, A>.() -> R): R {
|
||||||
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
|
return LabeledRationalFunctionSpace(this).block()
|
||||||
|
}
|
||||||
|
|
||||||
//fun <T: Field<T>> LabeledRationalFunction<T>.reduced(): LabeledRationalFunction<T> {
|
//fun <T: Field<T>> LabeledRationalFunction<T>.reduced(): LabeledRationalFunction<T> {
|
||||||
// val greatestCommonDivider = polynomialGCD(numerator, denominator)
|
// val greatestCommonDivider = polynomialGCD(numerator, denominator)
|
||||||
|
@ -5,6 +5,24 @@
|
|||||||
|
|
||||||
package space.kscience.kmath.functions
|
package space.kscience.kmath.functions
|
||||||
|
|
||||||
|
import space.kscience.kmath.operations.Ring
|
||||||
|
import kotlin.contracts.InvocationKind
|
||||||
|
import kotlin.contracts.contract
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a [NumberedRationalFunctionSpace] over a received ring.
|
||||||
|
*/
|
||||||
|
public fun <C, A : Ring<C>> A.numberedRationalFunction(): NumberedRationalFunctionSpace<C, A> =
|
||||||
|
NumberedRationalFunctionSpace(this)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a [RationalFunctionSpace]'s scope over a received ring.
|
||||||
|
*/
|
||||||
|
public inline fun <C, A : Ring<C>, R> A.numberedRationalFunction(block: NumberedRationalFunctionSpace<C, A>.() -> R): R {
|
||||||
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
|
return NumberedRationalFunctionSpace(this).block()
|
||||||
|
}
|
||||||
|
|
||||||
//fun <T: Field<T>> NumberedRationalFunction<T>.reduced(): NumberedRationalFunction<T> {
|
//fun <T: Field<T>> NumberedRationalFunction<T>.reduced(): NumberedRationalFunction<T> {
|
||||||
// val greatestCommonDivider = polynomialGCD(numerator, denominator)
|
// val greatestCommonDivider = polynomialGCD(numerator, denominator)
|
||||||
|
@ -5,6 +5,24 @@
|
|||||||
|
|
||||||
package space.kscience.kmath.functions
|
package space.kscience.kmath.functions
|
||||||
|
|
||||||
|
import space.kscience.kmath.operations.Ring
|
||||||
|
import kotlin.contracts.InvocationKind
|
||||||
|
import kotlin.contracts.contract
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a [RationalFunctionSpace] over a received ring.
|
||||||
|
*/
|
||||||
|
public fun <C, A : Ring<C>> A.rationalFunction(): RationalFunctionSpace<C, A> =
|
||||||
|
RationalFunctionSpace(this)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a [RationalFunctionSpace]'s scope over a received ring.
|
||||||
|
*/
|
||||||
|
public inline fun <C, A : Ring<C>, R> A.rationalFunction(block: RationalFunctionSpace<C, A>.() -> R): R {
|
||||||
|
contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }
|
||||||
|
return RationalFunctionSpace(this).block()
|
||||||
|
}
|
||||||
|
|
||||||
//operator fun <T: Field<T>> RationalFunction<T>.invoke(arg: T): T = numerator(arg) / denominator(arg)
|
//operator fun <T: Field<T>> RationalFunction<T>.invoke(arg: T): T = numerator(arg) / denominator(arg)
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user