Processed labeledRationalFunctionUtil.kt
This commit is contained in:
parent
dd820da765
commit
44febbdd73
@ -6,7 +6,6 @@
|
|||||||
package space.kscience.kmath.functions
|
package space.kscience.kmath.functions
|
||||||
|
|
||||||
import space.kscience.kmath.operations.*
|
import space.kscience.kmath.operations.*
|
||||||
import kotlin.jvm.JvmName
|
|
||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
|
@ -1,130 +1,23 @@
|
|||||||
package math.polynomials
|
/*
|
||||||
|
* Copyright 2018-2021 KMath contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
import math.ringsAndFields.*
|
package space.kscience.kmath.functions
|
||||||
import space.kscience.kmath.functions.LabeledRationalFunction
|
|
||||||
|
|
||||||
|
|
||||||
fun <T: Ring<T>> T.toLabeledRationalFunction() = LabeledRationalFunction(this.toLabeledPolynomial())
|
//// region Operator extensions
|
||||||
|
//
|
||||||
// region Operator extensions
|
//// region Field case
|
||||||
|
//
|
||||||
// region Field case
|
//fun <T: Field<T>> LabeledRationalFunction<T>.reduced(): LabeledRationalFunction<T> {
|
||||||
|
// val greatestCommonDivider = polynomialGCD(numerator, denominator)
|
||||||
fun <T: Field<T>> LabeledRationalFunction<T>.reduced(): LabeledRationalFunction<T> {
|
// return LabeledRationalFunction(
|
||||||
val greatestCommonDivider = polynomialGCD(numerator, denominator)
|
// numerator / greatestCommonDivider,
|
||||||
return LabeledRationalFunction(
|
// denominator / greatestCommonDivider
|
||||||
numerator / greatestCommonDivider,
|
// )
|
||||||
denominator / greatestCommonDivider
|
//}
|
||||||
)
|
//
|
||||||
}
|
//// endregion
|
||||||
|
//
|
||||||
// endregion
|
//// endregion
|
||||||
|
|
||||||
// region Constants
|
|
||||||
|
|
||||||
operator fun <T: Ring<T>> T.plus(other: LabeledRationalFunction<T>) = other + this
|
|
||||||
operator fun <T: Ring<T>> Integer.plus(other: LabeledRationalFunction<T>) = other + this
|
|
||||||
operator fun <T: Ring<T>> Int.plus(other: LabeledRationalFunction<T>) = other + this
|
|
||||||
operator fun <T: Ring<T>> Long.plus(other: LabeledRationalFunction<T>) = other + this
|
|
||||||
|
|
||||||
operator fun <T: Ring<T>> T.minus(other: LabeledRationalFunction<T>) = -other + this
|
|
||||||
operator fun <T: Ring<T>> Integer.minus(other: LabeledRationalFunction<T>) = -other + this
|
|
||||||
operator fun <T: Ring<T>> Int.minus(other: LabeledRationalFunction<T>) = -other + this
|
|
||||||
operator fun <T: Ring<T>> Long.minus(other: LabeledRationalFunction<T>) = -other + this
|
|
||||||
|
|
||||||
operator fun <T: Ring<T>> T.times(other: LabeledRationalFunction<T>) = other * this
|
|
||||||
operator fun <T: Ring<T>> Integer.times(other: LabeledRationalFunction<T>) = other * this
|
|
||||||
operator fun <T: Ring<T>> Int.times(other: LabeledRationalFunction<T>) = other * this
|
|
||||||
operator fun <T: Ring<T>> Long.times(other: LabeledRationalFunction<T>) = other * this
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// region Polynomials
|
|
||||||
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.plus(other: UnivariatePolynomial<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator + denominator * other.toLabeledPolynomial(),
|
|
||||||
denominator
|
|
||||||
)
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.plus(other: UnivariateRationalFunction<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator * other.denominator.toLabeledPolynomial() + denominator * other.numerator.toLabeledPolynomial(),
|
|
||||||
denominator * other.denominator.toLabeledPolynomial()
|
|
||||||
)
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.plus(other: Polynomial<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator + denominator * other.toLabeledPolynomial(),
|
|
||||||
denominator
|
|
||||||
)
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.plus(other: NumberedRationalFunction<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator * other.denominator.toLabeledPolynomial() + denominator * other.numerator.toLabeledPolynomial(),
|
|
||||||
denominator * other.denominator.toLabeledPolynomial()
|
|
||||||
)
|
|
||||||
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.minus(other: UnivariatePolynomial<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator - denominator * other.toLabeledPolynomial(),
|
|
||||||
denominator
|
|
||||||
)
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.minus(other: UnivariateRationalFunction<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator * other.denominator.toLabeledPolynomial() - denominator * other.numerator.toLabeledPolynomial(),
|
|
||||||
denominator * other.denominator.toLabeledPolynomial()
|
|
||||||
)
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.minus(other: Polynomial<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator - denominator * other.toLabeledPolynomial(),
|
|
||||||
denominator
|
|
||||||
)
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.minus(other: NumberedRationalFunction<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator * other.denominator.toLabeledPolynomial() - denominator * other.numerator.toLabeledPolynomial(),
|
|
||||||
denominator * other.denominator.toLabeledPolynomial()
|
|
||||||
)
|
|
||||||
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.times(other: UnivariatePolynomial<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator * other.toLabeledPolynomial(),
|
|
||||||
denominator
|
|
||||||
)
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.times(other: UnivariateRationalFunction<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator * other.numerator.toLabeledPolynomial(),
|
|
||||||
denominator * other.denominator.toLabeledPolynomial()
|
|
||||||
)
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.times(other: Polynomial<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator * other.toLabeledPolynomial(),
|
|
||||||
denominator
|
|
||||||
)
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.times(other: NumberedRationalFunction<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator * other.numerator.toLabeledPolynomial(),
|
|
||||||
denominator * other.denominator.toLabeledPolynomial()
|
|
||||||
)
|
|
||||||
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.div(other: UnivariatePolynomial<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator,
|
|
||||||
denominator * other.toLabeledPolynomial()
|
|
||||||
)
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.div(other: UnivariateRationalFunction<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator * other.denominator.toLabeledPolynomial(),
|
|
||||||
denominator * other.numerator.toLabeledPolynomial()
|
|
||||||
)
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.div(other: Polynomial<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator,
|
|
||||||
denominator * other.toLabeledPolynomial()
|
|
||||||
)
|
|
||||||
operator fun <T: Ring<T>> LabeledRationalFunction<T>.div(other: NumberedRationalFunction<T>) =
|
|
||||||
LabeledRationalFunction(
|
|
||||||
numerator * other.denominator.toLabeledPolynomial(),
|
|
||||||
denominator * other.numerator.toLabeledPolynomial()
|
|
||||||
)
|
|
||||||
|
|
||||||
// endregion
|
|
||||||
|
|
||||||
// endregion
|
|
Loading…
Reference in New Issue
Block a user