From 2082175af5e9e811d3a6dfa3079a7dcb2d25a2fe Mon Sep 17 00:00:00 2001 From: Gleb Minaev <43728100+lounres@users.noreply.github.com> Date: Wed, 16 Mar 2022 23:31:07 +0300 Subject: [PATCH] Fixed typos. --- .../kmath/functions/LabeledPolynomial.kt | 2 +- .../space/kscience/kmath/functions/Polynomial.kt | 2 +- .../kscience/kmath/functions/RationalFunction.kt | 5 +---- .../kmath/functions/labeledPolynomialUtil.kt | 4 ++-- .../kmath/functions/numberedPolynomialUtil.kt | 16 ++++++++-------- .../kscience/kmath/functions/polynomialUtil.kt | 8 ++++---- 6 files changed, 17 insertions(+), 20 deletions(-) diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/LabeledPolynomial.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/LabeledPolynomial.kt index d263b7102..369c7078a 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/LabeledPolynomial.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/LabeledPolynomial.kt @@ -49,7 +49,7 @@ internal constructor( } /** - * Returns the same degrees description of the monomial, but without zero degrees. + * Returns the same degrees' description of the monomial, but without zero degrees. */ internal fun Map.cleanUp() = filterValues { it > 0U } diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt index c6f649fe8..220bde8ff 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt @@ -425,7 +425,7 @@ public open class PolynomialSpace>( public inline fun Polynomial.asFunctionOnPolynomials(): (Polynomial) -> Polynomial = { this.substitute(ring, it) } /** - * Evaluates the polynomial for the given value [arg]. + * Evaluates the polynomial for the given value [argument]. */ @Suppress("NOTHING_TO_INLINE") public inline operator fun Polynomial.invoke(argument: C): C = this.substitute(ring, argument) diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/RationalFunction.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/RationalFunction.kt index f4ae64e81..226eddce9 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/RationalFunction.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/RationalFunction.kt @@ -5,10 +5,7 @@ package space.kscience.kmath.functions -import space.kscience.kmath.operations.* -import kotlin.jvm.JvmName -import kotlin.math.max -import kotlin.math.min +import space.kscience.kmath.operations.Ring public data class RationalFunction internal constructor ( diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/labeledPolynomialUtil.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/labeledPolynomialUtil.kt index 19417d767..27fdd7d7b 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/labeledPolynomialUtil.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/labeledPolynomialUtil.kt @@ -65,13 +65,13 @@ import kotlin.contracts.contract // /** - * Crates a [LabeledPolynomialSpace] over received ring. + * Creates a [LabeledPolynomialSpace] over a received ring. */ public fun > A.labeledPolynomial(): LabeledPolynomialSpace = LabeledPolynomialSpace(this) /** - * Crates a [LabeledPolynomialSpace]'s scope over received ring. + * Creates a [LabeledPolynomialSpace]'s scope over a received ring. */ @OptIn(ExperimentalContracts::class) public inline fun , R> A.labeledPolynomial(block: LabeledPolynomialSpace.() -> R): R { diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/numberedPolynomialUtil.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/numberedPolynomialUtil.kt index b2778343d..d544ca93c 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/numberedPolynomialUtil.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/numberedPolynomialUtil.kt @@ -42,13 +42,13 @@ import kotlin.math.max // } /** - * Crates a [NumberedPolynomialSpace] over received ring. + * Creates a [NumberedPolynomialSpace] over a received ring. */ public fun > A.numberedPolynomial(): NumberedPolynomialSpace = NumberedPolynomialSpace(this) /** - * Crates a [NumberedPolynomialSpace]'s scope over received ring. + * Creates a [NumberedPolynomialSpace]'s scope over a received ring. */ @OptIn(ExperimentalContracts::class) public inline fun , R> A.numberedPolynomial(block: NumberedPolynomialSpace.() -> R): R { @@ -279,9 +279,9 @@ public fun NumberedPolynomial.substitute(args: Map): Number val acc = LinkedHashMap, Double>(coefficients.size) for ((degs, c) in coefficients) { val newDegs = degs.mapIndexed { index, deg -> if (index !in args) deg else 0u }.cleanUp() - val newC = args.entries.fold(c) { product, (variable, substitutor) -> + val newC = args.entries.fold(c) { product, (variable, substitution) -> val deg = degs.getOrElse(variable) { 0u } - if (deg == 0u) product else product * substitutor.pow(deg.toInt()) + if (deg == 0u) product else product * substitution.pow(deg.toInt()) } if (newDegs !in acc) acc[newDegs] = newC else acc[newDegs] = acc[newDegs]!! + newC @@ -298,9 +298,9 @@ public fun NumberedPolynomial.substitute(ring: Ring, args: Map val acc = LinkedHashMap, C>(coefficients.size) for ((degs, c) in coefficients) { val newDegs = degs.mapIndexed { index, deg -> if (index !in args) deg else 0u }.cleanUp() - val newC = args.entries.fold(c) { product, (variable, substitutor) -> + val newC = args.entries.fold(c) { product, (variable, substitution) -> val deg = degs.getOrElse(variable) { 0u } - if (deg == 0u) product else product * power(substitutor, deg) + if (deg == 0u) product else product * power(substitution, deg) } if (newDegs !in acc) acc[newDegs] = newC else acc[newDegs] = acc[newDegs]!! + newC @@ -315,9 +315,9 @@ public fun NumberedPolynomial.substitute(ring: Ring, args: Map, NumberedPolynomial>(coefficients.size) for ((degs, c) in coefficients) { val newDegs = degs.mapIndexed { index, deg -> if (index !in args) deg else 0u }.cleanUp() - val newC = args.entries.fold(c.asNumberedPolynomial()) { product, (variable, substitutor) -> + val newC = args.entries.fold(c.asNumberedPolynomial()) { product, (variable, substitution) -> val deg = degs.getOrElse(variable) { 0u } - if (deg == 0u) product else product * power(substitutor, deg) + if (deg == 0u) product else product * power(substitution, deg) } if (newDegs !in acc) acc[newDegs] = c.asNumberedPolynomial() else acc[newDegs] = acc[newDegs]!! + c diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/polynomialUtil.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/polynomialUtil.kt index e6d6b1ae6..a0c11b0a8 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/polynomialUtil.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/polynomialUtil.kt @@ -22,13 +22,13 @@ import kotlin.math.pow // if (degree > -1) Polynomial(coefficients.subList(0, degree + 1)) else zero /** - * Crates a [PolynomialSpace] over received ring. + * Creates a [PolynomialSpace] over a received ring. */ public fun > A.polynomial(): PolynomialSpace = PolynomialSpace(this) /** - * Crates a [PolynomialSpace]'s scope over received ring. + * Creates a [PolynomialSpace]'s scope over a received ring. */ public inline fun , R> A.polynomial(block: PolynomialSpace.() -> R): R { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) } @@ -36,13 +36,13 @@ public inline fun , R> A.polynomial(block: PolynomialSpace. } /** - * Crates a [ScalablePolynomialSpace] over received scalable ring. + * Creates a [ScalablePolynomialSpace] over a received scalable ring. */ public fun A.scalablePolynomial(): ScalablePolynomialSpace where A : Ring, A : ScaleOperations = ScalablePolynomialSpace(this) /** - * Crates a [ScalablePolynomialSpace]'s scope over received scalable ring. + * Creates a [ScalablePolynomialSpace]'s scope over a received scalable ring. */ public inline fun A.scalablePolynomial(block: ScalablePolynomialSpace.() -> R): R where A : Ring, A : ScaleOperations { contract { callsInPlace(block, InvocationKind.EXACTLY_ONCE) }