v0.2.0 #206

Merged
altavir merged 210 commits from dev into master 2021-02-21 16:33:25 +03:00
2 changed files with 22 additions and 21 deletions
Showing only changes of commit 3714cfc28e - Show all commits

View File

@ -112,46 +112,46 @@ public object ComplexField : ExtendedField<Complex>, Norm<Complex, Complex> {
* Adds complex number to real one. * Adds complex number to real one.
* *
* @receiver the addend. * @receiver the addend.
* @param c the augend. * @param b the augend.
* @return the sum. * @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. * Subtracts complex number from real one.
* *
* @receiver the minuend. * @receiver the minuend.
* @param c the subtrahend. * @param b the subtrahend.
* @return the difference. * @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. * Adds real number to complex one.
* *
* @receiver the addend. * @receiver the addend.
* @param d the augend. * @param b the augend.
* @return the sum. * @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. * Subtracts real number from complex one.
* *
* @receiver the minuend. * @receiver the minuend.
* @param d the subtrahend. * @param b the subtrahend.
* @return the difference. * @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. * Multiplies real number by complex one.
* *
* @receiver the multiplier. * @receiver the multiplier.
* @param c the multiplicand. * @param b the multiplicand.
* @receiver the product. * @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 Complex.unaryMinus(): Complex = Complex(-re, -im)
public override fun norm(arg: Complex): Complex = sqrt(arg.conjugate * arg) public override fun norm(arg: Complex): Complex = sqrt(arg.conjugate * arg)

View File

@ -169,47 +169,48 @@ public object QuaternionField : Field<Quaternion>, Norm<Quaternion, Quaternion>,
* Adds quaternion to real one. * Adds quaternion to real one.
* *
* @receiver the addend. * @receiver the addend.
* @param c the augend. * @param b the augend.
* @return the sum. * @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. * Subtracts quaternion from real one.
* *
* @receiver the minuend. * @receiver the minuend.
* @param c the subtrahend. * @param b the subtrahend.
* @return the difference. * @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. * Adds real number to quaternion.
* *
* @receiver the addend. * @receiver the addend.
* @param d the augend. * @param b the augend.
* @return the sum. * @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. * Subtracts real number from quaternion.
* *
* @receiver the minuend. * @receiver the minuend.
* @param d the subtrahend. * @param b the subtrahend.
* @return the difference. * @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. * Multiplies real number by quaternion.
* *
* @receiver the multiplier. * @receiver the multiplier.
* @param c the multiplicand. * @param b the multiplicand.
* @receiver the product. * @receiver the product.
*/ */
public operator fun Double.times(c: Quaternion): Quaternion = public override operator fun Number.times(b: Quaternion): Quaternion =
Quaternion(this * c.w, this * c.x, this * c.y, this * c.z) 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 Quaternion.unaryMinus(): Quaternion = Quaternion(-w, -x, -y, -z)
public override fun norm(arg: Quaternion): Quaternion = sqrt(arg.conjugate * arg) public override fun norm(arg: Quaternion): Quaternion = sqrt(arg.conjugate * arg)