Feature: Polynomials and rational functions #469

Merged
lounres merged 132 commits from feature/polynomials into dev 2022-07-28 18:04:06 +03:00
3 changed files with 54 additions and 0 deletions
Showing only changes of commit d63c4acf10 - Show all commits

View File

@ -5,6 +5,24 @@
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> {
// val greatestCommonDivider = polynomialGCD(numerator, denominator)

View File

@ -5,6 +5,24 @@
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> {
// val greatestCommonDivider = polynomialGCD(numerator, denominator)

View File

@ -5,6 +5,24 @@
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)
//