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 27 additions and 18 deletions
Showing only changes of commit 94fd24d852 - Show all commits

View File

@ -50,15 +50,6 @@ public class ListRationalFunctionSpace<C, A : Ring<C>> (
override fun constructRationalFunction(numerator: ListPolynomial<C>, denominator: ListPolynomial<C>): ListRationalFunction<C> = override fun constructRationalFunction(numerator: ListPolynomial<C>, denominator: ListPolynomial<C>): ListRationalFunction<C> =
ListRationalFunction(numerator, denominator) ListRationalFunction(numerator, denominator)
/**
* Instance of zero rational function (zero of the rational functions ring).
*/
public override val zero: ListRationalFunction<C> = ListRationalFunction(polynomialZero, polynomialOne)
/**
* Instance of unit polynomial (unit of the rational functions ring).
*/
public override val one: ListRationalFunction<C> = ListRationalFunction(polynomialOne, polynomialOne)
// TODO: When context receivers will be ready move all of this substitutions and invocations to utilities with // TODO: When context receivers will be ready move all of this substitutions and invocations to utilities with
// [ListPolynomialSpace] as a context receiver // [ListPolynomialSpace] as a context receiver
/** /**

View File

@ -834,7 +834,12 @@ public abstract class PolynomialSpaceOfFractions<
numerator * other, numerator * other,
denominator denominator
) )
/**
* Returns quotient of the rational function and the integer represented as a rational function.
*
* The operation is equivalent to creating a new rational function by preserving numerator of [this] and
* multiplication denominator of [this] to [other].
*/
public override operator fun R.div(other: Int): R = public override operator fun R.div(other: Int): R =
constructRationalFunction( constructRationalFunction(
numerator, numerator,
@ -871,7 +876,12 @@ public abstract class PolynomialSpaceOfFractions<
this * other.numerator, this * other.numerator,
other.denominator other.denominator
) )
/**
* Returns quotient of the integer represented as a rational function and the rational function.
*
* The operation is equivalent to creating a new rational function which numerator is [this] times denominator of
* [other] and which denominator is [other]'s numerator.
*/
public override operator fun Int.div(other: R): R = public override operator fun Int.div(other: R): R =
constructRationalFunction( constructRationalFunction(
this * other.denominator, this * other.denominator,
@ -912,7 +922,9 @@ public abstract class PolynomialSpaceOfFractions<
this * other.numerator, this * other.numerator,
other.denominator other.denominator
) )
/**
* Returns quotient of the constant represented as a polynomial and the rational function.
*/
public override operator fun C.div(other: R): R = public override operator fun C.div(other: R): R =
constructRationalFunction( constructRationalFunction(
this * other.denominator, this * other.denominator,
@ -943,7 +955,9 @@ public abstract class PolynomialSpaceOfFractions<
numerator * other, numerator * other,
denominator denominator
) )
/**
* Returns quotient of the rational function and the constant represented as a rational function.
*/
public override operator fun R.div(other: C): R = public override operator fun R.div(other: C): R =
constructRationalFunction( constructRationalFunction(
numerator, numerator,
@ -979,7 +993,9 @@ public abstract class PolynomialSpaceOfFractions<
this * other.numerator, this * other.numerator,
other.denominator other.denominator
) )
/**
* Returns quotient of the polynomial represented as a polynomial and the rational function.
*/
public override operator fun P.div(other: R): R = public override operator fun P.div(other: R): R =
constructRationalFunction( constructRationalFunction(
this * other.denominator, this * other.denominator,
@ -1010,7 +1026,9 @@ public abstract class PolynomialSpaceOfFractions<
numerator * other, numerator * other,
denominator denominator
) )
/**
* Returns quotient of the rational function and the polynomial represented as a rational function.
*/
public override operator fun R.div(other: P): R = public override operator fun R.div(other: P): R =
constructRationalFunction( constructRationalFunction(
numerator, numerator,
@ -1050,7 +1068,9 @@ public abstract class PolynomialSpaceOfFractions<
numerator * other.numerator, numerator * other.numerator,
denominator * other.denominator denominator * other.denominator
) )
/**
* Returns quotient of the rational functions.
*/
public override operator fun R.div(other: R): R = public override operator fun R.div(other: R): R =
constructRationalFunction( constructRationalFunction(
numerator * other.denominator, numerator * other.denominator,

View File

@ -7,7 +7,6 @@ package space.kscience.kmath.test.misc
import space.kscience.kmath.functions.ListPolynomial import space.kscience.kmath.functions.ListPolynomial
import space.kscience.kmath.functions.ListPolynomialSpace import space.kscience.kmath.functions.ListPolynomialSpace
import space.kscience.kmath.misc.UnstableKMathAPI
import space.kscience.kmath.operations.Ring import space.kscience.kmath.operations.Ring
@ -109,7 +108,6 @@ class IntModulo {
} }
@Suppress("EXTENSION_SHADOWED_BY_MEMBER", "OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE") @Suppress("EXTENSION_SHADOWED_BY_MEMBER", "OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE")
@OptIn(UnstableKMathAPI::class)
class IntModuloRing : Ring<IntModulo> { class IntModuloRing : Ring<IntModulo> {
val modulus: Int val modulus: Int