Feature: Polynomials and rational functions #469

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

View File

@ -23,7 +23,6 @@ public interface AbstractPolynomial<C>
*/
@Suppress("INAPPLICABLE_JVM_NAME", "PARAMETER_NAME_CHANGED_ON_OVERRIDE")
public interface AbstractPolynomialSpace<C, P: AbstractPolynomial<C>> : Ring<P> {
// region Constant-integer relation
/**
* Returns sum of the constant and the integer represented as constant (member of underlying ring).
*
@ -42,9 +41,7 @@ public interface AbstractPolynomialSpace<C, P: AbstractPolynomial<C>> : Ring<P>
* The operation is equivalent to sum of [other] copies of [this].
*/
public operator fun C.times(other: Int): C
// endregion
// region Integer-constant relation
/**
* Returns sum of the integer represented as constant (member of underlying ring) and the constant.
*
@ -63,9 +60,7 @@ public interface AbstractPolynomialSpace<C, P: AbstractPolynomial<C>> : Ring<P>
* The operation is equivalent to sum of [this] copies of [other].
*/
public operator fun Int.times(other: C): C
// endregion
// region Polynomial-integer relation
/**
* Returns sum of the polynomial and the integer represented as polynomial.
*
@ -84,9 +79,7 @@ public interface AbstractPolynomialSpace<C, P: AbstractPolynomial<C>> : Ring<P>
* The operation is equivalent to sum of [other] copies of [this].
*/
public operator fun P.times(other: Int): P = multiplyBySquaring(this, other)
// endregion
// region Integer-polynomial relation
/**
* Returns sum of the integer represented as polynomial and the polynomial.
*
@ -105,9 +98,7 @@ public interface AbstractPolynomialSpace<C, P: AbstractPolynomial<C>> : Ring<P>
* The operation is equivalent to sum of [this] copies of [other].
*/
public operator fun Int.times(other: P): P = multiplyBySquaring(other, this)
// endregion
// region Constant-constant relation
/**
* Returns the same constant.
*/
@ -178,9 +169,7 @@ public interface AbstractPolynomialSpace<C, P: AbstractPolynomial<C>> : Ring<P>
* Instance of unit constant (unit of the underlying ring).
*/
public val constantOne: C
// endregion
// region Constant-polynomial relation
/**
* Returns sum of the constant represented as polynomial and the polynomial.
*/
@ -193,9 +182,7 @@ public interface AbstractPolynomialSpace<C, P: AbstractPolynomial<C>> : Ring<P>
* Returns product of the constant represented as polynomial and the polynomial.
*/
public operator fun C.times(other: P): P
// endregion
// region Polynomial-constant relation
/**
* Returns sum of the constant represented as polynomial and the polynomial.
*/
@ -208,9 +195,7 @@ public interface AbstractPolynomialSpace<C, P: AbstractPolynomial<C>> : Ring<P>
* Returns product of the constant represented as polynomial and the polynomial.
*/
public operator fun P.times(other: C): P
// endregion
// region Polynomial-polynomial relation
/**
* Returns the same polynomial.
*/
@ -278,10 +263,7 @@ public interface AbstractPolynomialSpace<C, P: AbstractPolynomial<C>> : Ring<P>
* Checks NOT equality of the polynomials.
*/
public infix fun P.notEqualsTo(other: P): Boolean = !(this equalsTo other)
// endregion
// Not sure is it necessary...
// region Polynomial properties
/**
* Degree of the polynomial, [see also](https://en.wikipedia.org/wiki/Degree_of_a_polynomial). If the polynomial is
* zero, degree is -1.
@ -314,12 +296,9 @@ public interface AbstractPolynomialSpace<C, P: AbstractPolynomial<C>> : Ring<P>
* Otherwise, (when the polynomial is not constant polynomial) raises corresponding exception.
*/
public fun P.asConstant(): C = asConstantOrNull() ?: error("Can not represent non-constant polynomial as a constant")
// endregion
// region Legacy of Ring interface
override fun add(left: P, right: P): P = left + right
override fun multiply(left: P, right: P): P = left * right
// endregion
}
/**
@ -335,7 +314,6 @@ public interface AbstractPolynomialSpaceOverRing<C, P: AbstractPolynomial<C>, A:
public val ring: A
// region Constant-integer relation
/**
* Returns sum of the constant and the integer represented as constant (member of underlying ring).
*
@ -354,9 +332,7 @@ public interface AbstractPolynomialSpaceOverRing<C, P: AbstractPolynomial<C>, A:
* The operation is equivalent to sum of [other] copies of [this].
*/
public override operator fun C.times(other: Int): C = ring { multiplyBySquaring(this@times, other) }
// endregion
// region Integer-constant relation
/**
* Returns sum of the integer represented as constant (member of underlying ring) and the constant.
*
@ -375,9 +351,7 @@ public interface AbstractPolynomialSpaceOverRing<C, P: AbstractPolynomial<C>, A:
* The operation is equivalent to sum of [this] copies of [other].
*/
public override operator fun Int.times(other: C): C = ring { multiplyBySquaring(other, this@times) }
// endregion
// region Constant-constant relation
/**
* Returns negation of the constant.
*/
@ -412,5 +386,4 @@ public interface AbstractPolynomialSpaceOverRing<C, P: AbstractPolynomial<C>, A:
* Instance of unit constant (unit of the underlying ring).
*/
public override val constantOne: C get() = ring.one
// endregion
}

View File

