diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Complex.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Complex.kt index e9e6fb0ce..a588f5d5c 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Complex.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Complex.kt @@ -112,46 +112,46 @@ public object ComplexField : ExtendedField, Norm { * Adds complex number to real one. * * @receiver the addend. - * @param c the augend. + * @param b the augend. * @return the sum. */ - public operator fun Double.plus(c: Complex): Complex = add(toComplex(), c) + public override operator fun Number.plus(b: Complex): Complex = add(toComplex(), b) /** * Subtracts complex number from real one. * * @receiver the minuend. - * @param c the subtrahend. + * @param b the subtrahend. * @return the difference. */ - public operator fun Double.minus(c: Complex): Complex = add(toComplex(), -c) + public override operator fun Number.minus(b: Complex): Complex = add(toComplex(), -b) /** * Adds real number to complex one. * * @receiver the addend. - * @param d the augend. + * @param b the augend. * @return the sum. */ - public operator fun Complex.plus(d: Double): Complex = d + this + public override operator fun Complex.plus(b: Number): Complex = b + this /** * Subtracts real number from complex one. * * @receiver the minuend. - * @param d the subtrahend. + * @param b the subtrahend. * @return the difference. */ - public operator fun Complex.minus(d: Double): Complex = add(this, -d.toComplex()) + public override operator fun Complex.minus(b: Number): Complex = add(this, -b.toComplex()) /** * Multiplies real number by complex one. * * @receiver the multiplier. - * @param c the multiplicand. + * @param b the multiplicand. * @receiver the product. */ - public operator fun Double.times(c: Complex): Complex = Complex(c.re * this, c.im * this) + public override operator fun Number.times(b: Complex): Complex = Complex(b.re * toDouble(), b.im * toDouble()) public override fun Complex.unaryMinus(): Complex = Complex(-re, -im) public override fun norm(arg: Complex): Complex = sqrt(arg.conjugate * arg) diff --git a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Quaternion.kt b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Quaternion.kt index ebbfb50f9..7692b0f01 100644 --- a/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Quaternion.kt +++ b/kmath-core/src/commonMain/kotlin/kscience/kmath/operations/Quaternion.kt @@ -169,47 +169,48 @@ public object QuaternionField : Field, Norm, * Adds quaternion to real one. * * @receiver the addend. - * @param c the augend. + * @param b the augend. * @return the sum. */ - public operator fun Double.plus(c: Quaternion): Quaternion = Quaternion(this + c.w, c.x, c.y, c.z) + public override operator fun Number.plus(b: Quaternion): Quaternion = Quaternion(toDouble() + b.w, b.x, b.y, b.z) /** * Subtracts quaternion from real one. * * @receiver the minuend. - * @param c the subtrahend. + * @param b the subtrahend. * @return the difference. */ - public operator fun Double.minus(c: Quaternion): Quaternion = Quaternion(this - c.w, -c.x, -c.y, -c.z) + public override operator fun Number.minus(b: Quaternion): Quaternion = + Quaternion(toDouble() - b.w, -b.x, -b.y, -b.z) /** * Adds real number to quaternion. * * @receiver the addend. - * @param d the augend. + * @param b the augend. * @return the sum. */ - public operator fun Quaternion.plus(d: Double): Quaternion = Quaternion(w + d, x, y, z) + public override operator fun Quaternion.plus(b: Number): Quaternion = Quaternion(w + b.toDouble(), x, y, z) /** * Subtracts real number from quaternion. * * @receiver the minuend. - * @param d the subtrahend. + * @param b the subtrahend. * @return the difference. */ - public operator fun Quaternion.minus(d: Double): Quaternion = Quaternion(w - d, x, y, z) + public override operator fun Quaternion.minus(b: Number): Quaternion = Quaternion(w - b.toDouble(), x, y, z) /** * Multiplies real number by quaternion. * * @receiver the multiplier. - * @param c the multiplicand. + * @param b the multiplicand. * @receiver the product. */ - public operator fun Double.times(c: Quaternion): Quaternion = - Quaternion(this * c.w, this * c.x, this * c.y, this * c.z) + public override operator fun Number.times(b: Quaternion): Quaternion = + Quaternion(toDouble() * b.w, toDouble() * b.x, toDouble() * b.y, toDouble() * b.z) public override fun Quaternion.unaryMinus(): Quaternion = Quaternion(-w, -x, -y, -z) public override fun norm(arg: Quaternion): Quaternion = sqrt(arg.conjugate * arg)