0.1.4 #137

Merged
altavir merged 30 commits from dev into master 2020-09-14 22:49:30 +03:00
2 changed files with 8 additions and 2 deletions
Showing only changes of commit 837150b5eb - Show all commits

View File

@ -153,7 +153,7 @@ object ComplexField : ExtendedField<Complex>, Norm<Complex, Complex> {
*/
operator fun Double.times(c: Complex): Complex = Complex(c.re * this, c.im * this)
override fun norm(arg: Complex): Complex = arg.conjugate * arg
override fun norm(arg: Complex): Complex = sqrt(arg.conjugate * arg)
override fun symbol(value: String): Complex = if (value == "i") i else super.symbol(value)
}

View File

@ -1,6 +1,7 @@
package scientifik.kmath.operations
import kotlin.math.*
import kotlin.math.PI
import kotlin.math.abs
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
@ -64,4 +65,9 @@ internal class ComplexFieldTest {
ComplexField { i * 8 }.let { it.im.toInt() to it.re.toInt() },
ComplexField { Complex(2, 2) pow 2 }.let { it.im.toInt() to it.re.toInt() })
}
@Test
fun testNorm() {
assertEquals(2.toComplex(), ComplexField { norm(2 * i) })
}
}