@ -30,7 +30,6 @@ public interface AbstractRationalFunction<C, P: AbstractPolynomial<C>> {
*/ // TODO: Add support of field
@Suppress("INAPPLICABLE_JVM_NAME", "PARAMETER_NAME_CHANGED_ON_OVERRIDE")
public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R: AbstractRationalFunction<C, P>> : Ring<R> {
// region Constant-integer relation
/**
* Returns sum of the constant and the integer represented as constant (member of underlying ring).
*
@ -49,9 +48,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* The operation is equivalent to sum of [other] copies of [this].
*/
public operator fun C.times(other: Int): C
// endregion
// region Integer-constant relation
/**
* Returns sum of the integer represented as constant (member of underlying ring) and the constant.
*
@ -70,9 +67,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* The operation is equivalent to sum of [this] copies of [other].
*/
public operator fun Int.times(other: C): C
// endregion
// region Polynomial-integer relation
/**
* Returns sum of the constant and the integer represented as polynomial.
*
@ -91,9 +86,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* The operation is equivalent to sum of [other] copies of [this].
*/
public operator fun P.times(other: Int): P
// endregion
// region Integer-polynomial relation
/**
* Returns sum of the integer represented as polynomial and the constant.
*
@ -112,9 +105,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* The operation is equivalent to sum of [this] copies of [other].
*/
public operator fun Int.times(other: P): P
// endregion
// region Rational-integer relation
/**
* Returns sum of the rational function and the integer represented as rational function.
*
@ -133,9 +124,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* The operation is equivalent to sum of [other] copies of [this].
*/
public operator fun R.times(other: Int): R = multiplyBySquaring(this, other)
// endregion
// region Integer-Rational relation
/**
* Returns sum of the integer represented as rational function and the rational function.
*
@ -154,9 +143,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* The operation is equivalent to sum of [this] copies of [other].
*/
public operator fun Int.times(other: R): R = multiplyBySquaring(other, this)
// endregion
// region Constant-constant relation
/**
* Returns the same constant.
*/
@ -227,9 +214,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* Instance of unit constant (unit of the underlying ring).
*/
public val constantOne: C
// endregion
// region Constant-polynomial relation
/**
* Returns sum of the constant represented as polynomial and the polynomial.
*/
@ -242,9 +227,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* Returns product of the constant represented as polynomial and the polynomial.
*/
public operator fun C.times(other: P): P
// endregion
// region Polynomial-constant relation
/**
* Returns sum of the constant represented as polynomial and the polynomial.
*/
@ -257,9 +240,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* Returns product of the constant represented as polynomial and the polynomial.
*/
public operator fun P.times(other: C): P
// endregion
// region Polynomial-polynomial relation
/**
* Returns the same polynomial.
*/
@ -327,9 +308,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* Checks NOT equality of the polynomials.
*/
public infix fun P.notEqualsTo(other: P): Boolean = !(this equalsTo other)
// endregion
// region Constant-rational relation
/**
* Returns sum of the constant represented as rational function and the rational function.
*/
@ -342,9 +321,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* Returns product of the constant represented as polynomial and the rational function.
*/
public operator fun C.times(other: R): R
// endregion
// region Rational-constant relation
/**
* Returns sum of the constant represented as rational function and the rational function.
*/
@ -357,9 +334,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* Returns product of the constant represented as rational function and the rational function.
*/
public operator fun R.times(other: C): R
// endregion
// region Polynomial-rational relation
/**
* Returns sum of the polynomial represented as rational function and the rational function.
*/
@ -372,9 +347,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* Returns product of the polynomial represented as polynomial and the rational function.
*/
public operator fun P.times(other: R): R
// endregion
// region Rational-polynomial relation
/**
* Returns sum of the polynomial represented as rational function and the rational function.
*/
@ -387,9 +360,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* Returns product of the polynomial represented as rational function and the rational function.
*/
public operator fun R.times(other: P): R
// endregion
// region Rational-rational relation
/**
* Returns the same rational function.
*/
@ -457,10 +428,7 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
* Checks NOT equality of the polynomials.
*/
public infix fun R.notEqualsTo(other: R): Boolean = !(this equalsTo other)
// endregion
// Not sure is it necessary...
// region Polynomial properties
/**
* Degree of the polynomial, [see also](https://en.wikipedia.org/wiki/Degree_of_a_polynomial). If the polynomial is
* zero, degree is -1.
@ -494,10 +462,6 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
*/
public fun P.asConstant(): C = asConstantOrNull() ?: error("Can not represent non-constant polynomial as a constant")
// endregion
// Not sure is it necessary...
// region Rational properties
/**
* Degree of the polynomial, [see also](https://en.wikipedia.org/wiki/Degree_of_a_polynomial). If the polynomial is
* zero, degree is -1.
@ -509,25 +473,8 @@ public interface AbstractRationalFunctionalSpace<C, P: AbstractPolynomial<C>, R:
*/
public val R.denominatorDegree: Int get() = denominator.degree
// TODO: Перенести в реализацию
// fun R.substitute(argument: C): C
// fun R.substitute(argument: P): R
// fun R.substitute(argument: R): R
//
// fun R.asFunction(): (C) -> C = /*this::substitute*/ { this.substitute(it) }
// fun R.asFunctionOnConstants(): (C) -> C = /*this::substitute*/ { this.substitute(it) }
// fun P.asFunctionOnPolynomials(): (P) -> R = /*this::substitute*/ { this.substitute(it) }
// fun R.asFunctionOnRationalFunctions(): (R) -> R = /*this::substitute*/ { this.substitute(it) }
//
// operator fun R.invoke(argument: C): C = this.substitute(argument)
// operator fun R.invoke(argument: P): R = this.substitute(argument)
// operator fun R.invoke(argument: R): R = this.substitute(argument)
// endregion
// region Legacy
override fun add(left: R, right: R): R = left + right
override fun multiply(left: R, right: R): R = left * right
// endregion
}
/**
@ -544,7 +491,6 @@ public interface AbstractRationalFunctionalSpaceOverRing<C, P: AbstractPolynomia
public val ring: A
// region Constant-integer relation
/**
* Returns sum of the constant and the integer represented as constant (member of underlying ring).
*
@ -563,9 +509,7 @@ public interface AbstractRationalFunctionalSpaceOverRing<C, P: AbstractPolynomia
* The operation is equivalent to sum of [other] copies of [this].
*/
public override operator fun C.times(other: Int): C = ring { multiplyBySquaring(this@times, other) }
// endregion
// region Integer-constant relation
/**
* Returns sum of the integer represented as constant (member of underlying ring) and the constant.
*
@ -584,9 +528,7 @@ public interface AbstractRationalFunctionalSpaceOverRing<C, P: AbstractPolynomia
* The operation is equivalent to sum of [this] copies of [other].
*/
public override operator fun Int.times(other: C): C = ring { multiplyBySquaring(other, this@times) }
// endregion
// region Constant-constant relation
/**
* Returns the same constant.
*/
@ -626,7 +568,6 @@ public interface AbstractRationalFunctionalSpaceOverRing<C, P: AbstractPolynomia
* Instance of unit constant (unit of the underlying ring).
*/
public override val constantOne: C get() = ring.one
// endregion
}
/**
@ -649,7 +590,6 @@ public interface AbstractRationalFunctionalSpaceOverPolynomialSpace<
public val polynomialRing: AP
// region Constant-integer relation
/**
* Returns sum of the constant and the integer represented as constant (member of underlying ring).
*
@ -668,9 +608,7 @@ public interface AbstractRationalFunctionalSpaceOverPolynomialSpace<
* The operation is equivalent to sum of [other] copies of [this].
*/
public override operator fun C.times(other: Int): C = polynomialRing { this@times * other }
// endregion
// region Integer-constant relation
/**
* Returns sum of the integer represented as constant (member of underlying ring) and the constant.
*
@ -689,9 +627,7 @@ public interface AbstractRationalFunctionalSpaceOverPolynomialSpace<
* The operation is equivalent to sum of [this] copies of [other].
*/
public override operator fun Int.times(other: C): C = polynomialRing { this@times * other }
// endregion
// region Polynomial-integer relation
/**
* Returns sum of the constant and the integer represented as polynomial.
*
@ -710,9 +646,7 @@ public interface AbstractRationalFunctionalSpaceOverPolynomialSpace<
* The operation is equivalent to sum of [other] copies of [this].
*/
public override operator fun P.times(other: Int): P = polynomialRing { this@times * other }
// endregion
// region Integer-polynomial relation
/**
* Returns sum of the integer represented as polynomial and the constant.
*
@ -731,9 +665,7 @@ public interface AbstractRationalFunctionalSpaceOverPolynomialSpace<
* The operation is equivalent to sum of [this] copies of [other].
*/
public override operator fun Int.times(other: P): P = polynomialRing { this@times * other }
// endregion
// region Constant-constant relation
/**
* Returns the same constant.
*/
@ -798,9 +730,7 @@ public interface AbstractRationalFunctionalSpaceOverPolynomialSpace<
* Instance of unit constant (unit of the underlying ring).
*/
public override val constantOne: C get() = polynomialRing.constantOne
// endregion
// region Constant-polynomial relation
/**
* Returns sum of the constant represented as polynomial and the polynomial.
*/
@ -813,9 +743,7 @@ public interface AbstractRationalFunctionalSpaceOverPolynomialSpace<
* Returns product of the constant represented as polynomial and the polynomial.
*/
public override operator fun C.times(other: P): P = polynomialRing { this@times * other }
// endregion
// region Polynomial-constant relation
/**
* Returns sum of the constant represented as polynomial and the polynomial.
*/
@ -828,9 +756,7 @@ public interface AbstractRationalFunctionalSpaceOverPolynomialSpace<
* Returns product of the constant represented as polynomial and the polynomial.
*/
public override operator fun P.times(other: C): P = polynomialRing { this@times * other }
// endregion
// region Polynomial-polynomial relation
/**
* Returns the same polynomial.
*/
@ -898,10 +824,7 @@ public interface AbstractRationalFunctionalSpaceOverPolynomialSpace<
* Checks NOT equality of the polynomials.
*/
public override infix fun P.notEqualsTo(other: P): Boolean = polynomialRing { this@notEqualsTo notEqualsTo other }
// endregion
// Not sure is it necessary...
// region Polynomial properties
/**
* Degree of the polynomial, [see also](https://en.wikipedia.org/wiki/Degree_of_a_polynomial). If the polynomial is
* zero, degree is -1.
@ -934,6 +857,4 @@ public interface AbstractRationalFunctionalSpaceOverPolynomialSpace<
* Otherwise, (when the polynomial is not constant polynomial) raises corresponding exception.
*/
public override fun P.asConstant(): C = polynomialRing { this@asConstant.asConstant() }
// endregion
}

