v0.2.0 #206
@ -105,54 +105,12 @@ public object ComplexField : ExtendedField<Complex>, Norm<Complex, Complex> {
|
|||||||
exp(pow * ln(arg))
|
exp(pow * ln(arg))
|
||||||
|
|
||||||
public override fun exp(arg: Complex): Complex = exp(arg.re) * (cos(arg.im) + i * sin(arg.im))
|
public override fun exp(arg: Complex): Complex = exp(arg.re) * (cos(arg.im) + i * sin(arg.im))
|
||||||
|
|
||||||
public override fun ln(arg: Complex): Complex = ln(arg.r) + i * atan2(arg.im, arg.re)
|
public override fun ln(arg: Complex): Complex = ln(arg.r) + i * atan2(arg.im, arg.re)
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds complex number to real one.
|
|
||||||
*
|
|
||||||
* @receiver the addend.
|
|
||||||
* @param b the augend.
|
|
||||||
* @return the sum.
|
|
||||||
*/
|
|
||||||
public override operator fun Number.plus(b: Complex): Complex = add(toComplex(), b)
|
public override operator fun Number.plus(b: Complex): Complex = add(toComplex(), b)
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtracts complex number from real one.
|
|
||||||
*
|
|
||||||
* @receiver the minuend.
|
|
||||||
* @param b the subtrahend.
|
|
||||||
* @return the difference.
|
|
||||||
*/
|
|
||||||
public override operator fun Number.minus(b: Complex): Complex = add(toComplex(), -b)
|
public override operator fun Number.minus(b: Complex): Complex = add(toComplex(), -b)
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds real number to complex one.
|
|
||||||
*
|
|
||||||
* @receiver the addend.
|
|
||||||
* @param b the augend.
|
|
||||||
* @return the sum.
|
|
||||||
*/
|
|
||||||
public override operator fun Complex.plus(b: Number): Complex = b + this
|
public override operator fun Complex.plus(b: Number): Complex = b + this
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtracts real number from complex one.
|
|
||||||
*
|
|
||||||
* @receiver the minuend.
|
|
||||||
* @param b the subtrahend.
|
|
||||||
* @return the difference.
|
|
||||||
*/
|
|
||||||
public override operator fun Complex.minus(b: Number): Complex = add(this, -b.toComplex())
|
public override operator fun Complex.minus(b: Number): Complex = add(this, -b.toComplex())
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiplies real number by complex one.
|
|
||||||
*
|
|
||||||
* @receiver the multiplier.
|
|
||||||
* @param b the multiplicand.
|
|
||||||
* @receiver the product.
|
|
||||||
*/
|
|
||||||
public override operator fun Number.times(b: Complex): Complex = Complex(b.re * toDouble(), b.im * toDouble())
|
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)
|
||||||
public override fun symbol(value: String): Complex = if (value == "i") i else super.symbol(value)
|
public override fun symbol(value: String): Complex = if (value == "i") i else super.symbol(value)
|
||||||
|
@ -165,50 +165,14 @@ public object QuaternionField : Field<Quaternion>, Norm<Quaternion, Quaternion>,
|
|||||||
return Quaternion(ln(n), th * arg.x, th * arg.y, th * arg.z)
|
return Quaternion(ln(n), th * arg.x, th * arg.y, th * arg.z)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds quaternion to real one.
|
|
||||||
*
|
|
||||||
* @receiver the addend.
|
|
||||||
* @param b the augend.
|
|
||||||
* @return the sum.
|
|
||||||
*/
|
|
||||||
public override operator fun Number.plus(b: Quaternion): Quaternion = Quaternion(toDouble() + b.w, b.x, b.y, b.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 b the subtrahend.
|
|
||||||
* @return the difference.
|
|
||||||
*/
|
|
||||||
public override operator fun Number.minus(b: Quaternion): Quaternion =
|
public override operator fun Number.minus(b: Quaternion): Quaternion =
|
||||||
Quaternion(toDouble() - b.w, -b.x, -b.y, -b.z)
|
Quaternion(toDouble() - b.w, -b.x, -b.y, -b.z)
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds real number to quaternion.
|
|
||||||
*
|
|
||||||
* @receiver the addend.
|
|
||||||
* @param b the augend.
|
|
||||||
* @return the sum.
|
|
||||||
*/
|
|
||||||
public override operator fun Quaternion.plus(b: Number): Quaternion = Quaternion(w + b.toDouble(), 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 b the subtrahend.
|
|
||||||
* @return the difference.
|
|
||||||
*/
|
|
||||||
public override operator fun Quaternion.minus(b: Number): Quaternion = Quaternion(w - b.toDouble(), 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 b the multiplicand.
|
|
||||||
* @receiver the product.
|
|
||||||
*/
|
|
||||||
public override operator fun Number.times(b: Quaternion): Quaternion =
|
public override operator fun Number.times(b: Quaternion): Quaternion =
|
||||||
Quaternion(toDouble() * b.w, toDouble() * b.x, toDouble() * b.y, toDouble() * b.z)
|
Quaternion(toDouble() * b.w, toDouble() * b.x, toDouble() * b.y, toDouble() * b.z)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user