From 31ccf744c527f59f19a9d90c9da9f73da3fa1ecf Mon Sep 17 00:00:00 2001 From: Gleb Minaev <43728100+lounres@users.noreply.github.com> Date: Mon, 14 Mar 2022 23:33:00 +0300 Subject: [PATCH] Deleted useless annotations `JvmName`, `JsName` and `Suppress` --- .../kmath/functions/AbstractPolynomial.kt | 20 +---------- .../functions/AbstractRationalFunction.kt | 34 ++----------------- .../kmath/functions/LabeledPolynomial.kt | 2 -- .../functions/LabeledRationalFunction.kt | 1 - .../kmath/functions/NumberedPolynomial.kt | 2 -- .../functions/NumberedRationalFunction.kt | 1 - .../kscience/kmath/functions/Polynomial.kt | 3 +- .../kmath/functions/RationalFunction.kt | 1 - .../kmath/functions/numberedPolynomialUtil.kt | 9 ++--- 9 files changed, 9 insertions(+), 64 deletions(-) diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/AbstractPolynomial.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/AbstractPolynomial.kt index 0b16303af..b053ffebd 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/AbstractPolynomial.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/AbstractPolynomial.kt @@ -29,21 +29,18 @@ public interface AbstractPolynomialSpace> : Ring

* * The operation is equivalent to adding [other] copies of unit of underlying ring to [this]. */ - @JvmName("constantIntPlus") public operator fun C.plus(other: Int): C /** * Returns difference between the constant and the integer represented as constant (member of underlying ring). * * The operation is equivalent to subtraction [other] copies of unit of underlying ring from [this]. */ - @JvmName("constantIntMinus") public operator fun C.minus(other: Int): C /** * Returns product of the constant and the integer represented as constant (member of underlying ring). * * The operation is equivalent to sum of [other] copies of [this]. */ - @JvmName("constantIntTimes") public operator fun C.times(other: Int): C // endregion @@ -53,21 +50,18 @@ public interface AbstractPolynomialSpace> : Ring

* * The operation is equivalent to adding [this] copies of unit of underlying ring to [other]. */ - @JvmName("intConstantPlus") public operator fun Int.plus(other: C): C /** * Returns difference between the integer represented as constant (member of underlying ring) and the constant. * * The operation is equivalent to subtraction [this] copies of unit of underlying ring from [other]. */ - @JvmName("intConstantMinus") public operator fun Int.minus(other: C): C /** * Returns product of the integer represented as constant (member of underlying ring) and the constant. * * The operation is equivalent to sum of [this] copies of [other]. */ - @JvmName("intConstantTimes") public operator fun Int.times(other: C): C // endregion @@ -148,32 +142,26 @@ public interface AbstractPolynomialSpace> : Ring