View File

@ -48,8 +48,6 @@ internal constructor(
override fun toString(): String = "LabeledPolynomial$coefficients"
}
// region Internal utilities
/**
* Represents internal [LabeledPolynomial] errors.
*/
@ -70,10 +68,6 @@ internal fun labeledPolynomialError(message: Any): Nothing = throw LabeledPolyno
*/
internal fun Map<Symbol, UInt>.cleanUp() = filterValues { it > 0U }
// endregion
// region Constructors and converters
//context(LabeledPolynomialSpace<C, Ring<C>>)
//@Suppress("FunctionName")
//internal fun <C> LabeledPolynomial(coefs: Map<Map<Symbol, UInt>, C>, toCheckInput: Boolean = false) : LabeledPolynomial<C> {
@ -128,8 +122,6 @@ internal fun Map<Symbol, UInt>.cleanUp() = filterValues { it > 0U }
public fun <C> C.asLabeledPolynomial() : LabeledPolynomial<C> = LabeledPolynomial(mapOf(emptyMap<Symbol, UInt>() to this))
// endregion
/**
* Space of polynomials.
*
@ -140,8 +132,6 @@ public fun <C> C.asLabeledPolynomial() : LabeledPolynomial<C> = LabeledPolynomia
public class LabeledPolynomialSpace<C, A : Ring<C>>(
public override val ring: A,
) : AbstractPolynomialSpaceOverRing<C, LabeledPolynomial<C>, A> {
// region Symbol-integer relation
public operator fun Symbol.plus(other: Int): LabeledPolynomial<C> =
if (other == 0) LabeledPolynomial<C>(mapOf(
mapOf(this@plus to 1U) to constantOne,
@ -163,9 +153,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
else LabeledPolynomial<C>(mapOf(
mapOf(this to 1U) to constantOne * other,
))
// endregion
// region Integer-variable relation
public operator fun Int.plus(other: Symbol): LabeledPolynomial<C> =
if (this == 0) LabeledPolynomial<C>(mapOf(
mapOf(other to 1U) to constantOne,
@ -187,9 +175,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
else LabeledPolynomial<C>(mapOf(
mapOf(other to 1U) to constantOne * this@times,
))
// endregion
// region Polynomial-integer relation
/**
* Returns sum of the polynomial and the integer represented as polynomial.
*
@ -243,9 +229,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
mapValues { (_, c) -> c * other }
}
)
// endregion
// region Integer-polynomial relation
/**
* Returns sum of the integer represented as polynomial and the polynomial.
*
@ -299,9 +283,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
mapValues { (_, c) -> this@times * c }
}
)
// endregion
// region Constant-variable relation
public operator fun C.plus(other: Symbol): LabeledPolynomial<C> =
if (isZero()) LabeledPolynomial<C>(mapOf(
mapOf(other to 1U) to constantOne,
@ -323,9 +305,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
else LabeledPolynomial<C>(mapOf(
mapOf(other to 1U) to this@times,
))
// endregion
// region Symbol-constant relation
public operator fun Symbol.plus(other: C): LabeledPolynomial<C> =
if (other.isZero()) LabeledPolynomial<C>(mapOf(
mapOf(this@plus to 1U) to constantOne,
@ -347,9 +327,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
else LabeledPolynomial<C>(mapOf(
mapOf(this@times to 1U) to other,
))
// endregion
// region Constant-polynomial relation
/**
* Returns sum of the constant represented as polynomial and the polynomial.
*/
@ -401,9 +379,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
mapValues { (_, c) -> this@times * c }
}
)
// endregion
// region Polynomial-constant relation
/**
* Returns sum of the constant represented as polynomial and the polynomial.
*/
@ -455,9 +431,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
mapValues { (_, c) -> c * other }
}
)
// endregion
// region Symbol-variable relation
public operator fun Symbol.plus(other: Symbol): LabeledPolynomial<C> =
if (this == other) LabeledPolynomial<C>(mapOf(
mapOf(this to 1U) to constantOne * 2
@ -479,9 +453,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
else LabeledPolynomial<C>(mapOf(
mapOf(this to 1U, other to 1U) to constantOne,
))
// endregion
// region Symbol-polynomial relation
public operator fun Symbol.plus(other: LabeledPolynomial<C>): LabeledPolynomial<C> =
with(other.coefficients) {
if (isEmpty()) LabeledPolynomial<C>(mapOf(mapOf(this@plus to 1u) to constantOne))
@ -519,9 +491,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
other.coefficients
.mapKeys { (degs, _) -> degs.toMutableMap().also{ it[this] = if (this in it) it[this]!! + 1U else 1U } }
)
// endregion
// region Polynomial-variable relation
public operator fun LabeledPolynomial<C>.plus(other: Symbol): LabeledPolynomial<C> =
with(coefficients) {
if (isEmpty()) LabeledPolynomial<C>(mapOf(mapOf(other to 1u) to constantOne))
@ -557,9 +527,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
coefficients
.mapKeys { (degs, _) -> degs.toMutableMap().also{ it[other] = if (other in it) it[other]!! + 1U else 1U } }
)
// endregion
// region Polynomial-polynomial relation
/**
* Returns negation of the polynomial.
*/
@ -626,10 +594,7 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
else -> coefficients.size == other.coefficients.size &&
coefficients.all { (key, value) -> with(other.coefficients) { key in this && this[key] == value } }
}
// endregion
// Not sure is it necessary...
// region Polynomial properties
/**
* Degree of the polynomial, [see also](https://en.wikipedia.org/wiki/Degree_of_a_polynomial). If the polynomial is
* zero, degree is -1.
@ -713,10 +678,8 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
// @Suppress("NOTHING_TO_INLINE")
// @JvmName("invokePolynomial")
// public inline operator fun LabeledPolynomial<C>.invoke(argument: Map<Symbol, LabeledPolynomial<C>>): LabeledPolynomial<C> = this.substitute(ring, argument)
// endregion
// region Utilities
// TODO: Move to region internal utilities with context receiver
// TODO: Move to other internal utilities with context receiver
@JvmName("applyAndRemoveZerosInternal")
internal fun MutableMap<Map<Symbol, UInt>, C>.applyAndRemoveZeros(block: MutableMap<Map<Symbol, UInt>, C>.() -> Unit) : MutableMap<Map<Symbol, UInt>, C> {
contract {
@ -744,5 +707,4 @@ public class LabeledPolynomialSpace<C, A : Ring<C>>(
for ((degs, c) in this) if (c.isZero()) this.remove(degs)
}
}
// endregion
}

View File

@ -17,8 +17,6 @@ public class LabeledRationalFunction<C>(
override fun toString(): String = "LabeledRationalFunction${numerator.coefficients}/${denominator.coefficients}"
}
// region Internal utilities
/**
* Represents internal [LabeledRationalFunction] errors.
*/
@ -34,9 +32,6 @@ internal class LabeledRationalFunctionError : Error {
*/
internal fun labeledRationalFunctionError(message: Any): Nothing = throw LabeledRationalFunctionError(message.toString())
// endregion
// region Constructors and converters
// Waiting for context receivers :( TODO: Replace with context receivers when they will be available
//context(RationalFunctionSpace<C, A>)
@ -82,8 +77,6 @@ internal fun labeledRationalFunctionError(message: Any): Nothing = throw Labeled
//LabeledPolynomial(numeratorCoefficients)
//)
// endregion
public class LabeledRationalFunctionSpace<C, A: Ring<C>>(
public val ring: A,
) : AbstractRationalFunctionalSpaceOverPolynomialSpace<
@ -95,7 +88,6 @@ public class LabeledRationalFunctionSpace<C, A: Ring<C>>(
override val polynomialRing : LabeledPolynomialSpace<C, A> = LabeledPolynomialSpace(ring)
// region Rational-integer relation
/**
* Returns sum of the rational function and the integer represented as rational function.
*
@ -126,9 +118,7 @@ public class LabeledRationalFunctionSpace<C, A: Ring<C>>(
numerator * other,
denominator
)
// endregion
// region Integer-Rational relation
/**
* Returns sum of the integer represented as rational function and the rational function.
*
@ -159,9 +149,7 @@ public class LabeledRationalFunctionSpace<C, A: Ring<C>>(
this * other.numerator,
other.denominator
)
// endregion
// region Constant-rational relation
/**
* Returns sum of the constant represented as rational function and the rational function.
*/
@ -186,9 +174,7 @@ public class LabeledRationalFunctionSpace<C, A: Ring<C>>(
this * other.numerator,
other.denominator
)
// endregion
// region Rational-constant relation
/**
* Returns sum of the constant represented as rational function and the rational function.
*/
@ -213,9 +199,7 @@ public class LabeledRationalFunctionSpace<C, A: Ring<C>>(
numerator * other,
denominator
)
// endregion
// region Polynomial-rational relation
/**
* Returns sum of the polynomial represented as rational function and the rational function.
*/
@ -240,9 +224,7 @@ public class LabeledRationalFunctionSpace<C, A: Ring<C>>(
this * other.numerator,
other.denominator
)
// endregion
// region Rational-polynomial relation
/**
* Returns sum of the polynomial represented as rational function and the rational function.
*/
@ -267,9 +249,7 @@ public class LabeledRationalFunctionSpace<C, A: Ring<C>>(
numerator * other,
denominator
)
// endregion
// region Rational-rational relation
/**
* Returns negation of the rational function.
*/
@ -329,9 +309,7 @@ public class LabeledRationalFunctionSpace<C, A: Ring<C>>(
return numerator * other.denominator equalsTo other.numerator * denominator
}
// endregion
// region Polynomial properties
/**
* Map that associates variables (that appear in the polynomial in positive exponents) with their most exponents
* in which they are appeared in the polynomial.
@ -348,9 +326,7 @@ public class LabeledRationalFunctionSpace<C, A: Ring<C>>(
* Count of all variables that appear in the polynomial in positive exponents.
*/
public val LabeledPolynomial<C>.countOfVariables: Int get() = polynomialRing { countOfVariables }
// endregion
// region Rational properties
/**
* Count of all variables that appear in the polynomial in positive exponents.
*/
@ -360,9 +336,8 @@ public class LabeledRationalFunctionSpace<C, A: Ring<C>>(
* Count of all variables that appear in the polynomial in positive exponents.
*/
public val LabeledRationalFunction<C>.countOfVariables: Int get() = variables.size
// endregion
// region REST TODO: Разобрать
// TODO: Разобрать
public operator fun LabeledRationalFunction<C>.div(other: LabeledRationalFunction<C>): LabeledRationalFunction<C> =
LabeledRationalFunction(

View File

@ -47,8 +47,6 @@ internal constructor(
override fun toString(): String = "NumberedPolynomial$coefficients"
}
// region Internal utilities
/**
* Represents internal [Polynomial] errors.
*/
@ -69,10 +67,6 @@ internal fun numberedPolynomialError(message: Any): Nothing = throw PolynomialEr
*/
internal fun List<UInt>.cleanUp() = subList(0, indexOfLast { it != 0U } + 1)
// endregion
// region Constructors and converters
//context(NumberedPolynomialSpace<C, Ring<C>>)
//@Suppress("FunctionName")
//internal fun <C> NumberedPolynomial(coefs: Map<List<UInt>, C>, toCheckInput: Boolean = false) : NumberedPolynomial<C> {
@ -124,8 +118,6 @@ internal fun List<UInt>.cleanUp() = subList(0, indexOfLast { it != 0U } + 1)
public fun <C> C.asNumberedPolynomial() : NumberedPolynomial<C> = NumberedPolynomial(mapOf(emptyList<UInt>() to this))
// endregion
/**
* Space of polynomials.
*
@ -136,7 +128,6 @@ public fun <C> C.asNumberedPolynomial() : NumberedPolynomial<C> = NumberedPolyno
public open class NumberedPolynomialSpace<C, A : Ring<C>>(
public final override val ring: A,
) : AbstractPolynomialSpaceOverRing<C, NumberedPolynomial<C>, A> {
// region Polynomial-integer relation
/**
* Returns sum of the polynomial and the integer represented as polynomial.
*
@ -190,9 +181,7 @@ public open class NumberedPolynomialSpace<C, A : Ring<C>>(
mapValues { (_, c) -> c * other }
}
)
// endregion
// region Integer-polynomial relation
/**
* Returns sum of the integer represented as polynomial and the polynomial.
*
@ -246,9 +235,7 @@ public open class NumberedPolynomialSpace<C, A : Ring<C>>(
mapValues { (_, c) -> this@times * c }
}
)
// endregion
// region Constant-polynomial relation
/**
* Returns sum of the constant represented as polynomial and the polynomial.
*/
@ -300,9 +287,7 @@ public open class NumberedPolynomialSpace<C, A : Ring<C>>(
mapValues { (_, c) -> this@times * c }
}
)
// endregion
// region Polynomial-constant relation
/**
* Returns sum of the constant represented as polynomial and the polynomial.
*/
@ -352,9 +337,7 @@ public open class NumberedPolynomialSpace<C, A : Ring<C>>(
mapValues { (_, c) -> c * other }
}
)
// endregion
// region Polynomial-polynomial relation
/**
* Returns negation of the polynomial.
*/
@ -463,10 +446,7 @@ public open class NumberedPolynomialSpace<C, A : Ring<C>>(
else -> coefficients.size == other.coefficients.size &&
coefficients.all { (key, value) -> with(other.coefficients) { key in this && this[key] == value } }
}
// endregion
// Not sure is it necessary...
// region Polynomial properties
// TODO: Replace `countOfVariables` with `lastVariable` and create new `countOfVariables`
/**
* Count of all variables that appear in the polynomial in positive exponents.
@ -545,10 +525,8 @@ public open class NumberedPolynomialSpace<C, A : Ring<C>>(
@Suppress("NOTHING_TO_INLINE")
@JvmName("invokePolynomial")
public inline operator fun NumberedPolynomial<C>.invoke(argument: Map<Int, NumberedPolynomial<C>>): NumberedPolynomial<C> = this.substitute(ring, argument)
// endregion
// region Utilities
// TODO: Move to region internal utilities with context receiver
// TODO: Move to other internal utilities with context receiver
@JvmName("applyAndRemoveZerosInternal")
internal fun MutableMap<List<UInt>, C>.applyAndRemoveZeros(block: MutableMap<List<UInt>, C>.() -> Unit) : MutableMap<List<UInt>, C> {
contract {
@ -576,9 +554,6 @@ public open class NumberedPolynomialSpace<C, A : Ring<C>>(
for ((degs, c) in this) if (c.isZero()) this.remove(degs)
}
}
// endregion
// region Constructors and converters
@Suppress("FunctionName")
internal fun NumberedPolynomial(coefs: Map<List<UInt>, C>, toCheckInput: Boolean = false) : NumberedPolynomial<C> {
@ -622,6 +597,4 @@ public open class NumberedPolynomialSpace<C, A : Ring<C>>(
@Suppress("FunctionName")
public fun NumberedPolynomial(vararg pairs: Pair<List<UInt>, C>) : NumberedPolynomial<C> = NumberedPolynomial(pairs.toList(), toCheckInput = true)
// endregion
}

View File

@ -16,8 +16,6 @@ public class NumberedRationalFunction<C> internal constructor(
override fun toString(): String = "NumberedRationalFunction${numerator.coefficients}/${denominator.coefficients}"
}
// region Internal utilities
/**
* Represents internal [NumberedRationalFunction] errors.
*/
@ -33,9 +31,6 @@ internal class NumberedRationalFunctionError : Error {
*/
internal fun numberedRationalFunctionError(message: Any): Nothing = throw NumberedRationalFunctionError(message.toString())
// endregion
// region Constructors and converters
// Waiting for context receivers :( TODO: Replace with context receivers when they will be available
//context(RationalFunctionSpace<C, A>)
@ -78,8 +73,6 @@ internal fun numberedRationalFunctionError(message: Any): Nothing = throw Number
//Polynomial(numeratorCoefficients)
//)
// endregion
public class NumberedRationalFunctionSpace<C, A: Ring<C>> (
public val ring: A,
) : AbstractRationalFunctionalSpaceOverPolynomialSpace<
@ -91,7 +84,6 @@ public class NumberedRationalFunctionSpace<C, A: Ring<C>> (
override val polynomialRing : NumberedPolynomialSpace<C, A> = NumberedPolynomialSpace(ring)
// region Rational-integer relation
/**
* Returns sum of the rational function and the integer represented as rational function.
*
@ -122,9 +114,7 @@ public class NumberedRationalFunctionSpace<C, A: Ring<C>> (
numerator * other,
denominator
)
// endregion
// region Integer-Rational relation
/**
* Returns sum of the integer represented as rational function and the rational function.
*
@ -155,9 +145,7 @@ public class NumberedRationalFunctionSpace<C, A: Ring<C>> (
this * other.numerator,
other.denominator
)
// endregion
// region Constant-rational relation
/**
* Returns sum of the constant represented as rational function and the rational function.
*/
@ -182,9 +170,7 @@ public class NumberedRationalFunctionSpace<C, A: Ring<C>> (
this * other.numerator,
other.denominator
)
// endregion
// region Rational-constant relation
/**
* Returns sum of the constant represented as rational function and the rational function.
*/
@ -209,9 +195,7 @@ public class NumberedRationalFunctionSpace<C, A: Ring<C>> (
numerator * other,
denominator
)
// endregion
// region Polynomial-rational relation
/**
* Returns sum of the polynomial represented as rational function and the rational function.
*/
@ -236,9 +220,7 @@ public class NumberedRationalFunctionSpace<C, A: Ring<C>> (
this * other.numerator,
other.denominator
)
// endregion
// region Rational-polynomial relation
/**
* Returns sum of the polynomial represented as rational function and the rational function.
*/
@ -263,9 +245,7 @@ public class NumberedRationalFunctionSpace<C, A: Ring<C>> (
numerator * other,
denominator
)
// endregion
// region Rational-rational relation
/**
* Returns negation of the rational function.
*/
@ -325,9 +305,7 @@ public class NumberedRationalFunctionSpace<C, A: Ring<C>> (
return numerator * other.denominator equalsTo other.numerator * denominator
}
// endregion
// region Polynomial properties
/**
* Count of all variables that appear in the polynomial in positive exponents.
*/
@ -340,17 +318,14 @@ public class NumberedRationalFunctionSpace<C, A: Ring<C>> (
* And size of the list is [countOfVariables].
*/
public val NumberedPolynomial<C>.degrees: List<UInt> get() = polynomialRing { degrees }
// endregion
// region Rational properties
/**
* Count of all variables that appear in the polynomial in positive exponents.
*/
public val NumberedRationalFunction<C>.countOfVariables: Int
get() = polynomialRing { max(numerator.countOfVariables, denominator.countOfVariables) }
// endregion
// region REST TODO: Разобрать
// TODO: Разобрать
public operator fun NumberedRationalFunction<C>.div(other: NumberedRationalFunction<C>): NumberedRationalFunction<C> =
NumberedRationalFunction(

View File

@ -91,7 +91,6 @@ public fun <C> C.asPolynomial() : Polynomial<C> = Polynomial(listOf(this))
* @param A type of underlying ring of constants. It's [Ring] of [C].
* @param ring underlying ring of constants of type [A].
*/
//@Suppress("INAPPLICABLE_JVM_NAME") // TODO: KT-31420
public open class PolynomialSpace<C, A : Ring<C>>(
public override val ring: A,
) : AbstractPolynomialSpaceOverRing<C, Polynomial<C>, A> {

View File

@ -18,8 +18,6 @@ public data class RationalFunction<C> internal constructor (
override fun toString(): String = "RationalFunction${numerator.coefficients}/${denominator.coefficients}"
}
// region Internal utilities
/**
* Represents internal [RationalFunction] errors.
*/
@ -35,9 +33,6 @@ internal class RationalFunctionError : Error {
*/
internal fun rationalFunctionError(message: Any): Nothing = throw RationalFunctionError(message.toString())
// endregion
// region Constructors and converters
// Waiting for context receivers :( TODO: Replace with context receivers when they will be available
//context(RationalFunctionSpace<C, A>)
@ -63,8 +58,6 @@ internal fun rationalFunctionError(message: Any): Nothing = throw RationalFuncti
// Polynomial( with(numeratorCoefficients) { if (reverse) reversed() else this } )
// )
// endregion
public class RationalFunctionSpace<C, A : Ring<C>> (
public val ring: A,
) : AbstractRationalFunctionalSpaceOverPolynomialSpace<
@ -76,7 +69,6 @@ public class RationalFunctionSpace<C, A : Ring<C>> (
override val polynomialRing : PolynomialSpace<C, A> = PolynomialSpace(ring)
// region Rational-integer relation
/**
* Returns sum of the rational function and the integer represented as rational function.
*
@ -107,9 +99,7 @@ public class RationalFunctionSpace<C, A : Ring<C>> (
numerator * other,
denominator
)
// endregion
// region Integer-Rational relation
/**
* Returns sum of the integer represented as rational function and the rational function.
*
@ -140,9 +130,7 @@ public class RationalFunctionSpace<C, A : Ring<C>> (
this * other.numerator,
other.denominator
)
// endregion
// region Constant-rational relation
/**
* Returns sum of the constant represented as rational function and the rational function.
*/
@ -167,9 +155,7 @@ public class RationalFunctionSpace<C, A : Ring<C>> (
this * other.numerator,
other.denominator
)
// endregion
// region Rational-constant relation
/**
* Returns sum of the constant represented as rational function and the rational function.
*/
@ -194,9 +180,7 @@ public class RationalFunctionSpace<C, A : Ring<C>> (
numerator * other,
denominator
)
// endregion
// region Polynomial-rational relation
/**
* Returns sum of the polynomial represented as rational function and the rational function.
*/
@ -221,9 +205,7 @@ public class RationalFunctionSpace<C, A : Ring<C>> (
this * other.numerator,
other.denominator
)
// endregion
// region Rational-polynomial relation
/**
* Returns sum of the polynomial represented as rational function and the rational function.
*/
@ -248,9 +230,7 @@ public class RationalFunctionSpace<C, A : Ring<C>> (
numerator * other,
denominator
)
// endregion
// region Rational-rational relation
/**
* Returns negation of the rational function.
*/
@ -298,9 +278,8 @@ public class RationalFunctionSpace<C, A : Ring<C>> (
numeratorDegree - denominatorDegree != with(other) { numeratorDegree - denominatorDegree } -> false
else -> numerator * other.denominator equalsTo other.numerator * denominator
}
// endregion
// region REST TODO: Разобрать
// TODO: Разобрать
public operator fun RationalFunction<C>.div(other: RationalFunction<C>): RationalFunction<C> =
RationalFunction(
@ -383,5 +362,4 @@ public class RationalFunctionSpace<C, A : Ring<C>> (
// numerator.removeZeros(),
// denominator.removeZeros()
// )
// endregion
}

View File

@ -17,10 +17,6 @@ import kotlin.contracts.contract
// TODO: Docs
// region Sort of legacy
//// region Constants
//
//// TODO: Reuse underlying ring extensions
//
//context(LabeledPolynomialSpace<C, A>)
@ -33,9 +29,7 @@ import kotlin.contracts.contract
//context(LabeledPolynomialSpace<C, A>)
//fun <C, A: Ring<C>> multiplyWithPower(base: C, arg: C, pow: UInt): C = ring { multiplyWithPower<C>(base, arg, pow) }
//
//// endregion
//// region Symbols
//
//context(LabeledPolynomialSpace<C, A>)
//fun <C, A: Ring<C>> power(arg: Symbol, pow: UInt): LabeledPolynomial<C> =
@ -44,9 +38,7 @@ import kotlin.contracts.contract
// mapOf(arg to pow) to constantOne
// ))
//
//// endregion
//// region Polynomials
//
//context(LabeledPolynomialSpace<C, A>)
//fun <C, A: Ring<C>> number(value: Int): LabeledPolynomial<C> = ring { LabeledPolynomial<C>(mapOf(emptyMap<Symbol, UInt>() to number<C>(value))) }
@ -71,11 +63,6 @@ import kotlin.contracts.contract
// else -> error("Error in raising ring instant by unsigned integer: got reminder by division by 2 different from 0 and 1")
// }
//
//// endregion
// endregion
// region Utilities
/**
* Crates a [LabeledPolynomialSpace] over received ring.
@ -92,10 +79,6 @@ public inline fun <C, A : Ring<C>, R> A.labeledPolynomial(block: LabeledPolynomi
return LabeledPolynomialSpace(this).block()
}
// endregion
//// region String representations
//
///**
// * Represents the polynomial as a [String] with names of variables substituted with names from [names].
// * Consider that monomials are sorted in lexicographic order.
@ -261,13 +244,7 @@ public inline fun <C, A : Ring<C>, R> A.labeledPolynomial(block: LabeledPolynomi
//context(LabeledPolynomialSpace<C, A>)
//fun <C, A: Ring<C>> LabeledPolynomial<C>.representReversedWithBrackets(namer: (Symbol) -> String): String =
// with(representReversed(namer)) { if (coefficients.count() == 1) this else "($this)" }
//
//// endregion
// region Operator extensions
//// region Field case
//
//operator fun <T: Field<T>> Polynomial<T>.div(other: T): Polynomial<T> =
// if (other.isZero()) throw ArithmeticException("/ by zero")
// else
@ -276,13 +253,7 @@ public inline fun <C, A : Ring<C>, R> A.labeledPolynomial(block: LabeledPolynomi
// .mapValues { it.value / other },
// toCheckInput = false
// )
//
//// endregion
// endregion
//// region Polynomial substitution and functional representation
//
//public fun <C> LabeledPolynomial<C>.substitute(ring: Ring<C>, args: Map<Symbol, C>): LabeledPolynomial<C> = ring {
// if (coefficients.isEmpty()) return this@substitute
// LabeledPolynomial<C>(
@ -324,10 +295,6 @@ public inline fun <C, A : Ring<C>, R> A.labeledPolynomial(block: LabeledPolynomi
//
//fun <C, A : Ring<C>> LabeledPolynomial<C>.asPolynomialFunctionOver(ring: A): (Map<Symbol, LabeledPolynomial<C>>) -> LabeledPolynomial<C> =
// { substitute(ring, it) }
//
//// endregion
// region Algebraic derivative and antiderivative
/**
* Returns algebraic derivative of received polynomial.
@ -573,5 +540,3 @@ public fun <C, A : Field<C>> LabeledPolynomial<C>.nthAntiderivativeWithRespectTo
}
)
}
// endregion

View File

@ -6,10 +6,6 @@
package space.kscience.kmath.functions
//// region Operator extensions
//
//// region Field case
//
//fun <T: Field<T>> LabeledRationalFunction<T>.reduced(): LabeledRationalFunction<T> {
// val greatestCommonDivider = polynomialGCD(numerator, denominator)
// return LabeledRationalFunction(
@ -17,7 +13,3 @@ package space.kscience.kmath.functions
// denominator / greatestCommonDivider
// )
//}
//
//// endregion
//
//// endregion

View File

@ -9,10 +9,6 @@ import kotlin.math.max
// TODO: Docs
// region Sort of legacy
//// region Constants
//
//// TODO: Reuse underlying ring extensions
//
//context(NumberedPolynomialSpace<C, A>)
@ -21,11 +17,7 @@ import kotlin.math.max
//
//context(NumberedPolynomialSpace<C, A>)
//public fun <C, A: Ring<C>> multiplyWithPower(base: C, arg: C, pow: UInt): C = ring { multiplyWithPower<C>(base, arg, pow) }
//
//// endregion
//// region Polynomials
//
//context(NumberedPolynomialSpace<C, A>)
//public fun <C, A: Ring<C>> number(value: Int): NumberedPolynomial<C> = ring { NumberedPolynomial<C>(mapOf(emptyList<UInt>() to number<C>(value))) }
//
@ -48,12 +40,6 @@ import kotlin.math.max
// exponent % 2U == 1U -> multiplyWithPowerInternalLogic(base * arg, arg * arg, exponent / 2U)
// else -> error("Error in raising ring instant by unsigned integer: got reminder by division by 2 different from 0 and 1")
// }
//
//// endregion
// endregion
// region Utilities
/**
* Crates a [NumberedPolynomialSpace] over received ring.
@ -70,10 +56,6 @@ public inline fun <C, A : Ring<C>, R> A.numberedPolynomial(block: NumberedPolyno
return NumberedPolynomialSpace(this).block()
}
// endregion
//// region String representations
//
///**
// * Represents the polynomial as a [String] where name of variable with index `i` is [withVariableName] + `"_${i+1}"`.
// * Consider that monomials are sorted in lexicographic order.
@ -237,11 +219,7 @@ public inline fun <C, A : Ring<C>, R> A.numberedPolynomial(block: NumberedPolyno
//context(NumberedPolynomialSpace<C, A>)
//public fun <C, A: Ring<C>> NumberedPolynomial<C>.representReversedWithBrackets(namer: (Int) -> String): String =
// with(representReversed(namer)) { if (coefficients.count() == 1) this else "($this)" }
//
//// endregion
//// region Polynomial substitution and functional representation
//
//public fun <C> NumberedPolynomial<C>.substitute(ring: Ring<C>, args: Map<Int, C>): NumberedPolynomial<C> = ring {
// if (coefficients.isEmpty()) return this@substitute
// NumberedPolynomial<C>(
@ -283,13 +261,7 @@ public inline fun <C, A : Ring<C>, R> A.numberedPolynomial(block: NumberedPolyno
//
//public fun <C, A : Ring<C>> NumberedPolynomial<C>.asPolynomialFunctionOver(ring: A): (Map<Int, NumberedPolynomial<C>>) -> NumberedPolynomial<C> =
// { substitute(ring, it) }
//
//// endregion
// region Operator extensions
//// region Field case
//
//operator fun <T: Field<T>> Polynomial<T>.div(other: T): Polynomial<T> =
// if (other.isZero()) throw ArithmeticException("/ by zero")
// else
@ -298,12 +270,6 @@ public inline fun <C, A : Ring<C>, R> A.numberedPolynomial(block: NumberedPolyno
// .mapValues { it.value / other },
// toCheckInput = false
// )
//
//// endregion
// endregion
// region Polynomial substitution and functional representation
// TODO: May be apply Horner's method too?
/**
@ -368,10 +334,6 @@ public fun <C, A : Ring<C>> NumberedPolynomial<C>.asFunction(ring: A): (Map<Int,
*/
public fun <C, A : Ring<C>> NumberedPolynomial<C>.asPolynomialFunctionOver(ring: A): (Map<Int, NumberedPolynomial<C>>) -> NumberedPolynomial<C> = { substitute(ring, it) }
// endregion
// region Algebraic derivative and antiderivative
/**
* Returns algebraic derivative of received polynomial.
*/
@ -597,5 +559,3 @@ public fun <C, A : Field<C>> NumberedPolynomial<C>.nthAntiderivativeWithRespectT
}
)
}
// endregion

View File

@ -6,10 +6,6 @@
package space.kscience.kmath.functions
//// region Operator extensions
//
//// region Field case
//
//fun <T: Field<T>> NumberedRationalFunction<T>.reduced(): NumberedRationalFunction<T> {
// val greatestCommonDivider = polynomialGCD(numerator, denominator)
// return NumberedRationalFunction(
@ -17,7 +13,3 @@ package space.kscience.kmath.functions
// denominator / greatestCommonDivider
// )
//}
//
//// endregion
//
//// endregion

View File

@ -14,8 +14,6 @@ import kotlin.math.min
import kotlin.math.pow
// region Utilities
/**
* Removes zeros on the end of the coefficient list of polynomial.
*/
@ -51,10 +49,6 @@ public inline fun <C, A, R> A.scalablePolynomial(block: ScalablePolynomialSpace<
return ScalablePolynomialSpace(this).block()
}
// endregion
// region Polynomial substitution and functional representation
// TODO: May be apply Horner's method too?
/**
* Evaluates the value of the given double polynomial for given double argument.
@ -116,10 +110,6 @@ public fun <C, A : Ring<C>> Polynomial<C>.asFunction(ring: A): (C) -> C = { subs
*/
public fun <C, A : Ring<C>> Polynomial<C>.asPolynomialFunctionOver(ring: A): (Polynomial<C>) -> Polynomial<C> = { substitute(ring, it) }
// endregion
// region Algebraic derivative and antiderivative
/**
* Returns algebraic derivative of received polynomial.
*/
@ -181,5 +171,3 @@ public fun <C : Comparable<C>> Polynomial<C>.integrate(
val integral = antiderivative(algebra)
integral.substitute(algebra, range.endInclusive) - integral.substitute(algebra, range.start)
}
// endregion

View File

@ -6,10 +6,6 @@
package space.kscience.kmath.functions
// region Operator extensions
// region Field case
//operator fun <T: Field<T>> RationalFunction<T>.invoke(arg: T): T = numerator(arg) / denominator(arg)
//
//fun <T: Field<T>> RationalFunction<T>.reduced(): RationalFunction<T> =
@ -20,11 +16,6 @@ package space.kscience.kmath.functions
// )
// }
// endregion
// endregion
// region Derivatives
///**
// * Returns result of applying formal derivative to the polynomial.
// *
@ -36,4 +27,3 @@ package space.kscience.kmath.functions
// numerator.derivative() * denominator - denominator.derivative() * numerator,
// denominator * denominator
// )
// endregion