/** * Check if the instant is zero constant. */ - @JvmName("constantIsZero") public fun C.isZero(): Boolean = this == constantZero /** * Check if the instant is NOT zero constant. */ - @JvmName("constantIsNotZero") public fun C.isNotZero(): Boolean = !isZero() /** * Check if the instant is unit constant. */ - @JvmName("constantIsOne") public fun C.isOne(): Boolean = this == constantOne /** * Check if the instant is NOT unit constant. */ - @JvmName("constantIsNotOne") public fun C.isNotOne(): Boolean = !isOne() /** * Check if the instant is minus unit constant. */ - @JvmName("constantIsMinusOne") public fun C.isMinusOne(): Boolean = this == -constantOne /** * Check if the instant is NOT minus unit constant. */ - @JvmName("constantIsNotMinusOne") public fun C.isNotMinusOne(): Boolean = !isMinusOne() /** @@ -330,7 +318,7 @@ public interface AbstractPolynomialSpace> : Ring

* @param C the type of constants. Polynomials have them as a coefficients in their terms. * @param P the type of polynomials. */ -@Suppress("INAPPLICABLE_JVM_NAME", "PARAMETER_NAME_CHANGED_ON_OVERRIDE") +@Suppress("INAPPLICABLE_JVM_NAME") public interface AbstractPolynomialSpaceOverRing, A: Ring> : AbstractPolynomialSpace { public val ring: A @@ -341,21 +329,18 @@ public interface AbstractPolynomialSpaceOverRing, A: * * The operation is equivalent to adding [other] copies of unit of underlying ring to [this]. */ - @JvmName("constantIntPlus") public override operator fun C.plus(other: Int): C = ring { optimizedAddMultiplied(this@plus, one, other) } /** * Returns difference between the constant and the integer represented as constant (member of underlying ring). * * The operation is equivalent to subtraction [other] copies of unit of underlying ring from [this]. */ - @JvmName("constantIntMinus") public override operator fun C.minus(other: Int): C = ring { optimizedAddMultiplied(this@minus, one, -other) } /** * Returns product of the constant and the integer represented as constant (member of underlying ring). * * The operation is equivalent to sum of [other] copies of [this]. */ - @JvmName("constantIntTimes") public override operator fun C.times(other: Int): C = ring { optimizedMultiply(this@times, other) } // endregion @@ -365,21 +350,18 @@ public interface AbstractPolynomialSpaceOverRing, A: * * The operation is equivalent to adding [this] copies of unit of underlying ring to [other]. */ - @JvmName("intConstantPlus") public override operator fun Int.plus(other: C): C = ring { optimizedAddMultiplied(other, one, this@plus) } /** * Returns difference between the integer represented as constant (member of underlying ring) and the constant. * * The operation is equivalent to subtraction [this] copies of unit of underlying ring from [other]. */ - @JvmName("intConstantMinus") public override operator fun Int.minus(other: C): C = ring { optimizedAddMultiplied(-other, one, this@minus) } /** * Returns product of the integer represented as constant (member of underlying ring) and the constant. * * The operation is equivalent to sum of [this] copies of [other]. */ - @JvmName("intConstantTimes") public override operator fun Int.times(other: C): C = ring { optimizedMultiply(other, this@times) } // endregion diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/AbstractRationalFunction.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/AbstractRationalFunction.kt index cf8f3a6ef..f8d3bb99b 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/AbstractRationalFunction.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/AbstractRationalFunction.kt @@ -28,21 +28,18 @@ public interface AbstractRationalFunctionalSpace, R: * * The operation is equivalent to adding [other] copies of unit of underlying ring to [this]. */ - @JvmName("constantIntPlus") public operator fun C.plus(other: Int): C /** * Returns difference between the constant and the integer represented as constant (member of underlying ring). * * The operation is equivalent to subtraction [other] copies of unit of underlying ring from [this]. */ - @JvmName("constantIntMinus") public operator fun C.minus(other: Int): C /** * Returns product of the constant and the integer represented as constant (member of underlying ring). * * The operation is equivalent to sum of [other] copies of [this]. */ - @JvmName("constantIntTimes") public operator fun C.times(other: Int): C // endregion @@ -52,21 +49,18 @@ public interface AbstractRationalFunctionalSpace, R: * * The operation is equivalent to adding [this] copies of unit of underlying ring to [other]. */ - @JvmName("intConstantPlus") public operator fun Int.plus(other: C): C /** * Returns difference between the integer represented as constant (member of underlying ring) and the constant. * * The operation is equivalent to subtraction [this] copies of unit of underlying ring from [other]. */ - @JvmName("intConstantMinus") public operator fun Int.minus(other: C): C /** * Returns product of the integer represented as constant (member of underlying ring) and the constant. * * The operation is equivalent to sum of [this] copies of [other]. */ - @JvmName("intConstantTimes") public operator fun Int.times(other: C): C // endregion @@ -189,32 +183,26 @@ public interface AbstractRationalFunctionalSpace, R: /** * Check if the instant is zero constant. */ - @JvmName("constantIsZero") public fun C.isZero(): Boolean = this == constantZero /** * Check if the instant is NOT zero constant. */ - @JvmName("constantIsNotZero") public fun C.isNotZero(): Boolean = !isZero() /** * Check if the instant is unit constant. */ - @JvmName("constantIsOne") public fun C.isOne(): Boolean = this == constantOne /** * Check if the instant is NOT unit constant. */ - @JvmName("constantIsNotOne") public fun C.isNotOne(): Boolean = !isOne() /** * Check if the instant is minus unit constant. */ - @JvmName("constantIsMinusOne") public fun C.isMinusOne(): Boolean = this == -constantOne /** * Check if the instant is NOT minus unit constant. */ - @JvmName("constantIsNotMinusOne") public fun C.isNotMinusOne(): Boolean = !isMinusOne() /** @@ -520,7 +508,7 @@ public interface AbstractRationalFunctionalSpace, R: // endregion } -@Suppress("INAPPLICABLE_JVM_NAME", "PARAMETER_NAME_CHANGED_ON_OVERRIDE") +@Suppress("INAPPLICABLE_JVM_NAME") public interface AbstractRationalFunctionalSpaceOverRing, R: AbstractRationalFunction, A: Ring> : AbstractRationalFunctionalSpace { public val ring: A @@ -531,21 +519,18 @@ public interface AbstractRationalFunctionalSpaceOverRing, R: AbstractRationalFunction, A: Ring> : AbstractRationalFunctionalSpace { public val polynomialRing: AbstractPolynomialSpace @@ -622,21 +604,18 @@ public interface AbstractRationalFunctionalSpaceOverPolynomialSpace.cleanUp() = filterValues { it > 0U } * @param A the intersection of [Ring] of [C] and [ScaleOperations] of [C]. * @param ring the [A] instance. */ -@Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE", "INAPPLICABLE_JVM_NAME") public class LabeledPolynomialSpace>( public override val ring: A, ) : AbstractPolynomialSpaceOverRing, A> { @@ -768,7 +767,6 @@ public class LabeledPolynomialSpace>( override val one: LabeledPolynomial = LabeledPolynomial(mapOf(emptyMap() to constantOne)) // TODO: Docs - @Suppress("EXTENSION_SHADOWED_BY_MEMBER", "CovariantEquals") override infix fun LabeledPolynomial.equalsTo(other: LabeledPolynomial): Boolean = when { this === other -> true diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/LabeledRationalFunction.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/LabeledRationalFunction.kt index 203c9e07c..2bec1f3a4 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/LabeledRationalFunction.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/LabeledRationalFunction.kt @@ -305,7 +305,6 @@ public class LabeledRationalFunctionSpace>( /** * Checks equality of the rational functions. */ - @Suppress("EXTENSION_SHADOWED_BY_MEMBER", "CovariantEquals") public override infix fun LabeledRationalFunction.equalsTo(other: LabeledRationalFunction): Boolean { if (this === other) return true diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/NumberedPolynomial.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/NumberedPolynomial.kt index 39ca43945..de5cc5658 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/NumberedPolynomial.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/NumberedPolynomial.kt @@ -263,7 +263,6 @@ public fun > C.asNumberedPolynomial() : NumberedPolynomial = Nu * @param A the intersection of [Ring] of [C] and [ScaleOperations] of [C]. * @param ring the [A] instance. */ -@Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE", "INAPPLICABLE_JVM_NAME") public open class NumberedPolynomialSpace>( public final override val ring: A, ) : AbstractPolynomialSpaceOverRing, A> { @@ -532,7 +531,6 @@ public open class NumberedPolynomialSpace>( ) // TODO: Docs - @Suppress("EXTENSION_SHADOWED_BY_MEMBER", "CovariantEquals") override infix fun NumberedPolynomial.equalsTo(other: NumberedPolynomial): Boolean = when { this === other -> true diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/NumberedRationalFunction.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/NumberedRationalFunction.kt index aff18d1f4..2053cc7f9 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/NumberedRationalFunction.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/NumberedRationalFunction.kt @@ -302,7 +302,6 @@ public class NumberedRationalFunctionSpace> ( /** * Checks equality of the rational functions. */ - @Suppress("EXTENSION_SHADOWED_BY_MEMBER", "CovariantEquals") public override infix fun NumberedRationalFunction.equalsTo(other: NumberedRationalFunction): Boolean { if (this === other) return true 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 49184468b..802ff7ea2 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 @@ -66,7 +66,7 @@ public fun T.asPolynomial() : Polynomial = 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 +//@Suppress("INAPPLICABLE_JVM_NAME") // TODO: KT-31420 public open class PolynomialSpace>( public final override val ring: A, ) : AbstractPolynomialSpaceOverRing, A> { @@ -322,7 +322,6 @@ public open class PolynomialSpace>( override val zero: Polynomial = Polynomial(emptyList()) override val one: Polynomial = Polynomial(listOf(constantZero)) - @Suppress("EXTENSION_SHADOWED_BY_MEMBER", "CovariantEquals") public override infix fun Polynomial.equalsTo(other: Polynomial): Boolean = when { this === other -> true 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 e9916b634..0842f0938 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 @@ -287,7 +287,6 @@ public class RationalFunctionSpace> ( /** * Checks equality of the rational functions. */ - @Suppress("EXTENSION_SHADOWED_BY_MEMBER", "CovariantEquals") public override infix fun RationalFunction.equalsTo(other: RationalFunction): Boolean = when { this === other -> true 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 d4053442d..558afa744 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 @@ -6,6 +6,7 @@ import kotlin.contracts.* import kotlin.jvm.JvmName + // TODO: Docs // region Sort of legacy @@ -485,8 +486,8 @@ public fun NumberedPolynomial.substitute(args: Map): Number val deg = degs.getOrElse(variable) { 0u } if (deg == 0u) product else product * substitutor.pow(deg.toInt()) } - if (newDegs !in acc) acc[newDegs] = c - else acc[newDegs] = acc[newDegs]!! + c + if (newDegs !in acc) acc[newDegs] = newC + else acc[newDegs] = acc[newDegs]!! + newC } return NumberedPolynomial(acc) } @@ -504,8 +505,8 @@ public fun NumberedPolynomial.substitute(ring: Ring, args: Map val deg = degs.getOrElse(variable) { 0u } if (deg == 0u) product else product * power(substitutor, deg) } - if (newDegs !in acc) acc[newDegs] = c - else acc[newDegs] = acc[newDegs]!! + c + if (newDegs !in acc) acc[newDegs] = newC + else acc[newDegs] = acc[newDegs]!! + newC } return NumberedPolynomial(acc) }